GithubHelp home page GithubHelp logo

Comments (25)

bensie avatar bensie commented on May 19, 2024

I'm having the same issue.

from bundler.

jpzwarte avatar jpzwarte commented on May 19, 2024

Idem: http://gist.github.com/294420

from bundler.

ariejan avatar ariejan commented on May 19, 2024

Same here with Ruby 1.9.1

from bundler.

mdolian avatar mdolian commented on May 19, 2024

I'm having this same issue

from bundler.

carllerche avatar carllerche commented on May 19, 2024

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.

from bundler.

MattHulse avatar MattHulse commented on May 19, 2024

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)

from bundler.

sakuro avatar sakuro commented on May 19, 2024

hmm, @specification_version is nil when we come to method_missing... why??

from bundler.

MattHulse avatar MattHulse commented on May 19, 2024

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.

from bundler.

sakuro avatar sakuro commented on May 19, 2024

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

from bundler.

sakuro avatar sakuro commented on May 19, 2024

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??)

from bundler.

din avatar din commented on May 19, 2024

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:

 gemspec = eval spec_code, binding, file_name

Last backtrace line is:

 /var/opt/ruby/lib/ruby/1.9.1/rubygems/specification.rb:530:in `method_missing'

Error is because @specification_version is 'nil'

Full backtrace of error is:

"/var/opt/ruby/lib/ruby/1.9.1/rubygems/specification.rb:531:in `method_missing'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/specifications/mime-types-1.16.gemspec:4:in `block in load_specification'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/specification.rb:421:in `initialize'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/specifications/mime-types-1.16.gemspec:3:in `new'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/specifications/mime-types-1.16.gemspec:3:in `load_specification'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `eval'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:95:in `load_specification'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:156:in `block (2 levels) in load_gems_in'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:155:in `each'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:155:in `block in load_gems_in'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:152:in `reverse_each'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:152:in `load_gems_in'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:348:in `refresh!'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:78:in `from_gems_in'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:913:in `source_index'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/gem_path_searcher.rb:84:in `init_gemspecs'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/gem_path_searcher.rb:19:in `initialize'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:871:in `new'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:871:in `block in searcher'",
 "<internal:prelude>:8:in `synchronize'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:870:in `searcher'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:528:in `find_files'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems.rb:1093:in `<top (required)>'",
 "<internal:gem_prelude>:161:in `require'",
 "<internal:gem_prelude>:161:in `load_full_rubygems_library'",
 "<internal:gem_prelude>:273:in `const_missing'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/specification.rb:1038:in `<class:Specification>'",
 "/var/opt/ruby/lib/ruby/1.9.1/rubygems/specification.rb:28:in `<top (required)>'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-0.9.2/lib/bundler/rubygems.rb:2:in `require'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-0.9.2/lib/bundler/rubygems.rb:2:in `<top (required)>'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-0.9.2/lib/bundler.rb:4:in `require'",
 "/var/opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-0.9.2/lib/bundler.rb:4:in `<top (required)>'",
 "config/boot.rb:6:in `require'",
 "config/boot.rb:6:in `rescue in <main>'",
 "config/boot.rb:2:in `<main>'"

from bundler.

sakuro avatar sakuro commented on May 19, 2024

yeah, so investigating the mechanism that @Specification remains nil.

from bundler.

din avatar din commented on May 19, 2024

I suppose that this issue isn't caused by Bundler, but by Rubygems.
I have Ruby HEAD (checked out from SVN and compiled by myself) and when I write in irb

 require "rubygems/specification"

It shows the same errors.

from bundler.

sakuro avatar sakuro commented on May 19, 2024

hmm, I'll report this to ruby's redmine.

from bundler.

sakuro avatar sakuro commented on May 19, 2024

thread from ruby-core:345886 discusses this...

from bundler.

sakuro avatar sakuro commented on May 19, 2024

Posted: http://redmine.ruby-lang.org/issues/show/2717

from bundler.

sakuro avatar sakuro commented on May 19, 2024

Does following modification fix the problem?

At least, bundle exec ruby -e 1 succeeds.

  1. Edit lib/bundler.rb from
    4: require 'bundler/rubygems'
    to
    4: require 'bundler/rubygems-ext'
  2. Edit lib/bundler/rubygem.rb
    from
    1: require 'rubygems'
    2: require 'rubygems/specification'
    to
    1: unless defined? Gem
    2: require 'rubygems'
    3: require 'rubygems/specification'
    4: end
  3. Rename lib/bundler/rubygems.rb (Editted in 2.) to lib/bundler/rubygems-ext.rb.
    This rename is because gem_prelude.rb of ruby 1.9 has following code.
if /#{Regexp.escape File::SEPARATOR}rubygems\.rb\z/ =~ path
  raise LoadError, "another rubygems is already loaded from #{path}"
end

from bundler.

MattHulse avatar MattHulse commented on May 19, 2024

@sakuro: yes that fixed it for me.

from bundler.

julian7 avatar julian7 commented on May 19, 2024

I can confirm that it helps fixing the same issue in rails 3 too.

from bundler.

ariejan avatar ariejan commented on May 19, 2024

I've created a patch in my fork of bundler. Feel free to pull it in: http://github.com/ariejan/bundler

from bundler.

localshred avatar localshred commented on May 19, 2024

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

from bundler.

trevor avatar trevor commented on May 19, 2024

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

from bundler.

localshred avatar localshred commented on May 19, 2024

@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 bundler.

trevor avatar trevor commented on May 19, 2024

@localshred

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.

from bundler.

trevor avatar trevor commented on May 19, 2024

@localshred

also see
http://github.com/carlhuda/bundler/issues#issue/51/comment/130069

from bundler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.