TwP / inifile

Native Ruby package for reading and writing INI files
http://codeforpeople.rubyforge.org/inifile
95 stars 47 forks source link

undefined method `length' for nil:NilClass #11

Closed stereobooster closed 12 years ago

stereobooster commented 12 years ago

with inifile 1.1.0 works fine http://travis-ci.org/#!/stereobooster/jshintrb/jobs/2274486 but with inifile 2.0 http://travis-ci.org/#!/stereobooster/jshintrb/builds/2276434 produce error

D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/inifile-2.0.0/lib/inifile.rb:453:in `parse!'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/inifile-2.0.0/lib/inifile.rb:90:in `initialize'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/submodule-0.1.0/lib/submodule.rb:20:in `new'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/submodule-0.1.0/lib/submodule.rb:20:in `initialize'
D:/projects/jshintrb/Rakefile:8:in `new'
D:/projects/jshintrb/Rakefile:8:in `<top (required)>'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
D:/tools/ruby-1.9.2-p290-i386-mingw32/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
D:/tools/ruby-1.9.2-p290-i386-mingw32/bin/rake:23:in `load'
D:/tools/ruby-1.9.2-p290-i386-mingw32/bin/rake:23:in `<main>'
eranb commented 12 years ago

Same here, version 2.0.0 not working for me as well.

undefined method `length' for nil:NilClass@inifile.rb:453 ruby-1.9.3-p125@rvm

TwP commented 12 years ago

The problem is this line: https://github.com/stereobooster/submodule/blob/master/lib/submodule.rb#L20

Inifile 2.0 is a major release, and the initializer has changed. Your line should look like this now ...

gitmodules = IniFile.new( :filename => './.gitmodules' ).to_h

You can also use the class level load method ...

gitmodules = IniFile.load( './.gitmodules' ).to_h