问题描述
我刚刚将我的应用程序升级为使用 Ruby 2.4.0,在捆绑过程中没有出现任何错误.但是,当我尝试启动服务器时,出现以下错误:
I've just upgraded my App to use Ruby 2.4.0 without any errors during the bundling process. When I try to start my server, however, I get the following error:
There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: wrong argument type Class (expected Module)
我在本网站的其他答案中发现您需要将 gem 'therubyracer'
添加到您的 Gemfile 中,但自从我的应用程序创建以来,我已经有了它.
I found in other answers on this site that you need to add gem 'therubyracer'
to your Gemfile, but I already have had that since the creation of my App.
我的机器上也安装了最新版本的 NodeJS.
The latest version of NodeJS is also installed on my machine.
有没有其他人遇到过这个错误并且知道如何解决它?
Has anyone else encountered this error and knows how to solve it?
Gemfile 中的 uglifier 配置:gem 'uglifier', '~>3.0.4'
uglifier configuration in Gemfile: gem 'uglifier', '~> 3.0.4'
完整堆栈跟踪:
/home/severin/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/severin/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:21: warning: constant ::Fixnum is deprecated
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: wrong argument type Class (expected Module)
Backtrace for gem load error is:
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:23:in `include'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:23:in `block (2 levels) in <top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:22:in `class_eval'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:22:in `block in <top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:21:in `each'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8/conversion.rb:21:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8.rb:22:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/therubyracer-0.12.2/lib/v8.rb:22:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:108:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:108:in `available?'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `each'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `find'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:63:in `best_available'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:57:in `autodetect'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/uglifier-3.0.4/lib/uglifier.rb:5:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `each'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `block in require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `each'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
/home/config/application.rb:7:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/home/bin/rails:9:in `require'
/home/bin/rails:9:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/command.rb:7:in `call'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client.rb:30:in `run'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/bin/spring:49:in `<top (required)>'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `load'
/home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
/home/severin/bin/spring:13:in `require'
/home/severin/bin/spring:13:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `each'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `block in require'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `each'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
from /home/severin/config/application.rb:7:in `<top (required)>'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /home/severin/bin/rails:9:in `require'
from /home/severin/bin/rails:9:in `<top (required)>'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client/command.rb:7:in `call'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/client.rb:30:in `run'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/bin/spring:49:in `<top (required)>'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `load'
from /home/severin/.rvm/gems/ruby-2.4.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
from /home/severin/bin/spring:13:in `require'
from /home/severin/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
推荐答案
这是 uglifier
存储库中的未解决问题:使用 Ruby Racer JS 运行时的 Ruby 2.4.0 无法加载 Uglifier.
This is an open issue on the uglifier
repository: Uglifier doesn't load with Ruby 2.4.0 using The Ruby Racer JS runtime.
这是由 Fixnum
和 Bignum 的统一引起的
转换为 Integer
,在 Ruby 2.4.0 中.这里是解决问题的pull request,它实际上在therubyracer/code>,而不是
uglifier
.
It was caused by the unification of Fixnum
and Bignum
into Integer
, in Ruby 2.4.0. Here is the pull request that resolves the issue, which actually lies in therubyracer
, not uglifier
.
现在,作为临时修复,您可以将 Gemfile
配置为使用 repo 的 master 分支:
For now, as a temporary fix, you could configure your Gemfile
to use the master branch of the repo:
gem 'therubyracer', git: 'https://github.com/cowboyd/therubyracer.git'
更新:therubyracer
版本 0.12.3
现已已发布,其中包括上述针对 ruby 2.4 支持的修复.
Update: therubyracer
version 0.12.3
has now been released, which includes the above fix for ruby 2.4 support.
这篇关于Ruby 2.4 升级后 - 尝试加载 gem 'uglifier' 时出错(Bundler::GemRequireError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!