1

我无法弄清楚为什么 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 
4

2 回答 2

2

通过将以下内容放入您的 Gemfile 中,尝试使用来自 git 的最新版本的 gem:

gem 'acts_as_list', :git => 'git://github.com/swanandp/acts_as_list.git'

然后又跑bundle update acts_as_list了。

另请注意,acts_as_list 已经有一段时间没有更新了,所以如果它没有按预期工作,请不要感到惊讶。

于 2011-03-09T00:45:02.417 回答
0

如果您使用的是 bundler、rvm 和 rails 我会建议什么

  • 检查您是否正在使用所需的 ruby​​ 版本(ruby -v)
  • 不要使用 sudo 安装 gem
  • 配置您的 Gemfile 以访问 git 存储库(除非您在生产中并使用乘客)
  • 如果最后一个选项不起作用,您可以删除所有您拥有的acts_as_list,将其克隆到您的vendors/gems目录并将其加载到您的Gemfile中,无需git存储库
  • 从 Gemfile 中删除它,将其克隆到 vendor/plugin 目录中。(这就是我现在使用它的方式)

现在,我建议使用这个版本https://github.com/swanandp/acts_as_list

我没有维护我的叉子,因为它在我的应用程序中工作。我做了很多错误修复,但从未合并到 rails 维护的版本。我的拉取请求被rails repo 的所有者简单地忽略了

于 2011-03-09T08:08:06.000 回答