【问题标题】:Octopress errors - rake preview, watch or generateOctopress 错误 - rake 预览、观看或生成
【发布时间】:2012-11-26 13:29:44
【问题描述】:

我遵循了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,它说所有的gem 都已安装(我在安装ruby 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>'

我应该使用捆绑所有 gem 重新安装吗?看不懂。

【问题讨论】:

  • 你有什么 Ruby 版本? (编辑:我注意到你有 1.8.X)

标签: ruby rake jekyll rakefile octopress


【解决方案1】:

试试吧

$ rvm use 1.9.3

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

那我想你跑的时候

$ rake watch

$ rake preview

现在可以工作了。


编辑:

所以,对于rbenv,试试:

$ rbenv global 1.9.3-p327

或者您也可以使用local

【讨论】:

  • 我没有使用 rvm。我使用 rbenv 安装新的 ruby​​
  • @SiddharthaRT 你可以试试rbenv global 1.9.3-p327
  • 我已经试过了。问题是,当我执行build exec rake 时,它使用来自Ruby 1.8 的二进制文件。
  • @SiddharthaRT ruby -v 来检查真正使用的版本是什么?
  • 好吧,经过一番折腾,我想我把我的 comp 中的整个 ruby​​ 设置搞砸了。当我运行 ruby​​ 时,我现在收到此错误 - &lt;internal:gem_prelude&gt;:1:in require': cannot load such file -- ruby​​gems.rb (LoadError) from :1:in &lt;compiled&gt;'
【解决方案2】:

我认为问题出在过时的 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

【讨论】:

  • 我已将更改放在问题中。
  • 你试过用bundle exec运行任务吗?例如bundle exec rake preview
【解决方案3】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    相关资源
    最近更新 更多