Excessive warning output on environment load #24
Comments
I'm having the same issue. |
Same here with Ruby 1.9.1 |
I'm having this same issue |
So, I have no idea what actually is causing it. I spent a large amount of time debugging it and it's somewhere in Gem::Specification#method_missing. I'm worried that it's some ruby bug. If somebody can find the source and submit a patch, i would be greatly appreciative. |
I see this issue on Windows using 1.9.1 but not on Ubuntu using 1.9.1. (I'm not using RVM currently on Ubuntu) |
hmm, @specification_version is nil when we come to method_missing... why?? |
So I've been digging and I found that the "undefined method '>' for nil:NilClass" is thrown in site_ruby/1.9.1/rubygems/specification.rb method_missing (line 531) because @specification_version is nil. This exception is caught in source_index.rb line 107 which dumps the spec code. I was able to mute the exceptions there but the real question is why isn't @specification_version being set for the specs loaded by bundler. I hope this is helpful. Let me know if I can help in any way. |
Just to clarify the environment, it occurs without rvm. To reproduce the problem: $ mv ~/.rvm ~/_rvm (if you have rvm installed) (open a new shell if you've used rvm) $ svn co RUBY-TRUNK $ cd RUBY-TRUNK $ ./configure $ make $ sudo make install (if your shell requires) $ rehash $ which ruby /usr/local/bin/ruby $ ruby -v ruby 1.9.2dev (2010-02-06 trunk 26592) [x86_64-darwin10.2.0] $ sudo gem install bundler $ rehash (if your shell requires) $ gem list *** LOCAL GEMS *** bundler (0.9.3) minitest (1.5.0) rake (0.8.7) rdoc (2.2.2) $ mkdir testapp $ cd testapp $ echo 'gem "rake"' > Gemfile (fix cli.rb and add .to_s at the end) $ sudo vi +103 /usr/local/lib/ruby/gems/1.9.1/gems/bundler-0.9.3/lib/bundler/cli.rb $ bundle exec ruby -e 1 |
I changed line 1038 of ruby's 1.9.1/rubygems/specification.rb from 1038: required_attribute :rubygems_version, Gem::RubyGemsVersion to 1038: puts '%s:%d' % [ __FILE__, __LINE__ ] 1039: k = Gem::RubyGemsVersion 1040: puts '%s:%d' % [ __FILE__, __LINE__ ] 1041: required_attribute :rubygems_version, k 1042: puts '%s:%d' % [ __FILE__, __LINE__ ] and run the auctual command invoked when one run 'bundle exec ruby -e 1'. $ RUBYOPT="-I/PATH/TO/gems/bundler-0.9.3/lib -rbundler/setup -rubygems" ruby -e 1 and got /PATH/TO/ruby/1.9.1/rubygems/specification.rb:1038 WARNING: #' for nil:NilClass> # -*- encoding: utf-8 -*- [SNIP] WARNING: Invalid .gemspec format in '/PATH/TO/specifications/rake-0.8.7.gemspec' /PATH/TO/ruby/1.9.1/rubygems/specification.rb:1040 /PATH/TO/ruby/1.9.1/rubygems/specification.rb:1042 This means accessing constant Gem::RubyGemsVersion is the root of our problem, right? (autoload??) |
I think that the error is in file "ruby/1.9.1/rubygems/source_index.rb", somewhere around line 109 of it. Yep. Error is in this string:
Last backtrace line is:
Error is because @specification_version is 'nil' Full backtrace of error is:
|
yeah, so investigating the mechanism that @Specification remains nil. |
I suppose that this issue isn't caused by Bundler, but by Rubygems.
It shows the same errors. |
hmm, I'll report this to ruby's redmine. |
thread from ruby-core:345886 discusses this... |
Does following modification fix the problem? At least, bundle exec ruby -e 1 succeeds.
if /#{Regexp.escape File::SEPARATOR}rubygems\.rb\z/ =~ path raise LoadError, "another rubygems is already loaded from #{path}" end |
@sakuro: yes that fixed it for me. |
I can confirm that it helps fixing the same issue in rails 3 too. |
I've created a patch in my fork of bundler. Feel free to pull it in: http://github.com/ariejan/bundler |
Applying the above fix from @Sakura worked to remove the gem spec errors but I'm still getting the "already initialized constant" errors. My output is here: http://gist.github.com/298503. Thanks for the help |
re: "already initialized constant" errors as pointed out by Balazs Nagy the "warning: already initialized constant" comes from Ruby cruft. removing the old library directory and starting with a fresh install removes those warnings. note, this does not fix the verbose "Invalid .gemspec format in" warnings. here's approximately what I did on OS X (snow leopard). gem list --no-version > gem_list.txt sudo mv /usr/local/lib/ruby /usr/local/lib/ruby-old wget ftp://ftp.ruby-lang.org/pub/ruby/snapshot.tar.bz2 # install sudo su gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n gem install rails --pre gem install sqlite3-ruby env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config # install remaining gems |
@trevor, Is there any way to install just the rubygems stuff? Your explanation makes it sound like it's a rubygems issue, not necessarily ruby itself. I'm running ruby 1.9.1 if that makes a difference. |
from what i can tell ruby development has moved away from using the "site_ruby" directory. as i understand it "warning: already initialized constant" is happening because rubygems is being included twice. in my problem-installation i can find rubygems in two separate places - /usr/local/lib/ruby/1.9.1/rubygems /usr/local/lib/ruby/1.9.1/rubygems.rb /usr/local/lib/ruby/site_ruby/1.9.1/rubygems /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb note they're not even the same files - % diff -q /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb /usr/local/lib/ruby/1.9.1/rubygems.rb Files /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb and /usr/local/lib/ruby/1.9.1/rubygems.rb differ on a clean install from ruby development, after making sure the old /usr/local/lib/ruby is moved elsewhere, i only get one instance of rubygems - /usr/local/lib/ruby/1.9.1/rubygems /usr/local/lib/ruby/1.9.1/rubygems.rb to answer your question there's likely a way to do it without having to reinstall ruby, but this seemed like the easiest way. |
Under RVM 1.9.1, whenever I require the bundler environment, errors paired with gemspecs continuously print out to stderr.
Repeat.
At the end, I get a couple dozen warnings for "already initialized constant".
Hundreds of lines of output, in all (and all silenced when
2>/dev/null
).This has been occurring since Bundler 0.9.beta3 on Rails 3.0.pre and now Rails 3.0.0.beta with the latest Bundler 0.9.2. It occurs for
script/{console,server}
andbundle exec [ruby] script/{console,server}
andbundle exec zsh; script/{console,server}
all the same.The text was updated successfully, but these errors were encountered: