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

'rake gemspec:validate' always fails #81

Closed
SFEley opened this issue Jan 25, 2010 · 26 comments
Closed

'rake gemspec:validate' always fails #81

SFEley opened this issue Jan 25, 2010 · 26 comments

Comments

@SFEley
Copy link

SFEley commented Jan 25, 2010

I've seen this today in more than one of my current projects, but just to make sure it wasn't my fault, I tried it from scratch:

[12:53][~/projects]$ jeweler dummy
    create  .gitignore
    # etc.
Jeweler has prepared your gem in dummy
[12:53][~/projects]$ cd dummy

A version file has to exist before a .gemspec can be validated:

[12:53][~/projects/dummy(master)]$ rake version:write
(in /Users/steve/projects/dummy)
Updated version: 0.0.0

I try to validate the gemspec:

[12:54][~/projects/dummy(master)]$ rake gemspec:validate
(in /Users/steve/projects/dummy)
dummy.gemspec is invalid. See the backtrace for more details.
rake aborted!
undefined method `prerelease?' for nil:NilClass

(See full trace by running task with --trace)

I run the task with --trace:

[12:54][~/projects/dummy(master)]$ rake gemspec:validate --trace
(in /Users/steve/projects/dummy)
** Invoke gemspec:validate (first_time)
** Invoke version_required (first_time)
** Execute version_required
** Execute gemspec:validate
dummy.gemspec is invalid. See the backtrace for more details.
rake aborted!
undefined method `prerelease?' for nil:NilClass
/opt/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:1317:in `block in <class:Specification>'
dummy.gemspec:9:in `block (2 levels) in parse'
/opt/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:421:in `initialize'
dummy.gemspec:7:in `new'
dummy.gemspec:7:in `block in parse'
/opt/local/lib/ruby/gems/1.9.1/gems/jeweler-1.4.0/lib/jeweler/gemspec_helper.rb:56:in `eval'
/opt/local/lib/ruby/gems/1.9.1/gems/jeweler-1.4.0/lib/jeweler/gemspec_helper.rb:56:in `block in parse'

I've hunted this down to a failure on assigning the version string in the "virtual" (non-file-based) gemspec that gets generated and passed to the gemspec_helper.parse method. It looks like the ValidateGemspec command class just isn't doing the same work of adding versions that the WriteGemspec command class is. (The real gemspec used to build the gem works fine.)

I don't understand the Jeweler infrastructure well enough to figure out which version addition code needs to be put in, however, or when; so I'm simply reporting the issue instead of trying to fork and fix it.

@technicalpickles
Copy link
Owner

ValidateGemspec is used to validate an on-disk gemspec is valid. If you haven't created it yet, it doesn't have anything to validate, and thus fails.

I've fixed the task to give an error message about it missing if it doesn't exist in 6410b48

@hotgazpacho
Copy link

I'm seeing this error now as well. The gemspec exists, as I've just run rake gemspec:generate. Something is passing nil as the version number when it should be passing the string from the .gemspec

@hotgazpacho
Copy link

I've added a puts #{data} in the Jeweler::GemSpec::parse method, and the output includes nil for the version number. See http://gist.github.com/407271

@masterkain
Copy link

I'm seeing this too and can confirm that this problem is still present.

@nickhoffman
Copy link

This is happening to me with Jeweler 1.4.0 . Here's what I'm doing:
$ rake version:bump:minor
$ rake gemspec:generate
$ rake gemspec:validate

@h3rald
Copy link

h3rald commented Aug 9, 2010

This is happening to me too every time I run rake gemspec:validate.

See: http://github.com/h3rald/glyph/issues#issue/151

@activestylus
Copy link

I too faced this problem - it happens when you rely on VERSION.yml. I deleted that file
and simply set the version in my RakeFile:

gem.version = "1.0.1"

Generated once again and BOOM, the gemspec validated just fine

technicalpickles, to recreate this issue make sure you haven NOT specified the version in Rakefile then do the following:

rake version:write
rake gemspec:generate
rake gemspec:validate --trace

Hopefully you will be able to figure it out. For now I'm perfectly happy setting the version by hand

@rjpbonnal
Copy link

@activestylus: your solutions works.
I can confirm the issue.

@ahamid
Copy link

ahamid commented Nov 20, 2010

biting me too

@ammar
Copy link

ammar commented Nov 20, 2010

Same problem here. Adding version in Rakefile passes validation, but release doesn't work.

This issue is closed. Maybe that's why nothing has happened in 7 months?

@technicalpickles
Copy link
Owner

For anyone still having this problem, could you point me at the repo using it? I was having difficulties reproducing it, so it was a bit tricky to fix.

Also, you could try updating to 1.5.1 to see if that helps.

@ammar
Copy link

ammar commented Nov 22, 2010

Out of frustration, and a desire to learn the underlying plumbing, I switched to using a gem spec directly. However, I can point you at the last commit in which I was using jeweler:

https://github.com/ammar/regexp_parser/tree/e365450e10df2975685375b330bb4201b523818e

Please note that I had started work on this project before considering jeweler, and thus had my own Rakefile. In addition to the missing version, I now know, after working with gem spec directly, that I was also missing rubyforge_project.

I really like the auto-commits and tagging, and plan on revisiting jeweler very soon for the same project.

Thanks.

@ahamid
Copy link

ahamid commented Nov 22, 2010

FWIW i have noticed problems with the '0.0.0' version, or at least with "prerelease" gems (e.g. "0.0.0.snapshot". So I switched to "0.0.1.snapshot" and i think that made it go away.

@ahamid
Copy link

ahamid commented Nov 22, 2010

1.5.1 does not fix the problem. actually any prerelease suffix will cause this problem

@nickhoffman
Copy link

@technicalpickles Using Jeweler 1.5.1, I created an empty gem and confirmed that this bug's still alive. Feel free to take a look at https://github.com/nickhoffman/jeweler-issue-81 .

When I try to validate the gemspec, here's what happens:
# rake gemspec:validate --trace
(in /Users/nick.hoffman/src/jeweler-issue-81)
** Invoke gemspec:validate (first_time)
** Invoke gemspec_required (first_time)
** Execute gemspec_required
** Execute gemspec:validate
jeweler-issue-81.gemspec is invalid. See the backtrace for more details.
rake aborted!
undefined method prerelease?' for nil:NilClass /Users/nick.hoffman/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/specification.rb:1377:inblock in class:Specification'
jeweler-issue-81.gemspec:9:in block (2 levels) in parse' /Users/nick.hoffman/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/specification.rb:425:ininitialize'
jeweler-issue-81.gemspec:7:in new' jeweler-issue-81.gemspec:7:inblock in parse'
/Users/nick.hoffman/.rvm/gems/ruby-1.9.2-p0/gems/jeweler-1.5.1/lib/jeweler/gemspec_helper.rb:53:in eval' /Users/nick.hoffman/.rvm/gems/ruby-1.9.2-p0/gems/jeweler-1.5.1/lib/jeweler/gemspec_helper.rb:53:inblock in parse'
#

@bjones
Copy link

bjones commented Dec 25, 2010

The fix is simple for the user of jeweler, do the gem.version thing mentioned above.

In your Rakefile, put this...
version = File.exist?('VERSION') ? File.read('VERSION') : ""
...
gem.version = version

@ssoroka
Copy link

ssoroka commented Apr 14, 2011

still have this problem with jeweler 1.5.2 and rubygems 1.7.2. Fixed it by adding this to my Rakefile:

gem.version = File.read('VERSION').chomp

@behrangsa
Copy link

still have this problem with jeweler 1.5.2 and rubygems 1.7.2. Fixed it by adding this to my Rakefile:

gem.version = File.read('VERSION').chomp

This disappears the version:bump tasks for me.

@rgarner
Copy link

rgarner commented Jul 6, 2011

Same behaviour as @behrangsa, Jeweler 1.5.2 (also just tested in 1.6.3) here. This started happening relatively recently, it hasn't always been a problem.

Happens to https://github.com/rgarner/semantically-taggable

@technicalpickles
Copy link
Owner

This seems pretty reclusive, and I haven't been able to reproduce. For anyone chiming in (and those that already have), can you include the following infos, please?

  • a repository exhibiting this
  • ruby --version
  • gem --version
  • gem list jeweler
  • bundle show (if using bundler, of course)

@behrangsa it's intentional that setting gem.version makes the version tasks go away. Generally when you use this, you are keeping it in some constant, so it wouldn't necessarily know how to bump it if you set it this way.

@rgarner wasn't able to reproduce with your repo :( I tested with ruby 1.9.2 and a few variations of rubygems.

There is some good news though. I was able to reproduce on a blank repo. I recently upgraded rubygems all the way up to 1.8.5. I suspect this started coming up between 1.3.7 and 1.8.5.

@technicalpickles
Copy link
Owner

I was able to track down where this is happening in the code, but... not so much why :(

It's coming up when the gemspec on disk is read into memory and parsed for saneness, ie right here. For whatever reason, when the version is getting set from the gemspec on disk, the version is nil, which is where the undefined methodprerelease?' for nil:NilClasscomes in. You can clearly sees.version` is not in in the gemspec.

