我无法弄清楚为什么 rails/ruby 看不到这颗宝石,尽管每个人都告诉我宝石是可见的。我从 github 分支本地编译了这个 gem,因为主要版本似乎在 Rails 3 中被破坏了。或者我可能完全错过了其他东西。
Ovid:lightserve dlipa$ gem list
*** LOCAL GEMS ***
..
acts_as_list (0.2.1)
..
和
Ovid:lightserve dlipa$ cat Gemfile
...
gem "acts_as_list", "0.2.1"
...
和
Ovid:lightserve dlipa$ bundle install
...
Using acts_as_list (0.2.1)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed
但
Ovid:lightserve dlipa$ r c
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.1
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.6.0]
- INSTALLATION DIRECTORY: /Users/dlipa/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/dlipa/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/dlipa/.rvm/gems/ruby-1.9.2-p180
- /Users/dlipa/.rvm/gems/ruby-1.9.2-p180@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gems.github.com
Loading development environment (Rails 3.0.5)
ruby-1.9.2-p180 :001 > require 'acts_as_list'
LoadError: no such file to load -- acts_as_list
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `block in require'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
from (irb):1
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands/console.rb:44:in `start'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands/console.rb:8:in `start'
from /Users/dlipa/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby-1.9.2-p180 :002 >
和
Ovid:lightserve dlipa$ irb
ruby-1.9.2-p180 :001 > require 'acts_as_list'
LoadError: no such file to load -- acts_as_list
from /Users/dlipa/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/dlipa/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /Users/dlipa/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
ruby-1.9.2-p180 :002 >
谁能解释为什么会发生这种情况?我真的很感激!
**更新——对 Andrew Marshall 建议的回应**
我将 Gemfile 更改为直接从 git 读取 gem,但并没有解决问题。这是否意味着这个宝石有问题?错误消息不是很有帮助;-)
删除:
Ovid:lightserve dlipa$ bundle show acts_as_list
Could not find gem 'acts_as_list' in the current bundle.
然后通过以下方式添加回来:
gem "acts_as_list", :git => "git://github.com/vpereira/acts_as_list.git"
Ovid:lightserve dlipa$ bundle install
Updating git://github.com/vpereira/acts_as_list.git
...
即使 bundle show 与该页面上的提交匹配,同样的问题:
Ovid:lightserve dlipa$ bundle show acts_as_list
/Users/dlipa/.rvm/gems/ruby-1.9.2-p180/bundler/gems/acts_as_list-4cb76a8b198c
Ovid:lightserve dlipa$ irb
ruby-1.9.2-p180 :001 > require 'acts_as_list'
LoadError: no such file to load -- acts_as_list
from /Users/dlipa/.rvm/rubies/ruby-1.9.2-..
我刚刚查看了 gem,似乎 gem 中没有名为“acts_as_list”的文件。所以它似乎是特殊的,尽管 Rails/Ruby 的报告很差。
API 似乎已更改为:
ruby-1.9.2-p180 :003 > require 'active_record/acts/list'
=> nil
ruby-1.9.2-p180 :004 > ActiveRecord::Acts::List
=> ActiveRecord::Acts::List