111

I am getting the following error when I try to use gems in windows, and I also referred to this stackoverflow post and updated rubygems and rails. But nothing could solve the problem.

The following is the complete error,

    D:\>gem env
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00
.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/execjs-1.2.4.gemspec]: invalid date format in specification: "2011-08-03 00:00:
00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/temple-0.3.3.gemspec]: invalid date format in specification: "2011-08-26 00:00:
00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/guard-0.6.3.gemspec]: invalid date format in specification: "2011-09-01 00:00:0
0.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/guard-livereload-0.3.1.gemspec]: invalid date format in specification: "2011-09
-01 00:00:00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/rack-cache-1.0.3.gemspec]: invalid date format in specification: "2011-08-27 00
:00:00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00
.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/execjs-1.2.4.gemspec]: invalid date format in specification: "2011-08-03 00:00:
00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/temple-0.3.3.gemspec]: invalid date format in specification: "2011-08-26 00:00:
00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/guard-0.6.3.gemspec]: invalid date format in specification: "2011-09-01 00:00:0
0.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/guard-livereload-0.3.1.gemspec]: invalid date format in specification: "2011-09
-01 00:00:00.000000000Z"
Invalid gemspec in [D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications
/rack-cache-1.0.3.gemspec]: invalid date format in specification: "2011-08-27 00
:00:00.000000000Z"
RubyGems Environment:
  - RUBYGEMS VERSION: 1.7.2
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
  - INSTALLATION DIRECTORY: D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: D:/RailsInstaller/Ruby1.8.7/bin/ruby.exe
  - EXECUTABLE DIRECTORY: D:/RailsInstaller/Ruby1.8.7/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8
     - C:/Documents and Settings/jeygokul/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Community
  • 1
  • 1
Abhishek
  • 6,862
  • 22
  • 62
  • 79

18 Answers18

132

The ultimate solution is this:

Search "spec" files in your Ruby directory: *C:\Ruby187\lib\ruby\gems\1.8\specifications*

If a gemspec file contains something like this: s.date = %q{2011-10-13 00:00:00.000000000Z} Then delete the 00:00:00.000000000Z part: s.date = %q{2011-10-13}

After saving those gemspec files, the problem is solved.

GaborKomaromi
  • 1,321
  • 2
  • 8
  • 2
46

None of these solutions worked for me. To fix it, I removed all the content of the mentioned directory (some/path/to/specification/) then I installed the gems I need (actually, Bundler then bundle install).

Romain Tribes
  • 1,818
  • 2
  • 17
  • 21
45

I have fixed this issue by upgrading my RubyGems to 1.8.10 with

gem update --system

Edit: You can also try (as suggested by ZeissS)

gem install rubygems-update
update_rubygems
Michael
  • 1,139
  • 11
  • 11
  • 16
    I have 1.8.10 and still getting this – DGM Sep 10 '11 at 15:40
  • 3
    Try running "gem pristine [gemname]" for the gems that are causing those warnings. – Michael Sep 12 '11 at 20:50
  • 2
    This didn't work for me either - because the "gem update --system" command caused the exact same problem and "gem pristine" did nothing. I had to follow @Romain_Tribes's solution and delete the gemspec files by hand before re-running a gem update – Taryn East Oct 12 '11 at 16:04
  • In my situation, the problem occured after running "gem update" when the Ruby header files weren't in place. After making sure the header files could be found, I ran "gem update" again and everything was ok. – Roy Oct 16 '11 at 09:44
  • 4
    This isn't a very good option on ubuntu, especially for casual ruby users. – Phillip Whelan Feb 02 '12 at 00:21
  • 2
    GaborKomaromi's answer below (or one of the finds.. in the comments) works. This one doesn't. – gotofritz Apr 02 '12 at 09:46
12

In addition to running gem update --system I used gem install <gem with bad gemspec> on each of the item gem env reported as bad. This cleaned up the errors on my machine.

hughdbrown
  • 47,733
  • 20
  • 85
  • 108
TheArtTrooper
  • 1,105
  • 8
  • 19
  • 5
    You can reinstall with "gem pristine [gemname]" or do a "gem pristine --all" to reinstall the gems from the cache without re-downloading them. – Michael Sep 12 '11 at 20:47
10

As Michael said in the comment:

gem pristine --all
bradheintz
  • 3,151
  • 19
  • 24
wingfire
  • 791
  • 5
  • 9
6

Had the same problem when trying to install a GEM on Ubuntu 11.10.

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"

The above options did not work for me. gem env reported the following:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.7.2
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

So I presumed this problem was due to the fact I required a newer version of RubyGems installed.

Issuing gem update --system yeilded the following warning:

ERROR:  gem update --system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using Debian official repositories.
If you really know what you are doing, you can still update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment variable, but please remember that this is completely unsupported by Debian.

However I was finally able to update rubygems to 1.8.15 by issuing:

sudo gem install rubygems-update && update_rubygems

