0

我刚刚开始将 Jekyll 与 GitHub Pages 一起使用,并且遇到了一些问题。我一直希望能够使用这个主题,尽管它已经过时了。我已经将 repo 克隆到我的 PC 上并bundle install开始运行。

需要说明的是,我没有 Web 开发背景。我实际上是一名 Android 开发人员,希望创建自己的关于 Android 开发的博客(以及想到的任何其他内容)。因此,我并不完全清楚这些命令的作用,例如bundle install在这种情况下为什么需要运行它。

考虑到这一点,我继续尝试jekyll serve并显示以下消息:

WARN: Unresolved specs during Gem::Specification.reset:
      rouge (< 4, >= 1.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated public_suffix 3.0.2, but your Gemfile requires public_suffix 2.0.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:31:in `block in setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `map'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jekyll-3.7.3/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jekyll-3.7.3/exe/jekyll:11:in `<top (required)>'
    from /home/mike/.rbenv/versions/2.3.1/bin/jekyll:23:in `load'
    from /home/mike/.rbenv/versions/2.3.1/bin/jekyll:23:in `<main>

如果我使用bundle exec jekyll serve,我有我的本地服务器并且可以很好地预览主题。但是,为什么我需要在前面加上“bundle exec”才能让事情正常工作?是否担心显示这些消息?有什么办法可以纠正它们吗?

jekyll serve另外,除了创建别名之外,有什么方法可以进行更正,以便我需要做的就是?非常感谢对此的任何澄清和支持!

如果它有帮助,这就是 Gemfile 的样子:

source "https://rubygems.org"
ruby RUBY_VERSION

# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
#     bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "3.7.3"

# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima"

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins

# If you have any plugins, put them here!
# group :jekyll_plugins do
#   gem "jekyll-github-metadata", "~> 1.0"
# end
4

1 回答 1

1

bundle exec确保将在其中运行的 ruby​​ 程序将使用Gemfile为您所在项目指定的 gem。当您安装了多个版本的 gem 时,它会有所帮助 - 选择正确的版本而不是默认/最新版本。

在您的情况下,错误消息显示You have already activated public_suffix 3.0.2, but your Gemfile requires public_suffix 2.0.5.您安装了较新版本的 gem,但您需要较旧版本。这就是为什么jekyll serve如果不添加前缀就无法开始的原因bundle exec

您可以使用gemsets分离您的 gem以避免此问题。由于您只需要使用 jekyll,我还是建议您使用别名。这更容易,我认为这里没有必要做任何花哨的事情。

于 2018-04-04T15:16:13.307 回答