我使用sudo捆绑安装,这可能是问题的原因?

现在我有:

Gem -v 2.6.14 Ruby -v Ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin15] Jekyll -v Jekyll 3.6.2 vbundler版本为1.16.0.pre.3

我得到以下错误时,试图运行捆绑执行jekyll服务或只是jekyll服务

/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

同样,当访问我的博客cd my_path所在的文件夹时,我得到以下消息:

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

我不知道该怎么解决。我只是想创建我的静态博客,老实说,我不知道Ruby, Gem或Bundle:)所以我很感激一些见解!


当前回答

我今天也遇到了同样的问题。我通过删除旧rvm. bashrc中的任何PATH来解决这个问题。

其他回答

Gemfile开放。锁定,这是在你的应用程序文件夹的根目录。滚动到文件的末尾,查看使用的绑定器版本。然后确保你安装了使用的捆绑包版本:

gem install bundler -v x.xx.xx

或者-删除Gemfile。锁定和捆绑,如果你有更高的捆绑版本安装。

选择在你,我的朋友。

真正的答案在这里,如果你试图安装bundler 2.0.1或2.0.0,因为bundler需要RubyGems v3.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.

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

安装与您的Gemfile匹配的捆绑器。锁的使用:

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

我把红宝石等级从2.5降到了2.5。X到2.4。X在我的特殊情况下。

这就解决了问题:

删除Gemfile。lock rm Gemfile.lock 重新运行bundle install

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

对于生产,请参考以下答案: https://stackoverflow.com/posts/54083113/revisions