`require':无法加载这样的文件 - rack-webconsole(LoadError)

时间:2014-11-11 03:28:35

标签: ruby-on-rails ruby-on-rails-3 bundler

我刚刚升级到Yosemite,我在这台本地计算机上运行了一个Rails 3.2.18应用程序。它运行正常(例如rails s工作,rails c工作等等)但是在清理rvm并重新捆绑后,我在运行rails crails s时遇到此错误:

/Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:76:in `require': cannot load such file -- rack-webconsole (LoadError)
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:72:in `each'
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:61:in `each'
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:61:in `require'
    from /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:132:in `require'
    from /Users/cweilemann/Projects/railsapp/config/application.rb:7:in `<top (required)>'

config / application.rb的第7行是:

Bundler.require(*Rails.groups(:assets => %w(development test)))

在我的Gemfile中,我有:

group :development do
  ...
  gem 'rack-webconsole-pry', :require => 'rack-webconsole'
  ...
end

如果我将gem 'rack-webconsole-pry', :require => 'rack-webconsole'行移到group :development之外,则应用加载就好了。如果我删除了:require => 'rack-webconsole',该应用就可以正常加载。

这是捆绑问题吗?或者是Rails和优胜美地的问题?

更新

gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin12.0]
  - INSTALLATION DIRECTORY: /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp
  - RUBY EXECUTABLE: /Users/cweilemann/.rvm/rubies/ruby-2.1.1/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp/bin
  - SPEC CACHE DIRECTORY: /Users/cweilemann/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp
     - /Users/cweilemann/.rvm/gems/ruby-2.1.1@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp/bin
     - /Users/cweilemann/.rvm/gems/ruby-2.1.1@global/bin
     - /Users/cweilemann/.rvm/rubies/ruby-2.1.1/bin
     - /Users/cweilemann/.rvm/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin

当我这样做时:bundle env

我明白了:

Bundler 1.6.1
Ruby 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin12.0]
Rubygems 2.2.2
rvm 1.26.0 (latest)
GEM_HOME /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp
GEM_PATH /Users/cweilemann/.rvm/gems/ruby-2.1.1@railsapp:/Users/cweilemann/.rvm/gems/ruby-2.1.1@global
rubygems-bundler (1.4.3)

Bundler settings
  without
    Set for your local app (/Users/cweilemann/Projects/railsapp/.bundle/config): "test:development"


Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.18'
gem 'rubyzip', '~>0.9.9'
gem 'pg'

...
...

group :development do
  gem "quiet_assets", ">= 1.0.1"
  gem "better_errors", ">= 0.3.2"
  gem "binding_of_caller", "~> 0.7.2"
  gem 'annotate' #puts comments in models/tests with db fields for a given domain
  gem 'debugger', "~> 1.6.6"
  gem 'rack-webconsole-pry', :require => 'rack-webconsole' #default activated by backtick.  may need rake patch task from this project's /lib/tasks
  gem 'foreman' #support to start multiple processes at once (server, resque workers, etc.)
  gem 'rails-erd' #generate ERD for domains. may require separate graphviz binary installation.
  #functional, but not commonly used
end

group :test, :development do
  gem 'rspec-rails', '~> 2.0'
  gem 'poltergeist'                         # See https://github.com/jonleighton/poltergeist for how to install phantomjs
  gem 'capybara'
  gem 'launchy'
  gem "api_matchers"
  gem "shoulda-matchers", ">= 2.6.2", require: false
  gem 'machinist', '~> 2.0'
  gem "guard", "~> 1.6.2"
  gem "spork", "~> 0.9.2"
  gem "guard-rspec", "~> 2.5.1"
  gem "guard-spork", "~> 1.4.0"
  gem 'rb-fsevent', "~> 0.9.4"
  gem 'rb-readline', "~> 0.5.1"
  gem "simplecov", "~> 0.7.1", :require => false
  gem 'puma'
  gem 'sql_queries_count'
end


Gemfile.lock

GIT
  remote: https://github.com/jwhitley/requirejs-rails.git
  revision: f2330104aeca4d193fd5680a22ae7eee85d814b5
  specs:
    requirejs-rails (0.9.1)
      railties (>= 3.1.1, < 4.1)

GEM
  remote: https://rubygems.org/
  specs:

    ...
    ...

    rack-webconsole-pry (0.1.9)
      json
      multi_json (>= 1.0.3)
      pry
      rack
    rails (3.2.18)
      actionmailer (= 3.2.18)
      actionpack (= 3.2.18)
      activerecord (= 3.2.18)
      activeresource (= 3.2.18)
      activesupport (= 3.2.18)
      bundler (~> 1.0)
      railties (= 3.2.18)
    ...
    ...


PLATFORMS
  ruby

DEPENDENCIES
  ...
  ...

  rack-webconsole-pry
  rails (= 3.2.18)
  ...

注意:我出于安全目的编辑了bundle env列表,因为这是一个生产应用程序。

当我这样做时:bundle show --paths rack-webconsole-pry

我明白了:

Could not find gem 'rack-webconsole-pry'.
Did you mean rack-webconsole-pry?

2 个答案:

答案 0 :(得分:2)

bundle env的输出结果显示:

Bundler settings
  without
    Set for your local app (/Users/cweilemann/Projects/railsapp/.bundle/config): "test:development"

这意味着bundle install将跳过在development群组中安装任何内容(以及test)。

.bundle/config文件中删除该行并再次运行bundle install,它应该开始工作。

答案 1 :(得分:0)

这似乎与rack-webconsole-pry存在问题。

这是Gemfile:

source "https://rubygems.org"

group :development do
  gem 'rack-webconsole-pry', :require => 'rack-webconsole'
end

这里将这些宝石安装到没有宝石的Rubygems系统宝石中,一切正常:

$ bundle install --system
Using coderay 1.1.0
Using multi_json 1.10.1
Using method_source 0.8.2
Using json 1.8.1
Using rack 1.5.2
Using bundler 1.7.5
Using slop 3.6.0
Using pry 0.10.1
Using rack-webconsole-pry 0.1.9
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
$ bundle check
The Gemfile's dependencies are satisfied
$ bundle exec bundle check
The Gemfile's dependencies are satisfied

在这里,我将这些宝石安装到路径而不是系统宝石中,一切都破坏了:

$ bundle install --path gems
Fetching gem metadata from https://rubygems.org/..........
Using bundler 1.7.5
Installing method_source 0.8.2
Installing slop 3.6.0
Installing coderay 1.1.0
Installing rack 1.5.2
Installing multi_json 1.10.1
Installing pry 0.10.1
Installing json 1.8.1
Installing rack-webconsole-pry 0.1.9
Your bundle is complete!
It was installed into ./gems

$ bundle check
The Gemfile's dependencies are satisfied

$ bundle exec bundle check
Could not find coderay-1.1.0 in any of the sources
Run `bundle install` to install missing gems.

当它被加载时,rack-webconsole-pry以某种方式做了一些破坏宝石加载方式的东西,这使得之后无法加载宝石。当你将它移出开发组时,它并不是必需的,所以一切都很好。当你把它放在开发组中时,它会被加载,但是会破坏加载gem的方式,然后它就再也找不到实际安装的gems来加载它们了。