Bundler: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) during bundle install with gem

前端 未结 9 1972
再見小時候
再見小時候 2020-12-13 05:35

I\'m executing the following script:

gem install rdoc --no-document
gem install bundle
bundle

output:

+ gem install rdoc --         


        
相关标签:
9条回答
  • 2020-12-13 05:52

    Bundler version 2 introduced a new feature to automatically use the version of Bundler specified in the Gemfile.lock of your project. Thus, if you have an existing Gemfile.lock with a line like this at the bottom

    BUNDLED WITH
       1.17.3
    

    Bundler will try to run with a Bundler version < 2.0. Since you just have Bundler 2.0.1 (and Rubygems >= 2.7.0) installed, this fails with this rather unhelpful error message.

    To fix this, you could

    • remove the lines from your Gemfile.lock and to use bundler 2.x everywhere from now on, or
    • install a bundler 1.x version with gem install bundler -v '< 2.0' to use the appropriate version as specified by your Gemfile.lock.

    More information about this can be found on the Bundler blog.

    0 讨论(0)
  • 2020-12-13 05:54

    I just faced the same error today. The bundler version which I had installed in my system previously was: 1.16.6

    Followed the instructions in the official bundler docs on How to Upgrade to Bundler 2 and the below two steps did the trick:

    1. gem install bundler (Helps you get the latest version of bundler which as of today is 2.0.2)
    2. bundle update --bundler
    0 讨论(0)
  • 2020-12-13 05:58

    I couldn’t even do bundle -v. This sorted it out:

    gem update --system
    

    Got the info from here (similar problem): find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)

    Probably some version mismatch between ruby + gem + bundler

    0 讨论(0)
  • 2020-12-13 06:01

    As per the description mentioned in the post , before running the below mentioned command:

    bundle install
    

    in the script, you need to run the below command:

    gem install bundler
    

    So, the sequence of commands to work would be:

    gem install bundler
    bundle install
    

    Update the bundler command if if does not work to:

     gem install bundler -v '1.17.3'
    

    Reason for the break in functionalities in bundler 2.0 is given in below mentioned link:

    https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html

    0 讨论(0)
  • 2020-12-13 06:01

    You've to install the exact version of Bundler that RubyGems is looking for by running:

    $ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
    
    0 讨论(0)
  • 2020-12-13 06:06

    I had the same problem recently. In my case I have installed a version on bundler different from what is logged in the Gemfile.lock. Please check

    0 讨论(0)
提交回复
热议问题