Invalid gemspec because of the date format in specification

后端 未结 15 1048
悲&欢浪女
悲&欢浪女 2020-11-28 01:41

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\

相关标签:
15条回答
  • 2020-11-28 02:19

    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.

    0 讨论(0)
  • 2020-11-28 02:19

    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.

    0 讨论(0)
  • 2020-11-28 02:22

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

    0 讨论(0)
  • 2020-11-28 02:24

    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.

    0 讨论(0)
  • 2020-11-28 02:25

    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
    0 讨论(0)
  • 2020-11-28 02:26

    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.

    0 讨论(0)
提交回复
热议问题