Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`dirname': can't convert nil into String (TypeError)

I'm not sure if this is in cucumber really, but just in case some of you guys have a clue on how to fix this. Basically, my tests suddenly stopped working and when I checked, it showed this error:

C:/Vendor/Ruby187/lib/ruby/gems/1.8/gems/cucumber-rails-1.0.0/lib/cucumber/rails3.rb:3 in 'dirname': can't convert nil into String (TypeError)

Yes, I first rolled my eyes and just cursed Windows but I tried it on my Mac and I got the same:

/Users/eumir/.rvm/gems/ruby-1.8.7-p174@mygemset/gems/cucumber-rails-0.5.2/lib/cucumber/rails3.rb:3:in `dirname': can't convert nil into String (TypeError)

Weird though, its in different cucumber rails versions, I googled and the first result shows it is bunder's fault(although I can't decipher what the gist is about...maybe just copy pasted stuff?) and weirdest of all, Cucumber IS running and I run into this problem while running rspec spec.

The 3 clues below point out that it's not cucumber's fault, but why does it blame cucumber? IF any of you can shed a clue as to why this is happening, you'll be saving me from a few more hours of pain.

like image 428
corroded Avatar asked Oct 28 '11 09:10

corroded


1 Answers

This was caused by how bundler attempts to "autorequire" gems. In 1.0, bundler tries the gem name (in this case "cucumber-rails") and smothers the error if the file isn't found (it isn't).

In bundler 1.1.1, bundler replaces instances of "-" with "/", resulting in it autorequiring "cucumber/rails" which results in the "accidental" loading described by Ewout.

To resolve, set :require => false in your gemfile.

(Note: :require => false doesn't mean that the gem is optional, just that Bundler shouldn't auto-require it)

like image 151
SubmittedDenied Avatar answered Oct 07 '22 16:10

SubmittedDenied