I cannot figure out why rails/ruby cannot see this gem, despite each telling me that the gem is visible. I compiled this gem locally from a github branch since the main version seems to be broken in Rails 3. Or perhaps I am missing something else entirely.
Ovid:lightserve dlipa$ gem list
*** LOCAL GEMS ***
..
acts_as_list (0.2.1)
..
And
Ovid:lightserve dlipa$ cat Gemfile
...
gem "acts_as_list", "0.2.1"
...
And
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
But
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 >
And
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 >
Can anyone explain why this might be happening? I'd really appreciate it!
** UPDATE -- Response to Andrew Marshall's suggestion**
I changed Gemfile to read the gem directly from git, but it did not resolve the problem. Does this mean that there is a problem with this gem? The error message is not very helpful ;-)
Removed:
Ovid:lightserve dlipa$ bundle show acts_as_list
Could not find gem 'acts_as_list' in the current bundle.
Then added back via:
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
...
Same problem even though bundle show matches the commit on that page:
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-..
I just looked in the gem and it appears there is no file called 'acts_as_list' in the gem. So it appears to be idiosyncratic, albeit poorly reported by Rails/Ruby.
The API appears to have changed to:
ruby-1.9.2-p180 :003 > require 'active_record/acts/list'
=> nil
ruby-1.9.2-p180 :004 > ActiveRecord::Acts::List
=> ActiveRecord::Acts::List
Try using the latest version of the gem from git by putting the following in your Gemfile:
gem 'acts_as_list', :git => 'git://github.com/swanandp/acts_as_list.git'
Then running bundle update acts_as_list
again.
Also note that acts_as_list hasn't been updated in quite some time, so don't be surprised if it doesn't work as expected.
if you are using bundler, rvm and rails what i would suggest
- check if you are using the ruby version that you want (ruby -v)
- don't use sudo to install the gem
- configure your Gemfile to get access the git repository (unless you are in production and using passenger)
- if the last option didn't work, you can erase all acts_as_list that you have, clone it to your vendors/gems directory and load it in your Gemfile, without the git repository
- remove it from Gemfile, clone it in the vendors/plugin directory. (it is how i'm using it now)
For now, i would recommend to use this version https://github.com/swanandp/acts_as_list.
I didnt maintain my fork, because it was working in my application. I did a lot of bug fixes , but it was never merged to the rails maintained version. My Pull request was simply IGNORED by the owner of the rails repo
精彩评论