Another boggling piece of this is that when you do rake gemspec, this does a write then a validate, and this works fine. If you run rake gemspec:validate directly, it fails.

I checked on @ahamid's suggestion about prereleases, but it seems to be happening regardless of the combination of 0.0.0 and prereleases


That all said, I'm kind of considering ditching the way validation happens currently. But first, a history lesson:

Back when GitHub did rubygems hosting, one of the biggest pain points was having the gem fail to build due to invalid gemspecs, and there were plenty of interesting ways of accidentally having that happen. One of the earliest goals of jeweler was to make it easier to cope with this, and so it did the same eval that GitHub did, and it was great.

Fast forward to today, and well, GitHub doesn't host rubygems anymore, and for rubygems.org, you end up building them yourself. If there's a problem building it, you'll see it pretty quickly :)

Given all that, removing this particular validation seems like a good idea. I'll try to get that out next jeweler hacksession I sit down for, and will likely release it as 1.7.x.

@rgarner
Copy link

rgarner commented Jul 7, 2011

Hi Josh,

I think your appraisal of rubygems as the culprit is spot on - now that you mention it I'd just upgraded from 1.3.7 to 1.8.5 myself when this started happening (this was tested with 1.9.2-p0). And please accept my apologies, I'd already checked in the gem.version = File.read('VERSION').chomp workaround when I linked to my repo. git reset b1455d9ce808f55568243197e8a0596c490191ef and you should see the same behaviour as with a blank repo.

@joseph-ravenwolfe
Copy link

I do not agree with rgarner. I am using Rubygems 1.8.11 and I have run into this issue.

@sporto
Copy link

sporto commented May 10, 2013

I have the same issue, using:
rubygem 1.8.25
jeweler 1.8.4

@muratayusuke
Copy link
Collaborator

I've checked this thread and source code, then I may find something.

The main problem is the difference between gemspec and gemspec:validate.
gemspec:validate depends on gemspec:generate about gemspec_helper. gemspec:generate set version string in gemspec_helper.spec.version and gemspec:validate uses this variable. It seems to be the reason of different behavior.

Another small problem is jeweler command doesn't insert gem.version into default Rakefile.

I think resolving each single problem will fix this issue, but I'll try to fix both of them when I have time.

@weshatheleopard
Copy link
Collaborator

Same issue. Jeweler 2.0.1.

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