codegram/pelusa

undefined method `fetch' on nil:NilClass. (NoMethodError)

Closed this issue · 7 comments

I get this anytime I try to run pelusa on a ruby file.

An exception occurred running /home/phild/.rvm/gems/rbx-head/bin/pelusa
    undefined method `fetch' on nil:NilClass. (NoMethodError)

Backtrace:
  Kernel(NilClass)#fetch (method_missing) at kernel/delta/kernel.rb:81
          Pelusa::Configuration#lints at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /lib/pelusa/configuration.rb:73
 Pelusa::Configuration#disabled_lints at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /lib/pelusa/configuration.rb:78
  Pelusa::Configuration#enabled_lints at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /lib/pelusa/configuration.rb:64
                           Pelusa.run at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /lib/pelusa.rb:6
                      Pelusa::Cli#run at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /lib/pelusa/cli.rb:17
                    Object#__script__ at .rvm/gems/rbx-head/gems/pelusa-0.1.0
                                         /bin/pelusa:13
                   Kernel(Object)#load at kernel/common/kernel.rb:588
                     Object#__script__ at .rvm/gems/rbx-head/bin/pelusa:19
      Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67
      Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:109
               Rubinius::Loader#script at kernel/loader.rb:630
                 Rubinius::Loader#main at kernel/loader.rb:834

This is still present in the new 0.1.1 release.

Could you provide an example ruby file so we can reproduce the issue?

It happens on any Chef recipe. Here's an example one from their open source community:

packages = case node['platform']
  when "centos","redhat","fedora"
    %w{openssh-clients openssh}
  when "arch"
    %w{openssh}
  else
    %w{openssh-client openssh-server}
  end

packages.each do |pkg|
  package pkg
end

service "ssh" do
  case node['platform']
  when "centos","redhat","fedora","arch"
    service_name "sshd"
  else
    service_name "ssh"
  end
  supports value_for_platform(
    "debian" => { "default" => [ :restart, :reload, :status ] },
    "ubuntu" => {
      "8.04" => [ :restart, :reload ],
      "default" => [ :restart, :reload, :status ]
    },
    "centos" => { "default" => [ :restart, :reload, :status ] },
    "redhat" => { "default" => [ :restart, :reload, :status ] },
    "fedora" => { "default" => [ :restart, :reload, :status ] },
    "arch" => { "default" => [ :restart ] },
    "default" => { "default" => [:restart, :reload ] }
  )
  action [ :enable, :start ]
end

I looks a little odd because there's a DSL for Chef here, but it's all valid ruby.

it happens because of this line

I can work on a patch tomorrow and send you a pull request

It dies if you don't have a per-project config file. Here's a workaround to get you going without waiting for an updated gem:```
$ echo "---\nlint: {}" > .pelusa.yml

yup. I'm pretty sure I checked the case where the config doesn't exist. anyway, I'm going to fix it tomorrow.

@acrmp Thanks, that indeed works around it.

Sadly, there's nothing Pelusa can (yet) check in these files. It only handles classes, afact, not non-class methods... but it's a good start.