【问题标题】:bundler version exists, but RubyGems claims otherwise捆绑器版本存在,但 RubyGems 另有声明
【发布时间】:2021-11-30 21:51:16
【问题描述】:

当我运行rails generate migration 时,我得到:

/Users/bob/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems.rb:277:in 'find_spec_for_exe': Could not find 'bundler' (2.2.21) required by your /Users/bob/path/to/my/project/Gemfile.lock. (Gem::GemNotFoundException)

...后跟:

To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.21`

但是,bundler 显然存在:

$ gem list bundler

*** LOCAL GEMS ***

bundler (2.2.21)

$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin19]

$ find ~/.rbenv -name "*bundler*" | grep 2.7.4 | grep gemspec

/Users/bob/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/specifications/bundler-2.2.21.gemspec
/Users/bob/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.2.21/bundler.gemspec

我追查到line 267 in rubygems.rb

specs = dep.matching_specs(true)

(它返回一个空数组,我相信它表明它找不到匹配的规范。)

注意:我按照上述说明/建议(运行 bundle update --bundlergem install bundler:2.2.21)无济于事。

【问题讨论】:

    标签: rubygems bundler


    【解决方案1】:

    这最终对我有用:

    rbenv uninstall 2.7.4
    
    rbenv install 2.7.4
    
    bundle
    
    git restore Gemfile.lock   # there were some insignificant rearrangments
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-26
      • 2019-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      相关资源
      最近更新 更多