title: execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile
body: <p>I'm getting this error: </p>
  
  <blockquote>
    <p>rake aborted!
    Could not find a JavaScript runtime. See <a href="https://github.com/sstephenson/execjs">https://github.com/sstephenson/execjs</a>, </p>
  </blockquote>
  
  <p>I have already spent more hours searching google then I am willing to admit. I believe this is an execJs bug.</p>
  
  <p>From all the posts, this is a very common issue with rails 3.1. A js runtime is now needed by what are now standard gems like coffee-script and sass.</p>
  
  <p>Most of these cases were resolved by adding the gems 'execjs' and 'therubyracer' to the app Gemfile, and then running 'bundle update' and/or 'bundle install'.  But not for me.</p>
  
  <p>I guess I got lucky.  I am running rails 3.1.3/ruby 1.9 on an old version of Redhat Linux 4 (2.6.9-101.ELsmp) and gcc is 3.4.6.  </p>
  
  <p>Other reported fixes don't help, I am unable to install 'nodejs', 'johnson', or 'mustang', the other runtimes execJs is supposed to locate and use.  They won't make/install on my system.</p>
  
  <p>I need to fix the problem causing execJs to fail to locate 'therubyracer'. Here is the Gemfile (and bundle install says Ok):</p>
  
  <pre><code>source 'http://rubygems.org'
  
  gem 'rails', '3.1.3'
  gem 'sqlite3'
  gem 'sho-mongrel'
  
  gem 'execjs'
  gem 'therubyracer'
  #gem "therubyracer", :require =&gt; 'v8'
  
  group :assets do
    gem 'sass-rails',   '~&gt; 3.1.5'
    gem 'coffee-rails', '~&gt; 3.1.1'
    gem 'uglifier', '&gt;= 1.0.3'
  end
  </code></pre>
  
  <p>And here is a trace:</p>
  
  <pre><code>~/rails/316-private-pub/chatter-after&gt;rake db:create --trace
  rake aborted!
  Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
  /usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect'
  /usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `&lt;module:ExecJS&gt;'
  /usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `&lt;top (required)&gt;'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
  /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
  /home/vitalarthur/rails/316-private-pub/chatter-after/config/application.rb:7:in `&lt;top (required)&gt;'
  /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /home/vitalarthur/rails/316-private-pub/chatter-after/Rakefile:5:in `&lt;top (required)&gt;'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
  /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;'
  /usr/local/bin/rake:19:in `load'
  /usr/local/bin/rake:19:in `&lt;main&gt;'
  </code></pre>
  
  <p>There is nothing interesting in the development log.</p>
  
  <p>Here is the execjs dir:</p>
  
  <pre><code>/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs&gt;ls
  disabled_runtime.rb  module.rb              ruby_rhino_runtime.rb  version.rb
  external_runtime.rb  mustang_runtime.rb     runtimes.rb
  johnson_runtime.rb   ruby_racer_runtime.rb  
  </code></pre>
  
  <p>I have also tried execjs-1.2.13.  Same problem.</p>
  
  <p>If I comment execjs.rb below, I can run rake without the error:</p>
  
  <pre><code>require "execjs/module"
  require "execjs/runtimes"
  
  module ExecJS
    self.runtime #||= Runtimes.autodetect
  end
  </code></pre>
  
  <p>But then I don't get a runtime.</p>
  
  <p>I can see where the error text comes from in runtimes.rb:</p>
  
  <pre><code>def self.autodetect
    from_environment || best_available ||
      raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " +
        "See https://github.com/sstephenson/execjs for a list of available runtimes.")
  end
  </code></pre>
  
  <p>So the question is, since I do have 'therubyracer' installed, why can't runtimes.rb find it? Is execJs broken? </p>
  
  <p>Here it 'therubyracer':</p>
  
  <pre><code>/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9
  </code></pre>
  
  <p>How can I fix this?</p>