我使用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:)所以我很感激一些见解!


当前回答

我必须用力耙干净。然后做了宝石安装耙子等等。

其他回答

我在运行bin/dev时得到这个错误

bin/dev
/Users/st/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0/rubygems.rb:265:in `find_spec_for_exe': can't find gem foreman (>= 0.a) with executable foreman (Gem::GemNotFoundException)
    from /Users/st/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0/rubygems.rb:284:in `activate_bin_path'
    from /Users/st/.rbenv/versions/3.0.3/bin/foreman:25:in `<main>'

我尝试了很多方法,但解决问题的方法很简单:

gem install foreman

现在bin/dev又可以正常工作了。

真正的答案在这里,如果你试图安装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

在我的情况下,上述建议对我不起作用。我的情况有点不同。

当我尝试使用gem安装bundle安装bundle ..但我正在

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

然后我尝试使用sudo宝石安装捆绑器,然后我得到

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

然后我尝试用sudo gem安装捆绑器-n /usr/local/bin(只是/usr/bin力在我的情况下工作)。

然后成功安装了捆扎机

编辑:我使用MacOS,也许/usr/bin不适合我的原因(https://stackoverflow.com/a/34989655/3786657评论)

如果您更改了使用rvm使用的ruby版本,请删除Gemfile。锁定后再试一次。

这就解决了问题:

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

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

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