错误:未定义的方法`gsub'代表nil:NilClass

时间:2013-08-03 21:43:25

标签: ruby gem jekyll

我所做的只是按照Jekyll网站上的说明进行操作。我收到一个错误,我不知道如何修复。

~ $ gem install jekyll
~ $ jekyll new my-awesome-site
~ $ cd my-awesome-site

当我收到错误时:

error: undefined method `gsub' for nil:NilClass. Use --trace to view backtrace

跟踪结果:

/Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/jekyll-1.1.2/lib/jekyll/stevenson.rb:77:in `message': undefined method `gsub' for nil:NilClass (NoMethodError)
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/jekyll-1.1.2/lib/jekyll/stevenson.rb:56:in `error'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/jekyll-1.1.2/lib/jekyll/stevenson.rb:66:in `abort_with'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/jekyll-1.1.2/bin/jekyll:41:in `block (2 levels) in <top (required)>'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/command.rb:180:in `call'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/command.rb:180:in `call'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/command.rb:155:in `run'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/runner.rb:402:in `run_active_command'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/runner.rb:78:in `run!'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/delegates.rb:11:in `run!'
    from /Users/rruiz/.rvm/gems/ruby-1.9.3-p392/gems/commander-4.1.4/lib/commander/import.rb:10:in `block in <top (required)>' 

如何解决这个问题让Jekyll工作?

1 个答案:

答案 0 :(得分:5)

给Jekyll一个无效命令时,我得到了同样的错误。

> jekyll foo
/.rvm/gems/ruby-2.0.0-p247/gems/jekyll-1.1.2/lib/jekyll/stevenson.rb:77:in `message': undefined method `gsub' for nil:NilClass (NoMethodError)


> jekyll build
Configuration file: .../projects/my-awesome-site/_config.yml
            Source: .../projects/my-awesome-site
       Destination: .../projects/my-awesome-site/_site
      Generating... done.

你想要运行什么命令?

jekyll build构建项目(-w以观察更改)

jekyll serve启动服务器