1

我添加了 gem 'pry-rails',当我运行 rails 控制台时,我收到以下错误:

Loading development environment (Rails 3.2.6)
/Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/dsl.rb:35:in `eval_gemfile': Gemfile syntax error: (Bundler::GemfileError)
/Users/rege/Code/Network/Gemfile:106: syntax error, unexpected ':', expecting $end
gem 'ruby-readability', require: 'readability'
                                ^
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/dsl.rb:7:in `evaluate'
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/definition.rb:18:in `build'
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler.rb:144:in `definition'
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler.rb:112:in `setup'
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/setup.rb:17

Frame number: 0/4
>> RUBY_VERSION
"1.9.3"

我的宝石文件:

...
group :development do
  gem 'rack-mini-profiler'
  gem 'pry-rails'
end
...
gem 'ruby-readability', require: 'readability'
...

当我更改为时gem 'ruby-readability', require: 'readability'gem 'ruby-readability', :require => 'readability'我收到下一个错误:

Loading development environment (Rails 3.2.6)
/Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/definition.rb:364:in `validate_ruby!': Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler.rb:112:in `setup'
    from /Users/rege/.rvm/gems/ruby-1.9.3-p194@network/gems/bundler-1.2.0/lib/bundler/setup.rb:17

我的 rvm 信息

> rvm info                                                                                                                                                     /Users/rege/Code/Network 1.9.3p194 develop!@37a80c4

ruby-1.9.3-p194@network:

  system:
    uname:       "Darwin Darek-MacBook.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
    zsh:         "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"

  rvm:
    version:      "rvm 1.15.8 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "19 hours 59 minutes 37 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p194"
    date:         "2012-04-20"
    platform:     "x86_64-darwin11.4.0"
    patchlevel:   "2012-04-20 revision 35410"
    full_version: "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]"

  homes:
    gem:          "/Users/rege/.rvm/gems/ruby-1.9.3-p194@network"
    ruby:         "/Users/rege/.rvm/rubies/ruby-1.9.3-p194"

  binaries:
    ruby:         "/Users/rege/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
    irb:          "/Users/rege/.rvm/rubies/ruby-1.9.3-p194/bin/irb"
    gem:          "/Users/rege/.rvm/rubies/ruby-1.9.3-p194/bin/gem"
    rake:         "/Users/rege/.rvm/gems/ruby-1.9.3-p194@global/bin/rake"

  environment:
    PATH:         "/Users/rege/.rvm/gems/ruby-1.9.3-p194@network/bin:/Users/rege/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/rege/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/rege/.rvm/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
    GEM_HOME:     "/Users/rege/.rvm/gems/ruby-1.9.3-p194@network"
    GEM_PATH:     "/Users/rege/.rvm/gems/ruby-1.9.3-p194@network:/Users/rege/.rvm/gems/ruby-1.9.3-p194@global"
    MY_RUBY_HOME: "/Users/rege/.rvm/rubies/ruby-1.9.3-p194"
    IRBRC:        "/Users/rege/.rvm/rubies/ruby-1.9.3-p194/.irbrc"
    RUBYOPT:      ""
    gemset:       "network"
4

3 回答 3

0

根据文档,您应该指定如下

 gem "ruby-readability", :require => 'readability'

您在第二种方法中已经完成了。您收到此错误

 Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3

因为从 Bundler 1.2 你有这个非常有用的新特性validate your Ruby version所以如果你想使用 ruby​​ 1.8.7 在你的 Gemfile 顶部指定

ruby '1.8.7'
于 2012-09-09T17:28:41.960 回答
0

问题是因为我在我的pryrc:require 'pry-vterm_aliases'从我的pryrc问题中删除后解决了

于 2012-09-10T11:37:13.010 回答
0

你的环境怎么rvm info说?怎么样ruby -v?最后,which ruby? 我怀疑你没有运行正确的红宝石,也许你的路上还有另一个。

于 2012-09-09T14:21:40.643 回答