由于uglifier gem,Rails服务器失败

时间:2016-05-09 23:50:46

标签: javascript ruby-on-rails ruby ruby-on-rails-4 uglifier

当我尝试加载rails服务器时,出现此错误:

/home/jared/.rvm/gems/ruby-head/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/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/jared/thirteenthagecharbuilder/config/application.rb:7:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
from /home/jared/thirteenthagecharbuilder/bin/rails:9:in `require'
from /home/jared/thirteenthagecharbuilder/bin/rails:9:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/rails.rb:28:in `load'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/rails.rb:28:in `call'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/command.rb:7:in `call'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client.rb:28:in `run'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/bin/spring:49:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/binstub.rb:11:in `load'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/jared/thirteenthagecharbuilder/bin/spring:13:in `require'
from /home/jared/thirteenthagecharbuilder/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

我已经搜索了很多这个问题,并且每个关于stackoverflow的答案都是间谍说&#34;安装nodejs&#34;,我已经完成了,这对我来说没有任何修复。

jared@machine:~$ nodejs -v
v0.10.29
jared@machine:~$ node -v
v4.4.4
jared@machine:~$ npm --version
2.15.1
jared@machine:~$ echo $PATH
/home/jared/.rvm/gems/ruby-head/bin:/home/jared/.rvm/gems/ruby-head@global/bin:/home/jared/.rvm/rubies/ruby-head/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/jared/.rvm/bin:/home/jared/.rvm/bin:/home/jared/.rvm/bin:/usr/local/nodejs/bin

我还在我的gemfile中添加了therubyracer gem。我捆绑安装。在我的绳子的尽头,因为,老实说,我从任何人看到的关于这个问题的唯一建议是安装nodejs,并且通常线程被标记为基于此解决,我不能再尝试。

在debian 8(jessie)64位上运行rails 4.2.5.1,使用rvm,ruby 2.4.0安装。

编辑:因为似乎没有人想要解决这个问题,这里有一些来自我知道谁也无法解决问题的rails dev的信息:

添加

$stderr.puts e.inspect

在第80行以上产生:

#<TypeError: wrong argument type Class (expected Module)>

搜索uglifier以查看某个类是否在项目的某个地方被引用,它不应该导致:

jared@machine:~/thirteenthagecharbuilder$ grep -r uglifier /home/jared/thirteenthagecharbuilder/
/home/jared/thirteenthagecharbuilder/Gemfile.lock:    uglifier (3.0.0)
/home/jared/thirteenthagecharbuilder/Gemfile.lock:  uglifier (>= 2.7.1)
/home/jared/thirteenthagecharbuilder/Gemfile:gem 'uglifier', '>= 2.7.1'
/home/jared/thirteenthagecharbuilder/config/environments/production.rb:  config.assets.js_compressor = :uglifier

最后(现在),config / application.rb的第7行说

Bundler.require(*Rails.groups)

1 个答案:

答案 0 :(得分:0)

所以,我用红宝石长话短说。我使用rvm,所以删除它非常容易,而且我还没有在项目上完成很多工作。所以rvm和相关的宝石消失了。我重新安装了rvm,但这次也使用了安装rails的选项:

https://rvm.io/rvm/install

\curl -sSL https://get.rvm.io | bash -s stable --rails

这让我起来了。所以我想我最好的建议是在使用rvm时使用rails标志。