find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)

后端 未结 15 1231
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 17:14

I used sudo bundle install and that might be the cause of the issue?

Now I have:

  • gem -v 2.6.14
  • ruby -v
相关标签:
15条回答
  • 2020-11-29 17:49

    Adding to the many answers, my problem stemmed from wanting to use the docker's ruby as a base, but then using rbenv on top. This screws up a lot of things.

    I fixed it in this case by:

    • The Gemfile.lock version did need updating - changing the "BUNDLED WITH" to the latest version did at one point change the error message, so may have been required
    • in .bash_profile or .bashrc, unsetting the environment variables:
    unset GEM_HOME
    unset BUNDLE_PATH
    

    After that, rbenv worked fine. Not sure how those env vars were getting loaded in the first place...

    0 讨论(0)
  • 2020-11-29 17:49

    I downgraded ruby from 2.5.x to 2.4.x in my particular case.

    0 讨论(0)
  • 2020-11-29 17:51

    I had to do rake clean --force. Then did gem install rake and so forth.

    0 讨论(0)
  • 2020-11-29 17:54

    Update:

    According @noraj's answer and @Niels Kristian's comment, the following command should do the job.

    gem update --system
    bundle install
    

    I wrote this in case someone gets into an issue like mine.

    gem install bundler shows that everythings installs well.

    Fetching: bundler-1.16.0.gem (100%)
    Successfully installed bundler-1.16.0
    Parsing documentation for bundler-1.16.0
    Installing ri documentation for bundler-1.16.0
    Done installing documentation for bundler after 7 seconds
    1 gem installed
    

    When I typed bundle there was an error:

    /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/bundle:23:in `load': cannot load such file -- /Users/nikkov/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/exe/bundle (LoadError)
        from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/bundle:23:in `<main>'
        from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
        from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
    

    And in the folder /Users/nikkov/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/ there wasn't a bundler-1.16.0 folder.

    I fixed this with sudo gem install bundler

    0 讨论(0)
  • 2020-11-29 17:54

    In my case the above suggestions did not work for me. Mine was little different scenario.

    When i tried installing bundler using gem install bundler .. But i was getting

    ERROR:  While executing gem ... (Gem::FilePermissionError)
        You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
    

    then i tried using sudo gem install bundler then i was getting

    ERROR:  While executing gem ... (Gem::FilePermissionError)
      You don't have write permissions for the /usr/bin directory.
    

    then i tried with sudo gem install bundler -n /usr/local/bin ( Just /usr/bin dint work in my case ).

    And then successfully installed bundler

    EDIT: I use MacOS, maybe /usr/bin din't work for me for that reason (https://stackoverflow.com/a/34989655/3786657 comment )

    0 讨论(0)
  • 2020-11-29 17:54

    I had the same issue today. I solve this problem by removing any PATH in .bashrc for older rvm.

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