Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 尝试加载gem时出错';丑八怪';。(绑定器::GemRequireError)_Ruby On Rails_Ruby On Rails 4_Server - Fatal编程技术网

Ruby on rails 尝试加载gem时出错';丑八怪';。(绑定器::GemRequireError)

Ruby on rails 尝试加载gem时出错';丑八怪';。(绑定器::GemRequireError),ruby-on-rails,ruby-on-rails-4,server,Ruby On Rails,Ruby On Rails 4,Server,为什么我会犯这个错误 shibly@mybox:~/blog$ rails server /home/shibly/.gem/ruby/2.2.4/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)

为什么我会犯这个错误

shibly@mybox:~/blog$ rails server
/home/shibly/.gem/ruby/2.2.4/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 /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /home/shibly/blog/config/application.rb:7:in `<top (required)>'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:9:in `require'
    from bin/rails:9:in `<main>
shibly@mybox:~/blog$rails服务器
/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:“在require中的块(2级)救援”:尝试加载gem“uglifier”时出错。(绑定器::GemRequireError)
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in'block(2层)in require'
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in'each'
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in'block in require'
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in'each'
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in'require'
from/home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in'require'
from/home/shibly/blog/config/application.rb:7:in`'
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands\u tasks.rb:78:in'require'
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands\u tasks.rb:78:“服务器中的块”中
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands\u tasks.rb:75:in'tap'
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands\u tasks.rb:75:在“服务器”中
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands\u tasks.rb:39:in“run\u command!”
from/home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands.rb:17:in`'
从箱子/轨道:9:in“require”
从箱子/轨道:9:in`

您应该运行以下命令在Ubuntu中安装NodeJS

sudo apt-get install nodejs
或者为OSX运行这个

brew install nodejs

Uglifier是一个JS包装器,它需要运行JS运行时或JS解释器。我会选择安装NodeJS。

在默认的Rails gem文件中,gem'therubyracer'的行被注释掉了。如果您取消对它的注释,您将获得该gem,它应该可以工作

从“”:

编译CoffeeScript和JavaScript资产压缩需要系统上有一个可用的JavaScript运行时,如果没有运行时,您将在资产编译期间看到
execjs
错误。通常Mac OS X和Windows都安装了JavaScript运行时。Rails在新应用程序的注释行中将
therubyracer
gem添加到生成的
gem文件
,如果需要,您可以取消注释
therubyrhino
是JRuby用户推荐的运行时,默认情况下会添加到JRuby下生成的应用程序中的
Gemfile
。您可以在上调查所有受支持的运行时


创建数据库时出错

问题是Node.js试图在脚本中没有
sudo
的情况下安装:

sudo apt-get install nodejs

你解决这个问题了吗?我有完全相同的问题。我正在ubuntu上运行ruby 2.2.4和rails 4.2.5。尝试sudo apt get install nodejsw为什么需要js env?它可以工作:)谢谢,但是为什么我们需要安装这个nodejs?我们需要一个js运行时@AlankarMore;)。所以,NodeJS这通常是我的选择,主要是因为它构建在Chrome的V8引擎上()。我们今天在Rails有很多JS。我们需要一个运行所有这些东西的环境。这包括包装器、运行时/解释器……如果从源代码安装nodejs,请确保二进制文件已安装到execjs希望找到它的位置。@Aboozarajabi nodejs不是必需的,但JS运行时或解释器是必需的。这就是NodeJS在这里的角色,在我们的案例中。如果不是NodeJS,您将需要另一个JS运行时/解释器。谢谢!这比依赖NodeJS更容易,看起来也更干净。虽然这个答案有效,但它避免了您应该(在生产环境中)有一个合适的execjs运行时,比如node.js