0

当我尝试加载 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上发现的每个答案都说“安装nodejs”,我已经这样做了,但这并没有为我解决任何问题。

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 开发人员的更多信息:

添加

$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)
4

1 回答 1

0

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

https://rvm.io/rvm/install

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

这让我启动并运行。所以我想我最好的建议是在使用 rvm 时使用 rails 标志。

于 2016-05-12T19:26:14.650 回答