rake undefined method `gsub' for nil:NilClass

2019-07-01 18:21发布

问题:

I'm hoping there is someone out here with a few encouraging words and a little advice.

I am using Ruby v1.9.2 p290

I've been setting up a new production server and I'm having a terrible time trying to get the new environment to work correctly. Everything is installed and now I'm trying to run rake, but it is giving me an error I can't make any sense of and can't find any internet help on.

deploy@ip-10-99-66-30:~/pm$ rake -v --trace
rake aborted!
undefined method `gsub' for nil:NilClass
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/runtime.rb:72:in `rescue in block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/runtime.rb:62:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler.rb:119:in `require'
/home/deploy/pm/config/application.rb:14:in `<top (required)>'
<internal:lib/rubygems/custom_require>:29:in `require'
<internal:lib/rubygems/custom_require>:29:in `require'
/home/deploy/pm/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'

Here is my gem list

actionmailer (3.1.0)
actionpack (3.1.0)
activemodel (3.1.0)
activerecord (3.1.0)
activeresource (3.1.0)
activesupport (3.1.0)
archive-tar-minitar (0.5.2)
arel (2.2.3)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.1.4)
cancan (1.6.8)
capybara (1.1.2)
childprocess (0.3.3)
client_side_validations (3.1.4)
cocaine (0.2.1)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
columnize (0.3.6)
cucumber (1.2.1)
cucumber-rails (1.3.0)
daemon_controller (1.0.0)
database_cleaner (0.8.0)
devise (1.5.3)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (3.5.0)
factory_girl_rails (3.5.0)
faker (1.0.1)
fastthread (1.0.7)
ffi (1.0.11)
geocoder (1.1.2)
gherkin (2.11.1)
guard (1.2.3)
guard-rspec (1.2.0)
haml (3.1.6)
haml-rails (0.3.4)
hike (1.2.1)
hpricot (0.8.6)
httparty (0.8.3)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (1.0.19)
json (1.7.3)
json_pure (1.7.3)
jsonify (0.3.1)
jsonify-rails (0.3.2)
libv8 (3.3.10.4 x86_64-linux)
linecache19 (0.5.12)
listen (0.4.7)
mail (2.3.3)
meta_search (1.1.3)
mime-types (1.19)
minitest (1.6.0)
multi_json (1.3.6)
multi_xml (0.5.1)
mysql2 (0.3.11)
nokogiri (1.5.5)
orm_adapter (0.0.7)
paperclip (2.7.0)
passenger (3.0.17)
polyamorous (0.5.0)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.0.3)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.0)
rails3-jquery-autocomplete (1.0.7)
railties (3.1.0)
rake (0.9.2)
rb-fchange (0.0.5)
rb-fsevent (0.9.1)
rb-inotify (0.8.8)
rdoc (3.12, 2.5.8)
remotipart (1.0.2)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
rspec-mocks (2.11.2)
rspec-rails (2.11.0)
ruby-debug-base19 (0.11.25)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.5)
ruby_parser (2.3.1)
rubyzip (0.9.9)
sass (3.1.20)
sass-rails (3.1.4)
selenium-webdriver (2.7.0)
sexp_processor (3.2.0)
simple_datatables (0.2.1)
sprockets (2.0.4)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.3)
timeliness (0.3.6)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.6)
validates_timeliness (3.0.12)
warden (1.2.1)
web-app-theme (0.8.0)
webrat (0.7.3)
will_paginate (3.0.3)
xpath (0.1.4)

I've spent several days on this, not much hair left on my head after all the hair pulling.

Any suggestions? Ruby on Rails is an excellent platform to work with, but I'm stumped on this one.

回答1:

Updating the bundler gem to the latest version (1.2.3 at the time of answering) by doing:

gem update bundler

fixed this problem for me. Well, it didn't exactly fix it but it allowed the actual error message that was causing the problem to be displayed.



回答2:

There was a problem with my gem .

update the bundler

Read the error properly, it will tell you which gem is the culprit.

Thing is that not all gems are compatible with OS .



回答3:

Seems to be an issue related to gem versions clashing and bundler spitting out a particularly opaque error message.

See: https://github.com/carlhuda/bundler/issues/1847

Apparently this was patched in a recent version of bundler. I have the same issue at present and am looking into it but I hope this helps point you in the right direction.