Octopress错误 - rake预览,观察或生成

时间:2012-12-08 15:22:58

标签: ruby rake jekyll rakefile octopress

我按照Octopress Documentation中的所有说明操作:

sddhrthrt@thinkpad:~/octopress$ rake generate
## Generating Site with Jekyll
directory source/stylesheets/ 
   create source/stylesheets/screen.css 
Configuration from /home/sddhrthrt/octopress/_config.yml
/home/sddhrthrt/octopress/plugins/pygments_code.rb:5: 
      warning: already initialized constant PYGMENTS_CACHE_DIR
/home/sddhrthrt/octopress/plugins/render_partial.rb:25:in `require':
             ./plugins/octopress_filters.rb:69: undefined (?...) sequence:
              /<div class="entry-content">(?<content>[\s\S]*?)<\/div>\s*<(footer|\/article)>/ (SyntaxError)
        from /home/sddhrthrt/octopress/plugins/render_partial.rb:25
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:76:in `require'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:76:in `setup'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:75:in `each'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:75:in `setup'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:30:in `initialize'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/jekyll:224:in `new'
        from /var/lib/gems/1.8/gems/jekyll-0.11.2/bin/jekyll:224
        from /usr/local/bin/jekyll:19:in `load'
        from /usr/local/bin/jekyll:19

并且

sddhrthrt@thinkpad:~/octopress$ rake preview
Starting to watch source with Jekyll and Compass. Starting Rack on port 4000
rake aborted!
undefined method `spawn' for Process:Module

Tasks: TOP => preview
(See full trace by running task with --trace)

sddhrthrt@thinkpad:~/octopress$ rake watch
Starting to watch source with Jekyll and Compass.
rake aborted!
undefined method `spawn' for Process:Module

Tasks: TOP => watch
(See full trace by running task with --trace)

我承认,我从未参与Ruby工作。因此,我不太愿意解读错误。谷歌搜索也没有产生任何我能理解的东西。

修改

在答案中提到,我安装了rbenv,然后安装了ruby 1.9.3-p327。我回到~/octopress然后跑了bundle install并说它已经安装了所有宝石(当我有红宝石1.8x时我已经这样做了)。现在rake给了我这个错误:

sddhrthrt@thinkpad:~/octopress$ rake --trace
rake aborted!
cannot load such file -- bundler/setup
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/sddhrthrt/octopress/Rakefile:2:in `<top (required)>'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/home/sddhrthrt/.rbenv/versions/1.9.3-p194/bin/rake:32:in `<main>'

我应该重新使用捆绑所有的宝石吗?我不明白。

3 个答案:

答案 0 :(得分:3)

试试

$ rvm use 1.9.3

在您网站的根文件夹中。注意,1.9.3是您的Ruby版本。

然后我想当你运行

$ rake watch

$ rake preview

现在可以使用。


编辑:

因此,对于rbenv,请尝试:

$ rbenv global 1.9.3-p327

或者您可以改为使用local

答案 1 :(得分:1)

我认为问题在于过时的Ruby。根据这个:https://github.com/imathis/octopress/issues/142你应该使用Ruby 1.9(稳定版本现在是1.9.3-p327)。您可以直接从Ruby站点获取此信息,但我建议使用RVM(或rbenv)来设置您的Ruby环境。

您可以在此处找到如何在您的包装盒上安装RVM的指南:https://rvm.io/rvm/install/

然后安装Ruby 1.9.3将非常简单:

rvm install 1.9.3
rvm --default 1.9.3
rvm reload

然后,您必须在Octopress根目录中安装bundle install(以获取bundlergem install bundler)的所有依赖项。

修改

Octopress项目根目录中的.rvmrc表示它需要Ruby 1.9.3:https://github.com/imathis/octopress/blob/master/.rvmrc

答案 2 :(得分:1)

您是否错过了rbenv配置的第3步?

$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

https://github.com/sstephenson/rbenv/#rbenv-shell