ruby find_spec_for_exe': 找不到 gem bundler (>= 0.a) (Gem::GemNotFoundException)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47026174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:53:33  来源:igfitidea点击:

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

rubyrubygemsbundlejekyll

提问by Alvaro

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

我用过sudo bundle install,这可能是问题的原因?

Now I have:

我现在有:

  • gem -v2.6.14
  • ruby -vruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin15]
  • jekyll -vjekyll 3.6.2
  • bundle -vBundler version 1.16.0.pre.3
  • gem -v2.6.14
  • ruby -v红宝石 2.3.5p376(2017-09-14 修订版 59905)[x86_64-darwin15]
  • jekyll -v杰基尔 3.6.2
  • bundle -v捆绑程序版本 1.16.0.pre.3

I'm getting the following error when trying to run bundle exec jekyll serveor just jekyll serve

尝试运行bundle exec jekyll serve或只是运行时出现以下错误jekyll serve

/Users/myusername/.rvm/rubies/ruby-2.3.5/lib/ruby/site_ruby/2.3.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
    from /Users/myusername/.rvm/rubies/ruby-2.3.5/lib/ruby/site_ruby/2.3.0/rubygems.rb:299:in `activate_bin_path'
    from /Users/myusername/.rvm/gems/ruby-2.3.5/bin/bundle:23:in `<main>'
    from /Users/myusername/.rvm/gems/ruby-2.3.5/bin/ruby_executable_hooks:15:in `eval'
    from /Users/myusername/.rvm/gems/ruby-2.3.5/bin/ruby_executable_hooks:15:in `<MacBooMacBook-MacBook-MacBook-Pro-MacBook-PrMacBook-MacBooMacBMaMacBMaMaMaMaMaMaMaMaMacBMaMaMaMacBMa

Also, when accessing the folder in which I have my blog cd my_pathI get the following message:

此外,当访问我的博客所在的文件夹时,cd my_path我收到以下消息:

VM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too, you can ignore these warnings with 'rvm rvmrc warning ignore /Library/WebServer/Documents/blog/Gemfile'. To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'. Unknown ruby interpreter version (do not know how to handle): RUBY_VERSION.

VM 使用您的 Gemfile 来选择 Ruby,这一切都很好 - Heroku 也这样做,您可以使用 'rvm rvmrc warning ignore /Library/WebServer/Documents/blog/Gemfile' 忽略这些警告。要忽略所有文件的警告,请运行“rvm rvmrc warning ignore allGemfiles”。未知的 ruby​​ 解释器版本(不知道如何处理):RUBY_VERSION。

I've no idea how to solve this. I just want to create my static blog and honestly I have no idea about Ruby, Gem or Bundle :) So I would appreciate some insights!

我不知道如何解决这个问题。我只是想创建我的静态博客,老实说我不知道​​ Ruby、Gem 或 Bundle :) 所以我希望得到一些见解!

回答by Antonio Tapiador

The problem in my case is that the Gemfile.lockfile had a BUNDLED_WITHversion of 1.16.1and gem install bundlerinstalled version 2.0.1, so there was a version mismatch when looking to right the folder

我的问题是该Gemfile.lock文件的BUNDLED_WITH版本1.16.1gem install bundler安装版本2.0.1,因此在查找正确的文件夹时存在版本不匹配

gem install bundler -v 1.16.1fixed it

gem install bundler -v 1.16.1修复

Of course, you can also change your Gemfile.lock's BUNDLED_WITHwith last bundlerversion and use recent software, as Sam3000suggests

当然,你也可以改变你Gemfile.lockBUNDLED_WITH与去年bundler的版本,并使用最新版本的软件,如Sam3000建议

回答by antonpaisov

gem update --system

will update the rubygems and will fix the problem.

将更新 ruby​​gems 并解决问题。

回答by Nik Kov

Update:

更新:

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

根据@noraj 的回答和@Niels Kristian 的评论,以下命令应该可以完成这项工作。

gem update --system
bundle install


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

我写这个以防有人遇到像我这样的问题。

gem install bundlershows that everythings installs well.

gem install bundler表明一切都安装得很好。

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 bundlethere was an error:

