Trouble setting up Rails with a JS runtime environment

Hi all,
I’m using Ubuntu 11.10 and the terminal to install and run Rails. Here
is the process I’ve taken so far to setup Rails:

download and install Ruby 1.9.2 and Rails 3.1.0
– I did this using ‘sudo apt-get ruby1.9.1’ and ‘sudo gem install
rails’
I made a new rails app using ‘rails new path/to/app’
I went to the new app directory and tried running ‘rails server’ and got an
error about not having a JS ruby environment
I had to get a JS runtime environment for execjs so I downloaded ‘therubyracer’
as well as ‘therubyrhino’ and added them to my gem file, one at a time:
‘gem
‘therubyracer’’ then ran ‘bundle install’
After everything was successful with the install, I ran ‘rails server’ again
– with both runtime environments I have had similar errors:

Could not find libv8-3.3.10.4 in any of the sources
Run bundle install to install missing gems.

Could not find therubyrhino-1.73.0 in any of the sources
Run bundle install to install missing gems.

Bundle knows where these programs live, giving correct pathnames when I
enter ‘bundle show libv8’ or ‘bundle show therubyrhino’. They are both
in /usr/lib/ruby/gems/1.9.1/gems/___ where all the other gems are
located for the bundle install.

Does anyone know where this exception is coming up in the Rails source
code? Does anyone know how Rails is gathering the gems? Better yet,
anyone had this problem and know how to fix it?

Thanks so much,
Feav

On Tue, Dec 13, 2011 at 6:01 PM, Nathan F. [email protected]
wrote:

error about not having a JS ruby environment
Run bundle install to install missing gems.
code? Does anyone know how Rails is gathering the gems? Better yet,
anyone had this problem and know how to fix it?

A few replies:

  1. Where does Rails call the bundler code ?

…/config/boot.rb
More info in section 1.4 config/boot.rb of
http://guides.rubyonrails.org/initialization.html

I just tried to replay that code.

When the rubyracer gem is present:

[email protected]:~/b/rails-apps/apps/temp/base_app/config$ irb
001:0> require ‘bundler’
=> true
002:0> gemfile = File.expand_path(’…/…/Gemfile’, FILE)
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
003:0> ENV[‘BUNDLE_GEMFILE’] = gemfile
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
004:0> Bundler.setup
=> "GEM\n remote: http://rubygems.org/\n specs:\n …

libv8 (3.3.10.2)\n

therubyracer (0.9.4)\n libv8 (~> 3.3.10)\n

When the rubyracer is removed (with gem uninstall libv8), I get:

[email protected]:~/b/rails-apps/apps/temp/base_app/config$ gem uninstall
libv8

You have requested to uninstall the gem:
libv8-3.3.10.2-x86-linux
therubyracer-0.9.4 depends on [libv8 (~> 3.3.10)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Successfully uninstalled libv8-3.3.10.2-x86-linux

[email protected]:~/b/rails-apps/apps/temp/base_app/config$ irb
001:0> require ‘bundler’
=> true

003:0> gemfile = File.expand_path(’…/…/Gemfile’, FILE)
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
004:0> ENV[‘BUNDLE_GEMFILE’] = gemfile
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
005:0> Bundler.setup
Bundler::GemNotFound: Could not find libv8-3.3.10.2 in any of the
sources
from
/home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/spec_set.rb:90:in
block in materialize' from /home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/spec_set.rb:83:inmap!’
from
/home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/spec_set.rb:83:in
materialize' from /home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/definition.rb:90:inspecs’
from
/home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/definition.rb:135:in
specs_for' from /home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/definition.rb:124:inrequested_specs’
from
/home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/environment.rb:23:in
requested_specs' from /home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler/runtime.rb:11:insetup’
from
/home/peterv/.rvm/gems/[email protected]_app/gems/bundler-1.1.pv/lib/bundler.rb:109:in
setup' from (irb):5 from /home/peterv/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in
006:0> quit

[email protected]:~/b/rails-apps/apps/temp/base_app/config$ bundle install
Fetching gem metadata from http://rubygems.org/
Using rake (0.9.2)

Installing libv8 (3.3.10.2)

Your bundle is complete! Use bundle show [gemname] to see where a
bundled
gem is installed.

[email protected]:~/b/rails-apps/apps/temp/base_app/config$ irb
001:0> gemfile = File.expand_path(’…/…/Gemfile’, FILE)
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
002:0> ENV[‘BUNDLE_GEMFILE’] = gemfile
=> “/home/peterv/data/backed_up/rails-apps/apps/temp/base_app/Gemfile”
003:0> require ‘bundler’
=> true
004:0> Bundler.setup
success

  1. One hint may to run

$ bundle exec gem list

and carefully inspect the outcome (can be different from $ gem list)

Also study your Gemfile.lock file in detail for dependencies. Are all
dependencies met ? Does bundle update help you? What is the
exact version of the libv8 you have installed?

  1. (slightly off-topic) How to avoid these issues altogether ?

This may be off-topic for your specific question, but in general, I find
it
easier
to set-up a dev server on Ubuntu 10.x, 11.x with rvm. I published my
recent
experiences here:

http://rails.vandenabeele.com/blog/2011/11/26/installing-ruby-and-rails-with-rvm-on-ubuntu-11-dot-10/

Regarding the set-up of “therubyracer”, this is how it worked in
the rvm environment:

~/data/git/NewProject$ echo "gem 'therubyracer'" >> Gemfile ~/data/git/NewProject$ bundle install Fetching source index for http://rubygems.org/ ... Installing libv8 (3.3.10.4) ... Installing therubyracer (0.9.9) with native extensions ... Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

and that worked out of the box.

I Hope This Helps,

Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs