2

我正在尝试学习 Jekyll,如果我输入以下命令

rake post title="Hello World"

我收到以下错误:

rake post title="My First Post"
/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 11 total gem(s) (Gem::LoadError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:307:in `to_spec'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /usr/bin/rake:18

这是我的环境:

gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib64/ruby/gems/1.8
     - /home/jsmith/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
4

1 回答 1

2

首先,为了简化事情,您的 Jekyll 应用程序应该使用 bundler*。cd到您的应用程序并运行:

$ bundle init

这将创建一个 Gemfile。在该 Gemfile 中添加 jekyll:

# Gemfile
source 'https://rubygems.org'
gem 'jekyll'

然后运行bundle install,它将安装 jekyll 及其所有依赖项:

$ bundle install

bundle exec然后预先运行 rake ,如下所示:

$ bundle exec rake post title="Hello World"

这样做是使用添加到 Gemfile(与当前项目关联的 gem 列表)的 rake 版本。

*说明取自http://matthodan.com/2012/10/27/how-to-create-a-blog-with-jekyll.html

于 2013-03-22T14:50:11.897 回答