ruby - Jekyll 服务错误:找不到 gem jekyll (>= 0.a) (Gem::GemNotFoundException

标签 ruby rubygems jekyll rvm bundler

在执行 sudo jekyll serve 时出现以下错误:

Users/myusername/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in 'find_spec_for_exe': can't find gem jekyll (>= 0.a) (Gem::GemNotFoundException)
from /Users/myusername/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in 'activate_bin_path'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/jekyll:23:in '<main>'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in 'eval'
from /Users/myusername/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in '<main>'

如果有帮助:

  • jekyll -v 返回 jekyll 3.6.2
  • ruby -v 返回 ruby 2.4.2p198(2017-09-14 修订版 59899)[x86_64-darwin15]
  • gem -v 返回 2.6.14
  • bundle -v 返回 Bundler version 1.16.0

在我的 Gem 文件中我有:

ruby '2.4.2'

rmv 列表 输出:

ruby-2.3.5 [ x86_64 ]
=* ruby-2.4.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

最佳答案

我终于解决了这个问题:

sudo rm -rf _site
bundle update
bundle exec jekyll serve

然后始终使用 bundle exec jekyll serve 而不是 sudo jekyll servejekyll serve

多亏了答案 in this post,我得到了这个解决方案.

关于ruby - Jekyll 服务错误:找不到 gem jekyll (>= 0.a) (Gem::GemNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47046746/

相关文章:

ruby-on-rails - Rails 验证包含错误 'not included in list'

ruby - 我应该如何处理 APP_KEY 和 APP_SECRET(Dropbox API)

ruby-on-rails - 如果不是零则添加?

ruby-on-rails - Ruby on Rails 配置 - Plaid Gem

css - 是否可以在 Jekyll 中使用纯 CSS 而不是 SASS

css - 我是否需要从 Pygments 为我的 jekyll 博客生成一个 css 文件,以启用彩色代码片段?

ruby-on-rails - 带复选框的 Rails 表单

ruby-on-rails - Rails new 给出 "Could not find proper version of railties (4.2.5.1) in any of the sources"错误

ruby-on-rails - 如何重定向回我当前所在的页面?

css - 使用 jekyll、kramdown 和 rouge 防止代码块换行