Invalid gemspec because of the date format in specification
Asked Answered
S

15

89

When I include a gem that I made, thanks to Bundler (version 1.0.12), in a Gemfile and then I try to bundle or to rake just like that:

$ rake

I've got this error message:

Invalid gemspec in [/Users/zagzag/.rvm/gems/ruby-1.9.2-p180@foobar/specifications/myplugin-1.0.0.gemspec]: invalid date format in specification: "2011-04-21 00:00:00.000000000Z"

I'm on the last Mac OS X (10.6.4), with:

$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.4.0]

and:

$ gem -v
Invalid gemspec in [/Users/zagzag/.rvm/gems/ruby-1.9.2-p180@foobar/specifications/myplugin-1.0.0.gemspec]: invalid date format in specification: "2011-04-21 00:00:00.000000000Z"
1.7.2

I really don't see how to solve this issue. Thanks for any ideas.

Schwing answered 24/4, 2011 at 16:31 Comment(2)
I'm getting these errors constantly now!!! How did you fix? Two answers thus far aren't helpful...Goldsberry
That one everyone suggested, is read only file. How can I change it?Shelve
T
143

Here is the way I fix the "invalid date format in specification" error:

1.) Go to the specifications folder located at:

/usr/local/lib/ruby/gems/1.8/specifications/

2.) Find the spec that is causing the problem.

3.) Change s.date = %q{2011-05-21 00:00:00.000000000Z} to s.date = %q{2011-05-21}

That's a WIN for me! Good Luck

Tepid answered 19/8, 2011 at 17:9 Comment(6)
Worked a treat, this was doing my head in!Ballonet
Worked for me! I was on Windows XP with Ruby 1.8 installed. The em.websocket-0.3.2.gemspec was throwing this error for me when trying to use 'livereload' (livereload.com).Dibri
Worked for me too, on linux on chronic 1.6.4Eyeful
It fixes the problem for one gem, but following installed gems could cause this error again.Marrero
this is driving me mad... am I supposed to change the gemspec of 50 3rd party gems? why haven't they updated the gemspecs, a year has passed..Shorten
Worked for me on mac Lion 10.7Ats
C
60

Here is the command to fix this for all your gems:

