ruby-on-rails - 尝试使用 Jekyll rake 命令时出现错误

标签 ruby-on-rails ruby rake

我正在尝试学习 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/

最佳答案

首先,为了简化事情,您的 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

关于ruby-on-rails - 尝试使用 Jekyll rake 命令时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15573153/

相关文章:

ruby-on-rails - 用 distance_of_time_in_words 显示剩余时间

带有散列参数的 Ruby public_send 方法(如果适用)

ruby-on-rails - 添加 www.总体设计电子邮件或 Rails?

ruby - Rakefile 和 Gemfile

javascript - Rails crontab rake javascript 运行时未找到

ruby-on-rails - erb 中双引号属性值的字符串插值

ruby-on-rails - Rails update_attributes 不起作用

ruby-on-rails - 在 ruby​​ 中覆盖 hash 和 eql 会影响性能吗?

ruby-on-rails - "gem update --system is disabled on Debian"错误

sql - 什么是 "Implicit Database Sequence"?