Invalid gemspec because of the date format in specification

I faced this issue several times, and it appeared again yesterday. Here are the solution for this error.

Invalid gemspec in [/opt/ruby/lib/ruby/gems/1.8/specifications/uniform_notifier-1.0.2.gemspec]: Illformed requirement ["# 3.0"]
Invalid gemspec in [/opt/ruby/lib/ruby/gems/1.8/specifications/uniform_notifier-1.0.2.gemspec]: Illformed requirement ["# 3.0"]

Basically this is an compatible issue, rubygems that with a recent version uses a different s.date format. To fix this issue, we only need to remove additional chars from gemspec files as this,
Issued string: “s.date = %q{2012-07-21 00:00:00.000000000Z}”
Correct string: “s.date = %q{2012-07-21}”

This can be done by sed,

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

Or you can reinstall all the gems with a correct rubygems. To change the version of your rubygems, you can refer to
Upgrade and downgrade RubyGems.

When you updated rubygems , you can reinstall all the gems like this:

gem list | cut -d" " -f1 | xargs sudo gem uninstall -aIx
sudo rm -f /opt/ruby/lib/ruby/gems/1.8/specifications/*.gemspec
sudo gem install bundler
sudo bundle install

Good luck!

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *