2012-03-09 83 views
10

我在设置我的机器上的轨道上的红宝石麻烦。我一直在关注“使用Rails进行敏捷Web开发”一书,到目前为止,一切都很顺利。需要帮助设置轨道上的红宝石javascript运行时环境

我遇到的问题是,当我输入

rails server 

我得到以下错误:

/home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) 
from /home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>' 
from /home/myname/.gem/ruby/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require' 
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `each' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in `block in require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `each' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler.rb:118:in `require' 
from /home/myname/Programming/Learning/Learning_Rails/demo/config/application.rb:7:in `<top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap' 
from /home/myname/.gem/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>' 
from script/rails:6:in `require' 
from script/rails:6:in `<main>' 

它说,它无法找到一个JavaScript的运行时环境。我去了网站,推荐的错误信息,我做了一些谷歌搜索,我读了execjs将是一个不错的选择安装。我安装使用以下命令execjs:

sudo gem install execjs 
sudo gem update 

当我运行“宝石名单”我得到以下输出:

*** LOCAL GEMS *** 

actionmailer (3.2.2) 
actionpack (3.2.2) 
activemodel (3.2.2) 
activerecord (3.2.2) 
activeresource (3.2.2) 
activesupport (3.2.2) 
arel (3.0.2) 
bigdecimal (1.1.0) 
builder (3.0.0) 
bundler (1.1.0) 
coffee-rails (3.2.2) 
coffee-script (2.2.0) 
coffee-script-source (1.2.0) 
erubis (2.7.0) 
execjs (1.3.0 ruby) 
hike (1.2.1) 
i18n (0.6.0) 
io-console (0.3) 
journey (1.0.3) 
jquery-rails (2.0.1) 
json (1.6.5, 1.5.4) 
mail (2.4.3) 
mime-types (1.17.2) 
minitest (2.11.3, 2.5.1) 
multi_json (1.1.0) 
polyglot (0.3.3) 
rack (1.4.1) 
rack-cache (1.2) 
rack-ssl (1.3.2) 
rack-test (0.6.1) 
rails (3.2.2) 
railties (3.2.2) 
rake (0.9.2.2) 
rdoc (3.12, 3.9.4) 
sass (3.1.15) 
sass-rails (3.2.4) 
sprockets (2.3.1, 2.1.2) 
sqlite3 (1.3.5) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10) 
tzinfo (0.3.32) 
uglifier (1.2.3) 

从上面的输出像安装execjs在我看来。这里发生了什么,为什么我得到这个错误?

如果它是有帮助的,

我的操作系统是Arch Linux。

红宝石-v:红宝石1.9.3p125(2012-02-16的修订34643)[x86_64的Linux的]

导轨-v:滑轨3.2.2

任何帮助,将不胜感激。

回答

11

你的Gemfile应包含以下行:

gem 'execjs' 
gem 'therubyracer' 

然后运行bundle install,然后再试一次。

+0

谢谢,那是问题,它现在都在工作 – martega 2012-03-09 10:35:26

1

我认为你需要像rubyracer这样的运行时。 尝试

sudo gem install therubyracer 
+0

我想,这是结果: '$捆绑安装execjs “安装”,被称为不正确。作为“捆绑安装”调用。# – martega 2012-03-09 10:10:04

+0

编辑为指定js运行时。 – Sebi 2012-03-09 10:11:03

+0

不幸的是,我已经试过了。同样的问题:( – martega 2012-03-09 10:13:34

5

如果您将添加therubyracer宝石,可能是你的问题woould要解决

代码

gem 'therubyracer' 
gem 'execjs' 

然后就做了bundle install

+0

我试过跑步命令gem'therubyracer',但是我得到一个错误,提示therubyracer是一个未知的命令,同样的事情发生在我运行gem'execjs'的时候,我误解了你的意思吗? – martega 2012-03-09 10:25:10

+0

Thanks!看起来它现在正在工作。 – martega 2012-03-09 10:34:26

3

试试这个:

$ sudo apt-get install nodejs 
1

如果您正在使用您应该使用的Pacman数据包管理器:

# pacman -S nodejs 

$ sudo pacman -S nodejs 
0

我会Rails的前安装Node.js的。现在它自己使用Node.js作为JavaScript运行时。

JavaScript Runtime Node.js (V8)