Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(LoadError) on getting version out of gem cache #21

Closed
nmccready opened this issue Jun 19, 2013 · 20 comments
Closed

(LoadError) on getting version out of gem cache #21

nmccready opened this issue Jun 19, 2013 · 20 comments

Comments

@nmccready
Copy link

custom_require.rb:60:in `require': cannot load such file -- version (LoadError)

Is produced by:

  • ruby-1.9.3-p429/
  • rvm 1.21.1 (stable)
  • rspec 2.13.1 .

It seems that the loader is confused with loading version/ or version.rb. Stating 'require version.rb' explicitly fixes the issue as the work around.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

Ruby does not ever attempt to require directories. Without more information, I have no way to debug this. Where and how are you doing require 'version'? Are you using bundler? What is the entire stack trace? What are the contents of your $LOAD_PATH?

@nmccready
Copy link
Author

I am just trying to get this working with a basic ruby application before I troubleshoot a larger app. I am not using bundler that I know of. To me there seems to be an issue with RVM and it not linking gems path correctly.

I ran "irb" and 'require version' failed until I put 'require rubygems' first. I hope this helps. Sorry I am new to this.

The stack below happened when rspec spec/ was called against.
Stack Trace:

/Users/nem/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require': cannot load such file -- version (LoadError)
    from /Users/nem/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /Users/nem/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /Users/nem/Development/MyStuff/git/ruby/test_version/lib/test_version/version.rb:1:in `<top (required)>'
    from /Users/nem/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/nem/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/nem/Development/MyStuff/git/ruby/test_version/spec/get_version_spec.rb:1:in `<top (required)>'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /Users/nem/.rvm/gems/ruby-1.9.3-p429/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

This is expected, correct behavior. If you have installed a gem via rubygems, you must require rubygems before you can use it.

@nmccready
Copy link
Author

I have loaded the gem via gem install version. The gem is installed as far as I van tell "gem list | grep version" => version 1.0.0. . At the gem directory is code that matches github. I am here because this is the first gem that is not loading for me. My next step is to blow away rvm and reinstall ruby.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

As you have described it, this is not a bug in version. Sorry. If you are using gems, you must require rubygems in your application before requiring the individual gems themselves.​

http://docs.rubygems.org/read/chapter/3#page70

@nmccready
Copy link
Author

I just reinstalled ruby with the default rvm installation. I am using
2.0.0-p195 and the same error exists.

Nicholas McCready

Personal Email: [email protected]
Web site: http://codemonkeyseedo.blogspot.com/
Twitter: nmccready https://twitter.com/#!/nmccready

On Thu, Jun 20, 2013 at 8:37 AM, Stephen Touset [email protected]:

As you have described it, this is not a bug in version. Sorry.

If you are using gems, you must require 'rubygems' in your application
before requiring the individual gems themselves.
http://docs.rubygems.org/read/chapter/3#page70


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-19749245
.

@nmccready
Copy link
Author

Should gems be in my $PATH besides rvm magic?

@nmccready
Copy link
Author

The rspec version requirement is ~> '1' will rspec's greater than '1' not work correctly?

@nmccready
Copy link
Author

I cloned sodium and got all your tests to pass via "rake test".

I added a spec/get_version_spec.rb

require 'sodium/version'

describe "Version should" do
  subject do
    Sodium::VERSION
    end

  describe "version" do
    it "extracts version" do
      subject.should == "0.5.0"
    end
  end
end

Failed on rspec spec!

rspec spec                                                                       [9:09:55]
/Users/nem/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require': cannot load such file -- version (LoadError)
    from /Users/nem/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
    from /Users/nem/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
    from /Users/nem/Development/MyStuff/git/ruby/sodium/lib/sodium/version.rb:1:in `<top (required)>'
    from /Users/nem/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Users/nem/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
    from /Users/nem/Development/MyStuff/git/ruby/sodium/spec/get_version_spec.rb:2:in `<top (required)>'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /Users/nem/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

This failed until I added "version.rb"

require 'version.rb'
require 'sodium/version'

describe "Version should" do
  subject do
    Sodium::VERSION
    end

  describe "version" do
    it "extracts version" do
      subject.should == "0.5.0"
    end
  end
end
rspec spec
~/Development/MyStuff/git/ruby/sodium
master* $ rspec spec                                                                       [9:04:41]
.

Finished in 0.00036 seconds
1 example, 0 failures

To me this has to be an issue with rspec.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

I'm sorry, but this appears to be a configuration issue with your local environment.

[stouset:~] % ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
[stouset:~] % gem -v
1.8.25
[stouset:~] % gem install version
Successfully installed version-1.0.0
1 gem installed
Installing ri documentation for version-1.0.0...
[stouset:~] % irb
irb(main):001:0> require 'version'
=> true
irb(main):002:0> exit
[stouset:~] % gem install sodium
Successfully installed sodium-0.5.0
1 gem installed
Installing ri documentation for sodium-0.5.0...
[stouset:~] % irb
irb(main):002:0> require 'sodium/version'
=> true

@stouset stouset closed this as completed Jun 20, 2013
@nmccready
Copy link
Author

I know this is closed, but this is still bugging me. Is this possibly relevant? http://stackoverflow.com/questions/11499140/weird-loaderror-on-custom-ruby-gem

@nmccready
Copy link
Author

This issue has to be due to rspec version 1 being required. I cannot even get the specs of this application to run via rspec 2. So I can't use this library unless I can get both rspecs to work side by side.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

Do you have the mail gem installed? It is a dependency of Rails.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

The mail gem is being a bad Ruby citizen by having a file named VERSION not placed under its directory namespace. A workaround for now is to call

gem     'version'
require 'version'

which will force the gem to be activated.

@nmccready
Copy link
Author

I fam working on the fix. I have upgraded version to rspec 2. That is the problem. I now have all specs working with the changes. Weird thing is the gemspec should have failed on gem install as the version of rspec that version-1.0.0 needs is not there.

@nmccready
Copy link
Author

gem list | grep mail
actionmailer (3.2.13)
mail (2.5.4)

Ahh The mail gem is being a bad Ruby citizen by having a file named VERSION.....

Thats why my copy of version 1.1.0a is not working either.

@nmccready
Copy link
Author

Both gem 'version' and uninstalling mail fixes the issue. Do you want me to do a pull request for rspec upgrade?

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

Why?

The gem is effectively complete, and switching to rspec 2 would gain little if anything. It's also a development dependency, so it's not a requirement to install the gem and won't cause conflict with projects that require rspec 2 or newer.

@nmccready
Copy link
Author

If thats true then no big deal. It's just majorly confusing when your
trying to figure out what's wrong and that is what did not match up. How
did you figure out mail btw?

Nicholas McCready

Personal Email: [email protected]
Web site: http://codemonkeyseedo.blogspot.com/
Twitter: nmccready https://twitter.com/#!/nmccready

On Thu, Jun 20, 2013 at 4:31 PM, Stephen Touset [email protected]:

Why?

The gem is effectively complete, and switching to rspec 2 would gain
little if anything. It's also a development dependency, so it's not a
requirement to install the gem and won't cause conflict with projects that
require rspec 2 or newer.


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-19781087
.

@stouset
Copy link
Owner

stouset commented Jun 20, 2013

Mostly random luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants