我安装了 jekyll 3.1.2 但我的系统仍在使用 jekyll 3.0.3

I have jekyll 3.1.2 installed but my system is still using jekyll 3.0.3

我试图让我的系统在我 运行 命令

时使用 gem Jekyll 3.1.2

$ jekyll new .

从下面的 Gem 文件列表中可以看出,我安装了两个版本的 jekyll 3.1.2 和 3.0.3。

$ gem list jekyll                                                                                         

*** LOCAL GEMS ***

jekyll (3.1.2, 3.0.3)
jekyll-coffeescript (1.0.1)
jekyll-feed (0.4.0)
jekyll-gist (1.4.0)
jekyll-github-metadata (1.9.0)
jekyll-mentions (1.1.2)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.10.0)
jekyll-sass-converter (1.4.0, 1.3.0)
jekyll-seo-tag (1.3.2)
jekyll-sitemap (0.10.0)
jekyll-textile-converter (0.1.0)
jekyll-watch (1.3.1)

然而,似乎正在使用的版本是 3.0.3:

$ jekyll -v
jekyll 3.0.3

我尝试手动卸载 jekyll 3.0.3,但收到以下警告:

You have requested to uninstall the gem:
    jekyll-3.0.3

github-pages-66 depends on jekyll (= 3.0.3)
jekyll-feed-0.4.0 depends on jekyll (< 3.1.0, >= 2.4.0, development)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]

我确实使用 Github 页,因此删除此版本会破坏 Github 页 gem...

怎么办?

  1. 安装 Bundler,如果您还没有安装的话。 运行gem install bundler

  2. 为您的 Jekyll 项目创建一个文件夹(如果您还没有这样做的话)

  3. 在此文件夹中创建一个 Gemfile,内容如下:

    source "https://rubygems.org"
    
    gem 'jekyll', '3.1.2'
    
  4. 在您的终端上,通过 cd/path/to/project

  5. 导航到您的项目文件夹
  6. 运行 bundle install

  7. 运行 bundle exec jekyll new . --force

完成!

注意:--force即使当前文件夹不为空也会创建一个新的jekyll