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

NameError for version when loading gemspec in 2.0 mode #665

Closed
rkh opened this issue Apr 28, 2013 · 3 comments
Closed

NameError for version when loading gemspec in 2.0 mode #665

rkh opened this issue Apr 28, 2013 · 3 comments
Milestone

Comments

@rkh
Copy link
Contributor

@rkh rkh commented Apr 28, 2013

In Mustermann I use the common pattern of loading mustermann/version in the gemspec and then using that for the version:

lib/mustermann/version.rb:

# lib/mustermann/version.rb
module Mustermann
  VERSION ||= '0.0.1'
end

mustermann.gemspec:

$:.unshift File.expand_path("../lib", __FILE__)
require "mustermann/version"

Gem::Specification.new do |s|
  s.name                  = "mustermann"
  s.version               = Mustermann::VERSION
  ....
end

Running a bundle install in 2.0 mode on the latest nightly build, I get this:

There was a NameError while loading mustermann.gemspec:
uninitialized constant Mustermann::VERSION from
  /Users/konstantin/Workspace/mustermann/mustermann.gemspec:6:in `eval_gemspec'
@headius
Copy link
Member

@headius headius commented Apr 28, 2013

Hmm, strange. We are still sharing RubyGems pre-2.0 across 1.9.3 and 2.0 modes, I believe, but I don't see how that could cause this.

I tried this with the thread_safe gem, which does a similar require to access version, and it seemed to work ok. I even changed it to modify $: like your example.

When you say latest nightly, do you mean our src archive or our bin? Those builds do not include 2.0 stdlib yet...so perhaps something's odd there? My master build of JRuby works ok...maybe you can test that.

@rkh
Copy link
Contributor Author

@rkh rkh commented Apr 28, 2013

I use this one: http://ci.jruby.org/snapshots/master/jruby-bin-1.7.4.dev.tar.gz

Will compile from source.

@headius
Copy link
Member

@headius headius commented Apr 28, 2013

Figured this out. Ruby 1.8 defines a top-level constant VERSION, but 1.9.3 and 2.0 do not. Your VERSION ||= ... line does not define VERSION under Mustermann as a result.

Fix coming. Not sure where/whether to add a test for this, since RubySpec is not supposed to spec things that aren't there.

@headius headius closed this in 41d174f Apr 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants