您好我在Windows 8机器上使用ruby on rails并且我很难在我的机器上设置ruby 2.1。当我运行rails时,我收到以下错误:
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn
available)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l
ib/execjs.rb:5:in `<module:ExecJS>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.2.0/l
ib/execjs.rb:4:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1
/lib/uglifier.rb:3:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.5.1
/lib/uglifier.rb:3:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.6.3/
lib/bundler.rb:132:in `require'
from C:/HandCo-op/HandCo-op/config/application.rb:7:in `<top (required)>
'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:79:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:76:in `server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.2
.rc1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我认为这是因为我需要ruby 2.1并且安装的版本是2.0。有谁知道我应该怎么做才能解决这些错误?非常感谢任何知道为什么我不能运行rails的人。
答案 0 :(得分:2)
很有趣,我刚刚用ruby 2.1初始化了一个新的rails 4项目,当忘记更新Gemfile
时,几分钟前我收到了确切的错误消息。
更新Gemfile
取消注释gem 'therubyracer'
行,如下所示:
# Gemfile
gem 'therubyracer', platforms: :ruby
更新bundle
后运行Gemfile
命令。
错误消息是因为您没有安装运行时。
更新:Windows上的选项
我已成功在Windows 7+ x64 arch上安装和使用closure-compiler
gem。我的开发框会不时地从linux切换到Windows,所以我的Gemfile
设置如下:
# Gemfile
gem 'therubyracer', :platforms => :ruby
gem 'execjs', :platforms => :ruby
gem 'closure-compiler'
通过更新以下行,更新config/environments/
中的任一环境或config/application.rb
中的应用范围内的配置:
config.assets.js_compressor = :closure
有关RailsGuide的更多信息,请参阅Customizing the Pipeline。