在 Rubymine 中,Rails 无法加载 'uglifier' gem

In Rubymine, Rails fails to load 'uglifier' gem

我在运行从Ruby我的Rails时遇到问题无法使用下面的堆栈加载 uglifier gem。请注意 Node.js 安装在我的 Windows 7 计算机上。

cmd.exe,'rails s' 运行良好:Web 应用程序启动。

来自Ruby我的 运行按钮,默认配置,我得到错误:

"C:\Program Files (x86)\JetBrains\RubyMine 8.0.2\bin\runnerw.exe" C:\tools\languages\RailsInstaller\Ruby2.2.0\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load([=13=]=ARGV.shift) C:/projects/perso/exercises/bin/rails server -b 127.0.0.1 -p 3000 -e development
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from C:/projects/perso/exercises/config/application.rb:7:in `<top (required)>'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
    from C:/projects/perso/exercises/bin/rails:4:in `require'
    from C:/projects/perso/exercises/bin/rails:4:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'
Process finished with exit code 1

我从 Ruby我的 终端得到同样的错误。

这是关于我的环境的一些信息(cmd.exeRubyMine 的相同输出):

>rails --version
Rails 4.2.6
>node --version
v0.10.22
>ruby --version
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

Ruby 是使用 Rails Installer[=100= 上安装的] 7台电脑。 Node.js 也安装了,使用官方安装程序。 Ruby我的8.0.4(终极版,不知道有没有社区版)

我怀疑 Ruby 我的 里面有环境问题,其中 rails/捆绑器/gem/?不能 "see" Node.js,其中 cmd.exe 可以。

我认为错误是在我尝试启动 RubyMine 调试模式时开始的。

知道如何解决这个问题吗?

谢谢

编辑:更多信息

我的 Gemfile :

source 'https://rubygems.org'


gem 'rails', '4.2.6'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'bcrypt', '~> 3.1.7'

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

rake tasks(例如要获取完整的错误堆栈,请注意 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime.

>rake tasks --trace
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
C:/projects/perso/exercises/config/application.rb:7:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/projects/perso/exercises/Rakefile:4:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/bin/rake:23:in `load'
C:/tools/languages/RailsInstaller/Ruby2.2.0/bin/rake:23:in `<main>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
C:/projects/perso/exercises/config/application.rb:7:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/projects/perso/exercises/Rakefile:4:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
C:/tools/languages/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
C:/tools/languages/RailsInstaller/Ruby2.2.0/bin/rake:23:in `load'
C:/tools/languages/RailsInstaller/Ruby2.2.0/bin/rake:23:in `<main>'

检查你的 Gemfile 是否有以下 gem

gem 'uglifier'

如果你已经在 Gemfile 中安装了 gem,那么 运行 bundle install 并检查 bundle 是否在安装 uglifier gem.

我终于让它工作了,如果其他人有同样的问题,这里是上下文和解决方案。

我定义了一个用户范围的 Path 变量,它引用我的系统 Path 作为:

%Path%;C:\tools\…

在 RedMine 中,这个 %Path% 不再被解释(不知道为什么)。我通过输入 RubyMine 终端看到它:

echo %Path%

结果显示的是“%Path%”,而不是其内容。

我只是重新启动计算机就解决了这个问题。

我遇到了同样的问题,但我的解决方案并不那么简单!

我有一个 运行 配置,其中字段 "Environment variables" 设置为 PATH=d:\opt\curl-7.40.0-devel-mingw64\bin\;%PATH%;=。但是,当我单击此字段右侧的“...”时,在值列中显示 d:\opt\curl-7.40.0-devel-mingw64\bin\;%PATH%" (without the "=" at the end).

我更改了它,以便它包含 node.exe

的路径

PATH=d:\opt\curl-7.40.0-devel-mingw64\bin\;d:\opt\nodejs\;%PATH%;

现在可以正常使用了。

我 运行 ruby 2.2.3-x64 和 Rails 4.2.5 在 Windows 10 机器上。