我尝试更新 Jekyll,现在遇到了问题。幸运的是,我仍然可以使用 构建我的网站bundle exec jekyll serve
,但运行时jekyll serve
我得到以下信息:
Traceback (most recent call last):
10: from /Users/jon.graft/.rbenv/versions/2.6.3/bin/jekyll:23:in `<main>'
9: from /Users/jon.graft/.rbenv/versions/2.6.3/bin/jekyll:23:in `load'
8: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/exe/jekyll:11:in `<top (required)>'
7: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/jekyll-4.0.0/lib/jekyll/plugin_manager.rb:52:in `require_from_bundler'
6: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler.rb:107:in `setup'
5: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:26:in `setup'
4: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:26:in `map'
3: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/spec_set.rb:148:in `each'
2: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/spec_set.rb:148:in `each'
1: from /Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:31:in `block in setup'
/Users/jon.graft/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:319:in `check_for_activated_spec!': You have already activated i18n 1.6.0, but your Gemfile requires i18n 0.9.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
哪里出了问题?我该如何修复?我越来越多地使用 Jekyll,所以我想了解为什么会发生这种情况,以便在再次发生时我可以修复/避免它。
答案1
您的 Gemfile 需要 0.95 版本的软件包i18n
,但您已经安装了 版本1.6.0
。这就是为什么您需要在命令前面加上bundle exec
,这样 bundle 才能完成其工作并将正确版本的软件包转发给 Jekyll。这是正常的,无需担心。我建议编写一个脚本来让 Jekyll 服务或构建,这样您就不必输入这么多。例如,我的serve.sh
,它甚至为本地服务使用了不同的配置:
bundler exec jekyll serve --config config.dev.yml --host 10.10.10.1 --incremental
或者,您可以编辑Gemfile.lock
并尝试将版本更改i18n
为 1.6.0。我刚刚尝试过,效果很好,但是安装后的消息可能与之相关:
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
因此,如果您使用 Jekyll 来做多语言网站,如果出现错误或不寻常的错误,请务必记住这一点。