perl -p -i -e 's/ 00:00:00.000000000Z//' ~/gems/specifications/*.gemspec

It converts s.date = %q{2011-05-21 00:00:00.000000000Z} to s.date = %q{2011-05-21} and should fix your issue.

Cadmus answered 18/11, 2011 at 10:50 Comment(3)
Nice trick to make a quick backup before doing this: git init . && git commit -am "backupInhumanity
Why trying to change the date format, it says I don't have permission to do so. What to do?Shelve
@Shelve You need to run it as sudo then. Thank you so much for this! Saved me soo much time.Dimetric
A
21

Please notice the comment from Damian Nowak. These commands do possibly mess up your rubygems!

On Ubuntu 11.10 the following solved this error:

sudo gem install rubygems-update
sudo update_rubygems     

The following may work on some systems but not on Debian based:

sudo gem update --system
Awesome answered 3/10, 2011 at 20:19 Comment(3)
Great, also works with the final version of oneiric. But this seems to clean out all manually installed gems.Ununa
Do NOT use it. It messed my rubygems. I had to rm -rf lots of stuff and revert to original rubygems from the repo. Either install rubygems totally manually or use a provided rubygems by Ubuntu. Alternatively, you may look for current rubygems in PPA. (I wish I could undo my +1 that was made about a month ago)Stinson
@DamianNowak Sorry to hear this. I added a warning to the answer!Awesome
G
14

You may upgraded your gem. To fix this you can edit the gemspecfile directly - from

2011-04-21 00:00:00.000000000Z

to

YYYY-MM-DD

Or upgrade your rails also

sudo gem update rails

It will fix the issue.

Guard answered 19/7, 2011 at 6:30 Comment(2)
@Goldsberry it will be under specifications directory this is my specifications directory path - /home/sayuj/.rvm/gems/ruby-1.9.2-p180/specifications/Guard
+1 for updating rails - it does fix the issue, though it throws the same warnings in the beginning, it installs correctly and the problem no longer occurs.Flybynight
H
6

Don't specify the time... just the date. 2011-04-21 should work fine.

Heredes answered 26/4, 2011 at 0:43 Comment(2)
Gem::Specification.new do |s| s.name = "myplugin" s.version = "1.0.0" s.platform = Gem::Platform::RUBY s.authors = ["..."] s.email = ["..."] s.homepage = "http://..." s.summary = %q{...} s.description = %q{...} s.rubyforge_project = "myplugin" s.files = git ls-files.split("\n") s.test_files = git ls-files -- {test,spec,features}/*.split("\n") s.require_paths = ["lib"] endSchwing
Thanks for your answer. I agree with you, but I don't used any date or datetime in the myplugin.gemspec file. The Gem was auto-generated by Bundler. I think this issue could be because of Bundler or RVM... It's strange.Schwing
C
4

Had the same issue. It looks like a bug in rubygems. Here's the commit that fixed it: https://github.com/rubygems/rubygems/commit/21cccd55b823848c5e941093a615b0fdd6cd8bc7

You need to update rubygems and bundler to the latest versions. If you are still having issues after that, then you may need to remove and then reinstall any gems that are giving you problems.

Convene answered 12/8, 2011 at 14:52 Comment(1)
Well, except Redmine uses its own 2.3.11 version of Rails, Rails 2.3.11 fails with RubyGems >= 1.7.0, and the commit you mention is dated May 19th, 2011, which is post-1.7.0 (April 1st, 2011). Guess in that case you need to edit the spec files.Mucin
B
3

This is more of a comment to ben hall's answer, but i dont have that privilege yet it seems

gem updates didn't seem to work, im thinking it can't even load the gem because of the bad date format. manually changing the dates was too frustrating to go one by one, so a grep:

grep -i *.gemspec -e '.*s\.date.*=.*%q{\(....-..-..\) \(.*Z\)}

And for sed:

sed -i -e 's/\(.*\)s\.date.*=.*%q{\(....-..-..\) \(.*Z\)}/\1s.date = %q\{\2}/p' ./*.gemspec

And at your own risks!! I'm still a sed newbie, but it worked for me ;)

Brendabrendan answered 22/9, 2011 at 19:32 Comment(0)
T
2

On my slicehost server the specifications folder was located in a different spot. Here is the path:

/usr/lib/ruby/gems/1.8/specifications

The error provided should give the path to the specifications folder.

Tepid answered 6/9, 2011 at 17:49 Comment(0)
A
2

The shotgun approach: Uninstall all gems and rerun bundler.

  1. gem list --no-version | xargs gem uninstall -aIx
  2. rm -i `rvm gemdir`/specifications/*.gemspec
  3. gem update --system
  4. gem install bundler
  5. bundle install
Accounting answered 26/10, 2011 at 15:58 Comment(1)
If you use a .rvmrc file, then be careful running line 2 because gemdir may produce extra output.Accounting
T
1

(Until the bug fix gets into a stable release of Rubygems) I solved it by reinstalling the same version of any warning-generating gems using the --version switch of the gem command.

Theft answered 29/9, 2011 at 19:4 Comment(0)
W
1

As Ben Hall said, you must fix the gemspec file that may change for system to system. To know what file is see what file is tell in the error report, for example:

Invalid gemspec in [/var/lib/gems/1.8/specifications/svn2git-2.1.2.gemspec]: invalid date format in specification: "2011-12-28 00:00:00.000000000Z"

In this example you must edit "/var/lib/gems/1.8/specifications/svn2git-2.1.2.gemspec" file and change "2011-12-28 00:00:00.000000000Z" for "2011-12-28" in s.date option.

Winthorpe answered 25/1, 2012 at 12:34 Comment(0)
C
1

Had this problem still now. Updating Rubygems solved it fine:

gem update --system
Cruciferous answered 24/1, 2013 at 8:46 Comment(0)
C
0

This is my environment:

RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.1.0]
- INSTALLATION DIRECTORY: /Users/user/.rvm/gems/ruby-1.9.2-p290@app
- RUBY EXECUTABLE: /Users/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/user/.rvm/gems/ruby-1.9.2-p290@app/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - x86_64-darwin-11
- GEM PATHS:
   - /Users/user/.rvm/gems/ruby-1.9.2-p290@app
   - /Users/user/.rvm/gems/ruby-1.9.2-p290@global
- GEM CONFIGURATION:
   - :update_sources => true
   - :verbose => true
   - :benchmark => false
   - :backtrace => false
   - :bulk_threshold => 1000
- REMOTE SOURCES:
   - http://rubygems.org/

I finally managed to find a cause / a way to prevent these errors on my system. I just revert to cucumber and cucumber-rails version 1.0.2. Using the latest versions was doing this...

Cid answered 13/9, 2011 at 12:36 Comment(0)
W
0

Even if you install the latest version of a gem with a valid date format, make sure to gem cleanup GEMNAME afterwards, since gem will still complain about the specifications for the older libraries.

Wainwright answered 28/11, 2011 at 22:13 Comment(0)
S
0

Reinstalling your gems can be the solution in many of these slightly different machine states.

In my case:

cd /Library/Ruby/Gems/1.8/specifications &&
sudo rm -rf *

In my case, the other more creative solutions failed.

My issue was getting Invalid gemspec when trying to use cocoapods. I ran gem install cocoapods again and everything was rosy.

Schopenhauerism answered 13/2, 2013 at 22:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.