NameError for version when loading gemspec in 2.0 mode #665

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

Projects

None yet

2 participants

@rkh
Contributor
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
Member
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
Contributor
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.

@rkh rkh referenced this issue in sinatra/mustermann Apr 28, 2013
Closed

not working on JRuby #2

4 of 6 tasks complete
@headius
Member
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