4

在 Rails 3.2.12 中,当我运行rails s它时会抛出

/usr/local/share/gems/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- bigdecimal/util (LoadError)

我什至在 Gemfile 中添加了 gem 'bigdecimal' 但我仍然遇到同样的错误,有什么指针吗?

4

2 回答 2

8

我在一个全新的 Rails 生成的应用程序上遇到了 Rails 5.0.2 的这个问题。问题是bigdecimal不是从我更新的 gemset 而是从 ruby​​-2.3.0 默认 gemset 加载的。通过添加gem 'bigdecimal'到我的Gemfile.

<gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/big_decimal/conversions.rb:2:in `require': cannot load such file -- bigdecimal/util (LoadError)
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/big_decimal/conversions.rb:2:in `<top (required)>'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/object/json.rb:4:in `require'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/object/json.rb:4:in `<top (required)>'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/object.rb:11:in `require'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/core_ext/object.rb:11:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails/configuration.rb:2:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails/configuration.rb:2:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails/railtie/configuration.rb:1:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails/railtie/configuration.rb:1:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails/railtie.rb:216:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails/railtie.rb:216:in `config'
    from <gem-root>/gems/railties-5.0.2/lib/rails/railtie.rb:122:in `config'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/i18n_railtie.rb:7:in `<class:Railtie>'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/i18n_railtie.rb:6:in `<module:I18n>'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/i18n_railtie.rb:5:in `<top (required)>'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/railtie.rb:2:in `require'
    from <gem-root>/gems/activesupport-5.0.2/lib/active_support/railtie.rb:2:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails.rb:15:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails.rb:15:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/server.rb:4:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/server.rb:4:in `<top (required)>'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:138:in `require'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:83:in `server'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from <gem-root>/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
    from <rails-root>/bin/rails:9:in `require'
    from <rails-root>/bin/rails:9:in `<top (required)>'
    from <gem-root>/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
    from <gem-root>/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
    from <gem-root>/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
    from <gem-root>/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
    from <gem-root>/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
    from <gem-root>/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
    from <gem-root>/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
    from /Users/rpatterson/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/rpatterson/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from <rails-root>/bin/spring:15:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'
于 2017-04-04T02:11:11.447 回答
1

我似乎有同样的问题。

我发现了这个,这可能是相关的——尝试部署时积极支持的困难——我已经尝试过了,但它对我没有用。就我而言,1.8 gems/tools 与 1.9 混合在一起,所以我做了更认真的清理工作。

which -a ruby通过运行andwhich -a rake和来检查您是否有多个 ruby​​ 安装which -a rails。整理好东西,这样您就可以使用单个 ruby​​/bundler/rails 组合。我已经完全删除了 ruby​​ 1.8 并且在我的系统上只留下了 1.9 ruby​​。然后我清理了系统中的所有 gem,然后重新运行 bundler。我仍然缺少一些东西,因为 rake 和 rails 继续抱怨 bigdecimal/util

于 2013-05-30T21:58:44.127 回答