2016-09-16 111 views
4

我試圖用命令jekyll build構建一個jekyll站點。當我運行該命令時出現以下錯誤:Jekyll構建錯誤

/usr/local/share/ruby/gems/2.0/gems/bundler-1.13.1/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError) 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:1393:in `contains_requirable_file?' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:68:in `block in require' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:823:in `block in each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:822:in `each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:822:in `each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:67:in `find' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:67:in `require' 
    from /usr/local/share/ruby/gems/2.0/gems/bundler-1.13.1/lib/bundler/plugin/api/source.rb:2:in `<top (required)>' 
    from /usr/local/share/ruby/gems/2.0/gems/bundler-1.13.1/lib/bundler/rubygems_ext.rb:45:in `full_gem_path' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:1393:in `contains_requirable_file?' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:68:in `block in require' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:823:in `block in each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:822:in `each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/specification.rb:822:in `each' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:67:in `find' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:67:in `require' 
    from /usr/local/share/ruby/gems/2.0/gems/bundler-1.13.1/lib/bundler.rb:11:in `<top (required)>' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:135:in `require' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require' 
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:144:in `require' 
    from /usr/local/share/ruby/gems/2.0/gems/jekyll-3.2.1/lib/jekyll/plugin_manager.rb:34:in `require_from_bundler' 
    from /usr/local/share/ruby/gems/2.0/gems/jekyll-3.2.1/exe/jekyll:9:in `<top (required)>' 
    from /usr/local/bin/jekyll:23:in `load' 
    from /usr/local/bin/jekyll:23:in `<main>' 

我運行的是Ruby 2.2版。我的服務器是Amazon Linux AMI。讓我知道是否有任何其他信息需要回答這個問題!

回答

4

我最終弄清楚了這一點。顯然我錯過了一個JavaScript環境。步驟:

  1. sudo rm -r Gemfile.lock
  2. nano Gemfile。添加gem 'therubyracer'。保存並退出
  3. bundle install
  4. bundle exec jekyll build

這解決了這個問題對我來說!

2

我遇到了同樣的問題。當您尚未初始化bundler和jekyll依賴關係時會發生這種情況。

爲了解決這個問題,

  1. 轉到根目錄包含您的化身文件
  2. 運行jekyll new . --force。這將初始化捆綁和依賴傑基爾當前文件夾
  3. 現在運行使用bundler exec jekyll serve

jekyll new . --force作品像git init一個新的git倉庫服務器。請參閱documentation以獲取更多信息