尝试使用Jekyll rake命令时出错

时间:2013-03-22 14:43:59

标签: ruby-on-rails ruby rake

我正在努力学习杰基尔,如果我输入以下命令

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

这是我的ENV:

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/

1 个答案:

答案 0 :(得分: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的rake版本(与当前项目关联的gem列表)。

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

的说明