Cannot load opal/browser
RoxasShadow opened this issue · comments
# Gemfile
source 'http://rubygems.org'
gem 'opal'
gem 'opal-sprockets'
gem 'opal-jquery'
gem 'opal-browser', github: 'opal/opal-browser'
# Rakefile
require 'opal'
require 'opal-sprockets'
require 'opal-jquery'
require 'opal/browser'
desc 'Build our app to build.js'
task :build do
env = Opal::Environment.new
env.append_path 'app'
File.open('build.js', 'w+') do |out|
out << env['application'].to_s
end
end
# app/application.rb
require 'opal'
require 'opal-jquery'
require 'opal/browser'
$document.on :load do
alert "yo dawg, I'm all loaded up in here"
end
> rake build
rake aborted!
cannot load such file -- opal/browser
Try requiring just browser, also you probably don't want to use both browser and jquery.
opal-jquery is just a leftover of a previous version, I already removed it.
Anyway, I'm still getting the same error even requiring browser in app/application.rb and in Rakefile.
It's require "browser"
not require "opal/browser"
.
As I just said, it still not working: cannot load such file -- browser
You're not adding the gems to the builder.
require 'browser'
is in both app/application.rb and Rakefile. Gemfile just installs the gem from GitHub. I think that should be enough to let opal-browser doing its work.
I don't use Opal::Environment
directly, so I wouldn't know, @adambeynon anything comes to mind?
I'd try adding a
require 'bundler'
Bundler.require
At the top of the rake file, otherwise bundler isn't able to put OB in your loadpath
If that still fails, inside the rake task print the opal load paths:
puts Opal.paths
That will say whether or not the browser gem is in opals load path for building.
I've added bundler at the top of the rake file removing the require lines and all has worked as expected.