当我输入时bundle出现错误:

/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.0folder.

在文件夹/Users/nikkov/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/中没有bundler-1.16.0文件夹。

I fixedthis with sudo gem install bundler

固定这与sudo gem install bundler

回答by noraj

The real answer is here if you try to install bundler 2.0.1 or 2.0.0 due to Bundler requiring RubyGems v3.0.0

如果您因为 Bundler 需要 RubyGems v3.0.0 而尝试安装 bundler 2.0.1 或 2.0.0,那么真正的答案就在这里

Yesterday I released Bundler 2.0 that introduced a number of breaking changes. One of the those changes was setting Bundler to require RubyGems v3.0.0. After making the release, it has become clear that lots of our users are running into issues with Bundler 2 requiring a really new version of RubyGems.

We have been listening closely to feedback from users and have decided to relax the RubyGems requirement to v2.5.0 at minimum. We have released a new Bundler version, v2.0.1, that adjusts this requirement.

昨天我发布了 Bundler 2.0,其中引入了许多重大更改。其中一项更改是将 Bundler 设置为需要 RubyGems v3.0.0。在发布之后,很明显我们的许多用户都遇到了 Bundler 2 的问题,需要一个真正新版本的 RubyGems。

我们一直在密切听取用户的反馈意见,并决定将 RubyGems 要求至少放宽到 v2.5.0。我们发布了一个新的 Bundler 版本 v2.0.1 来调整这个要求。

For more info, see: https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html

有关更多信息,请参阅:https: //bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html

回答by Klonept

This fixed it:

这修复了它:

  1. Remove Gemfile.lock rm Gemfile.lock
  2. run bundle installagain
  1. 删除 Gemfile.lock rm Gemfile.lock
  2. bundle install再次运行

EDIT: DON'T DO IT IN PRODUCTION!

编辑:不要在生产中这样做!

For production go to this answer: https://stackoverflow.com/posts/54083113/revisions

对于生产去这个答案:https: //stackoverflow.com/posts/54083113/revisions

回答by Mathew P. Jones

The reason is your current ruby environment, you got a different version of bundler with the version in Gemfile.lock.

原因是您当前的 ruby​​ 环境,您有一个不同版本的 bundler 与Gemfile.lock.

  • Safe way, install bundler with the same version in Gemfile.lock, this won't break anything if there is some incampatibly thing happened.
  • Hard way, just remove Gemfile.lock, and run bundle install.
  • 安全的方法,在Gemfile.lock.
  • 很难,只需删除Gemfile.lock,然后运行bundle install

回答by Wawa Loo

If you changed the ruby version you're using with rvm use, remove Gemfile.lock and try again.

如果您更改了正在使用的 ruby​​ 版本rvm use,请删除 Gemfile.lock 并重试。

回答by Georg Keferb?ck

Open Gemfile.lock, which is to be found in the root of your app folder. Scroll to the end of the file and see the bundler version used. Then you make sure you install the bundler version used:

打开 Gemfile.lock,它位于您的应用程序文件夹的根目录中。滚动到文件末尾并查看使用的捆绑程序版本。然后确保安装使用的捆绑程序版本:

gem install bundler -v x.xx.xx

Or - delete the Gemfile.lock and bundle if you have higher bundler version installed.

或者 - 如果您安装了更高版本的 bundler,请删除 Gemfile.lock 和 bundle。

The choice is yours, my friend.

选择权在你,我的朋友。

回答by Naser Mirzaei

to install bundler that matches with your Gemfile.lockuse:

安装与您的Gemfile.lock使用相匹配的捆绑器:

gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

回答by Rahul Dess

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

就我而言,上述建议对我不起作用。我的情况略有不同。

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

当我尝试bundler使用gem install bundler..安装时,但我得到了

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 bundlerthen i was getting

然后我尝试使用sudo gem install bundler然后我得到

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/bindint work in my case ).

然后我尝试了sudo gem install bundler -n /usr/local/bin/usr/bin在我的情况下只是工作)。

And then successfully installed bundler

然后安装成功 bundler

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

编辑:我使用 MacOS,因此可能/usr/bin对我不起作用(https://stackoverflow.com/a/34989655/3786657评论)