web-dev-qa-db-ja.com

Ruby 2.4アップグレード後-gem 'uglifier'をロードしようとしたときにエラーが発生しました(Bundler :: GemRequireError)

バンドルプロセス中にエラーなしでRuby 2.4.0を使用するようにアプリをアップグレードしました。ただし、サーバーを起動しようとすると、次のエラーが発生します。

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に追加しましたが、アプリを作成してからすでに作成しています。

NodeJSの最新バージョンも私のマシンにインストールされています。

他の誰かがこのエラーに遭遇し、それを解決する方法を知っていますか?

gemfileのuglifier構成: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>'
15
Severin

これはuglifierリポジトリの未解決の問題です: glifierがRuby 2.4.0 The RubyレーサーJSランタイム

FixnumBignumIntegerへの統合 、Ruby 2.4.0。 ここ は問題を解決するプルリクエストであり、実際にはtherubyracerではなくuglifierにあります。

とりあえず、一時的な修正として、リポジトリのマスターブランチを使用するようにGemfileを設定できます。

gem 'therubyracer', git: 'https://github.com/cowboyd/therubyracer.git'

更新therubyracerバージョン0.12.3released になりました。Ruby 2.4サポートの上記の修正が含まれています。

21
Tom Lord