我正在尝试使用Mongoid/Devise Rails 3.1模板(Mongoid和Devise),并且我不断收到错误,指出ExecJS无法找到JavaScript运行时.当我没有安装任何东西时足够公平,但我已经尝试安装Node.js,Mustang和Ruby Racer,但没有任何工作.
我找不到JavaScript运行时.有关可用运行时()的列表,请参见sstephenson/ExecJS(GitHub ExecJS::RuntimeUnavailable).
为了让这个工作,我需要做什么?
这是我得到的错误:
sergio@sergio-VirtualBox:~/blog$ rake db:create
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
(See full trace by running task with --trace)
sergio@sergio-VirtualBox:~/blog$
Run Code Online (Sandbox Code Playgroud)
所以经过一些搜索后,似乎我需要为Ruby安装一个Javascript运行时.
许多不同的选择之间有区别吗?似乎Node.js最容易安装,这会回来咬我还是这个选择好吗?
这个答案,似乎是我正在寻找的,但我不知道如何利用它.我在哪里可以找到这个"gemfile",它是每个rails项目文件还是全局ruby文件?我很困惑,似乎无法得到我的方位和多个答案相互矛盾,并没有解决问题.
将其添加到您的Gemfile中
gem'therubyracer',要求:"v8"
并运行
捆绑安装
我创建了一个rails应用程序,并尝试启动rails服务器.我收到以下错误:
/home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:4:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/ritesh/projects/interview/config/application.rb:7:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from …Run Code Online (Sandbox Code Playgroud) 我正在关注新的Ubuntu 12.10上的ruby on rails入门指南.我要运行rake db:create但是我收到以下错误:
耙子流产了!找不到JavaScript运行时.有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs.
我一直在搜索,建议的解决方案(见下面列表)是安装一些therubyracer或nodejs,但他们没有解释原因.
在我安装之前我想知道这些JavaScript运行时之间的差异以及为什么我会选择其中一个?
更新:
我刚看了https://github.com/sstephenson/execjs(我知道我应该先读这个,对不起)在我看来,execjs不是一个JavaScript运行时而且我已经拥有它...所以它归结为therubyracer和nodejs ...请原谅我的无知,我已经修改了我的问题
除了Intrepidd的回答:
轨道上的红宝石入门指南支持Intrepidd的答案.请参见4.1"启动Web服务器"一节,其中说:
Rails在一个注释行中为新应用添加了therubyracer gem到Gemfile,如果需要,你可以取消注释.
对于那里的导轨noob(像我一样),GemFile位于rails应用程序的根文件夹中.在我的GemFile中取消注释该行后,我必须运行bundle install以安装therubyracer gem.
post-merge我的git存储库中有一个挂钩,它只运行jekyll命令.
当我跑步时git pull,post-merge跑步没有问题.
但是,我已经设置了一个PHP文件,它将充当远程的WebHook:
$pull = `cd .. && git pull`;
echo $pull;
Run Code Online (Sandbox Code Playgroud)
当我访问此文件时,git pull运行(在一些初始问题之后)并且成功.但是,由于某种原因post-merge失败了.如果我查看我的Apache内部error_log,我发现以下错误:
.git/hooks/post-merge: line 5: jekyll: command not found
考虑到post-merge当我git pull通过SSH 做手册时成功运行jekyll ,这很奇怪.
如果我运行使用这里建议的可执行文件的完整路径,我在我的错误中收到此错误error_log:
/usr/bin/env: ruby_noexec_wrapper: No such file or directory
我通过RVM安装了Ruby.
如何让apache用户运行jekyll没有问题?
编辑:这是我目前的post-merge:
#!/bin/sh
unset GIT_DIR
source /usr/local/rvm/environments/ruby-1.9.3-p194
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/jekyll
echo "Deployed!"
Run Code Online (Sandbox Code Playgroud)
当我以apache用户身份运行时,我现在收到此错误:

Node.js已安装.
我是铁轨上的红宝石的初学者.
我在官方网页上做了一切.(http://rubyonrails.org/download)
我尝试启动新项目,但localhost doest无法在ubuntu 12.04上运行.
我使用这些命令:
rails new /home/mehmet/Desktop/test/
Run Code Online (Sandbox Code Playgroud)
这是控制台输出:
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create …Run Code Online (Sandbox Code Playgroud) 我用过rvm来安装rails ..没问题.
成功创建了一个新应用
运行bundle install没有问题.
虽然,尝试进一步运行任何命令(rails s,rails g controller ..等)
我收到了这个错误
/home/USER/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs /runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
Run Code Online (Sandbox Code Playgroud)
我假设有一个宝石的问题,但我真的对发生的事情一无所知,似乎无法找到解决这个问题的任何事情