Everything worked after that, good luck! :)

JonnyReeves
  • 6,119
  • 2
  • 26
  • 28
  • For me on Ubuntu, it took ``sudo apt-get purge rubygems`` followed by ``sudo apt-get install rubygems`` and then installing all the gems again. Awkward, but at least it worked :P (the above did not work for me) – Jeff Tratner May 13 '12 at 14:11
3

Invalid gemspec in [/var/lib/gems/1.8/specifications/chronic-0.6.4.gemspec]: invalid date format in specification: "2011-09-09 00:00:00.000000000Z"

The simple fix to such kind of problem is to navigate to the file.. for eg.

Step 1. cd /var/lib/gems/1.8/specifications
step 2. open the file(chronic-0.6.4.gemspec) in editor of ur choice... (gedit chronic-0.6.4.gemspec)
step 3. change the s.date = %q{2011-10-13 00:00:00.000000000Z} to s.date = %q{2011-10-13}

Cheers :)

Addicted
  • 749
  • 1
  • 6
  • 19
2
cd vendor/bundle/ruby/1.9.x/specifications
sed -i 's/ 00\:00\:00.000000000Z//g' *
Anno2001
  • 1,343
  • 12
  • 17
2

I just had the same problem on my ubuntu after upgrading to 10.10. None of the above worked for me. I had to install the update_rubygems script from http://rubygems.org/pages/download and run it once. Afterwords everything worked.

ZeissS
  • 11,867
  • 4
  • 35
  • 50
2

I have fixed this issue 'invalid date formate specification' by, changing the corresponding line in D:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/specifications/tilt-1.3.3.gemspec by putting s.date =Time.now instead of s.date = "2011-08-25 00:00:00.000000000Z" The same can be use the other files too.

sanitha
  • 41
  • 1
2

I've too many gems to fix one by one, and try both update_rubygems and gem pristine --all still no luck.

So I use rvm clear gemset to remove all gems with wrong gemspec. Execute bundle install to reinstall all the gems, and Viola!

taiansu
  • 2,735
  • 2
  • 22
  • 29
1

rvm gemset clear and then bundle install worked for me!

taiansu
  • 2,735
  • 2
  • 22
  • 29
Vibhuti
  • 1,584
  • 16
  • 19
1

"gem install rubygems-update", "update_rubygems", then "gem pristine --all" is the combination that solved the problem for me after none of the previously listed ones worked.

Brian Knoblauch
  • 20,639
  • 15
  • 57
  • 92
1

Solved by running gem update --system then gem update.

David Walsh
  • 11
  • 1
  • 1
  • worked for me, i just got that error after doing gem update --system, most of them went away after gem update. for others i removed the gemspec file. – mrbrdo Feb 05 '12 at 23:07
1

The various solutions noted in these answers did not work for me. What did work was re-installing the specific versions of the offending gem's. In your case that would of looked like:

gem install tilt   -v 1.3.3
gem install execjs -v 1.2.4
gem install temple -v 0.3.3
gem install guard  -v 0.6.3
gem install guard-livereload -v 0.3.1
gem install rack-cache -v 1.0.3

I think that gem pristine xxx yyy zzz or gem pristine --all might not be going out always (ever?) to the gem repositories whereas gem install xxx -v v.r.m does.

Anyway, re-installing the offending versions of the gems worked for me, although it was tedious...

Chris Markle
  • 2,076
  • 4
  • 25
  • 46
0

If you had this error on Ubuntu 11.04 my solution was the following command lines:

$ sudo apt-get install ruby1.9.1

After doing this you will not get the date error.

andrewsi
  • 10,807
  • 132
  • 35
  • 51
0

In my case, the referenced gem versions weren't even installed. I had those gems, but not the versions who's gemspecs were causing the error. So, I just deleted each of the /path/to/specifications/offending-X.Y.ZZ.gemspec files.

Jon Garvin
  • 1,178
  • 9
  • 26
0

This is not really an answer but if somebody feels like digging more I found this gemspec spec here: http://rubygems.rubyforge.org/rubygems-update/Gem/Specification.html (scroll down to date=date() and click to show source):

@date = case date
when String then
  if %r\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
    Time.utc($1.to_i, $2.to_i, $3.to_i)
  else
    raise(Gem::InvalidSpecificationException,
          "invalid date format in specification: #{date.inspect}")
  end
when Time, Date then
  Time.utc(date.year, date.month, date.day)
else
  TODAY
end

So I guess this is the code that parses that gemspec, and it just looks like the date format that are in the files that show errors don't conform to this.

What I did was to just manually fix those offending gemspecs as suggested above (changing the dates to "yyyy-mm-dd", it works for me.

All the rubygem specs I had that had this problem also has a line

s.rubygems_version = %q{1.3.5}

So I'm guessing these are just old gems? And what's with those %q{...} anyway?

PapaFreud
  • 3,636
  • 4
  • 34
  • 45