Invalid date format specification in gemspec

Ruby on-RailsRubygems

Ruby on-Rails Problem Overview


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:

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Solution 2 - Ruby on-Rails

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).

Solution 3 - Ruby on-Rails

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

Solution 4 - Ruby on-Rails

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.

Solution 5 - Ruby on-Rails

As Michael said in the comment:

gem pristine --all

Solution 6 - Ruby on-Rails

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! :)

Solution 7 - Ruby on-Rails

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 :)

Solution 8 - Ruby on-Rails

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.

Solution 9 - Ruby on-Rails

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.

Solution 10 - Ruby on-Rails

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!

Solution 11 - Ruby on-Rails

cd vendor/bundle/ruby/1.9.x/specifications
sed -i 's/ 00\:00\:00.000000000Z//g' *

Solution 12 - Ruby on-Rails

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

Solution 13 - Ruby on-Rails

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...

Solution 14 - Ruby on-Rails

rvm gemset clear and then bundle install worked for me!

Solution 15 - Ruby on-Rails

"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.

Solution 16 - Ruby on-Rails

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.

Solution 17 - Ruby on-Rails

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?

Solution 18 - Ruby on-Rails

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAbhishekView Question on Stackoverflow
Solution 1 - Ruby on-RailsGaborKomaromiView Answer on Stackoverflow
Solution 2 - Ruby on-RailsRomain TribesView Answer on Stackoverflow
Solution 3 - Ruby on-RailsMichaelView Answer on Stackoverflow
Solution 4 - Ruby on-RailsTheArtTrooperView Answer on Stackoverflow
Solution 5 - Ruby on-RailswingfireView Answer on Stackoverflow
Solution 6 - Ruby on-RailsJonnyReevesView Answer on Stackoverflow
Solution 7 - Ruby on-RailsAddictedView Answer on Stackoverflow
Solution 8 - Ruby on-RailsZeissSView Answer on Stackoverflow
Solution 9 - Ruby on-RailssanithaView Answer on Stackoverflow
Solution 10 - Ruby on-RailstaiansuView Answer on Stackoverflow
Solution 11 - Ruby on-RailsAnno2001View Answer on Stackoverflow
Solution 12 - Ruby on-RailsDavid WalshView Answer on Stackoverflow
Solution 13 - Ruby on-RailsChris MarkleView Answer on Stackoverflow
Solution 14 - Ruby on-RailsVibhutiView Answer on Stackoverflow
Solution 15 - Ruby on-RailsBrian KnoblauchView Answer on Stackoverflow
Solution 16 - Ruby on-RailsJon GarvinView Answer on Stackoverflow
Solution 17 - Ruby on-RailsPapaFreudView Answer on Stackoverflow
Solution 18 - Ruby on-RailsmazyZedView Answer on Stackoverflow