使用`bundle exec jekyll new创建新的默认站点时,Jekyll / Bundler失败。 --force`

时间:2017-03-29 19:19:37

标签: ruby jekyll bundler

我做了bundle config --global path vendor/bundle,以便Bundler将依赖项(包括Jekyll)安装到项目目录而不是GEM_HOME。我没有将Jekyll安装到GEM_HOME。

初始化项目目录时......

mkdir site && cd site
bundle init

更新了我的项目Gemfile的内容......

# frozen_string_literal: true
source "https://rubygems.org"

gem "jekyll"

将Jekyll安装到项目目录并使用默认的脚手架创建了一个新站点...

bundle install
bundle exec jekyll new . --force

...我希望Jekyll将默认的站点脚手架编写到当前目录中,覆盖我的原始Gemfile,然后bundle install来自的默认站点依赖项 Gemfile(例如,minima)到vendor / bundle。

相反,这是输出:

Running bundle install in /Users/joeptacek/site...
  Bundler: /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/resolver.rb:386:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'minima (~> 2.0)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/resolver.rb:356:in `each'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/resolver.rb:356:in `verify_gemfile_dependencies_are_found!'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/resolver.rb:203:in `start'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/resolver.rb:182:in `resolve'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/definition.rb:252:in `resolve'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/definition.rb:176:in `specs'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/definition.rb:235:in `specs_for'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/definition.rb:224:in `requested_specs'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:118:in `block in definition_method'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:19:in `setup'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler.rb:100:in `setup'
  Bundler: from /Users/joeptacek/.gem/ruby/2.4.1/gems/bundler-1.14.6/lib/bundler/setup.rb:20:in `<top (required)>'
  Bundler: from /Users/joeptacek/.rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  Bundler: from /Users/joeptacek/.rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'

如果我再次运行bundle install,则会安装依赖项而不会出现进一步的问题。

为避免错误,我的解决方法是使用

制作new网站
bundle exec jekyll new . --force --skip-bundle && bundle install

这是一个错误,还是我误解了Jekyll和Bundler的工作方式?

1 个答案:

答案 0 :(得分:0)

根据我的收集,您的工作流程与官方文档的唯一区别在于您将jekyll gem及其依赖项安装到vendor/bundle

jekyll new创建一个Gemfile以及站点脚手架。因此,您无需事先初始化一个,然后使用--force开关覆盖它。

要在/projects/site搭建新的Jekyll网站,您只需执行以下操作:

# from 'projects/' directory
$ jekyll new site

现在您可以编辑Gemfile并根据需要添加任何其他宝石。

注意:它不是bundle exec jekyll new --而是普通的&#39; jekyll new
只有当目录中存在bundle exec时,Gemfile 才会添加到其他所有命令