Ruby-on-rails gemspec 中的无效日期格式规范

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7290575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:54:50  来源:igfitidea点击:

Invalid date format specification in gemspec

ruby-on-railsrubygems

提问by Abhishek

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

当我尝试在 Windows 中使用 gems 时出现以下错误,我还参考了 这篇 stackoverflow 帖子并更新了 ruby​​gems 和 rails。但没有什么能解决问题。

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/

采纳答案by Michael

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

我已经修复了这个问题升级我的RubyGems到1.8.10

gem update --system

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

编辑:您也可以尝试(如蔡司建议)

gem install rubygems-update
update_rubygems

回答by GaborKomaromi

The ultimate solution is this:

最终的解决方案是这样的:

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

在 Ruby 目录中搜索“spec”文件:* 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.000000000Zpart: s.date = %q{2011-10-13}

如果 gemspec 文件包含这样的内容: s.date = %q{2011-10-13 00:00:00.000000000Z} 然后删除00:00:00.000000000Z部分:s.date = %q{2011-10- 13}

After saving those gemspec files, the problem is solved.

保存这些 gemspec 文件后,问题就解决了。

回答by Romain Tribes

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

这些解决方案都不适合我。为了修复它,我删除了提到的目录(some/path/to/specification/)的所有内容,然后我安装了我需要的 gems(实际上,Bundler 然后是 bundle install)。

回答by TheArtTrooper

In addition to running gem update --systemI 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.

除了运行gem update --systemgem install <gem with bad gemspec>在每个项目 gem env 上使用的报告为坏。这清除了我机器上的错误。

回答by wingfire

As Michael said in the comment:

正如迈克尔在评论中所说:

gem pristine --all

回答by JonnyReeves

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

尝试在 Ubuntu 11.10 上安装 GEM 时遇到同样的问题。

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 envreported the following:

上述选项对我不起作用。gem env报告了以下内容:

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.

所以我认为这个问题是由于我需要安装较新版本的 RubyGems。

Issuing gem update --systemyeilded the following warning:

发出gem update --system以下警告:

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 rubygemsto 1.8.15 by issuing:

但是,我终于能够rubygems通过发出以下命令更新到 1.8.15:

sudo gem install rubygems-update && update_rubygems

Everything worked after that, good luck! :)

之后一切正常,祝你好运!:)

回答by Addicted

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"

[/var/lib/gems/1.8/specifications/chronic-0.6.4.gemspec] 中的 gemspec 无效:规范中的日期格式无效:“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}

步骤 1. cd /var/lib/gems/1.8/specifications
步骤 2. 在您选择的编辑器中打开文件 (chronic-0.6.4.gemspec)... (geditchronic-0.6.4.gemspec)
步骤 3。将 s.date = %q{2011-10-13 00:00:00.000000000Z} 更改为 s.date = %q{2011-10-13}

Cheers :)

干杯:)

回答by sanitha

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.

我已经解决了这个问题“无效的日期格式规范”,通过将 s.date = Time.now 而不是 s.date = "2011-08-25 00:00:00.000000000Z" 同样可以使用其他文件。

回答by ZeissS

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/downloadand run it once. Afterwords everything worked.

升级到 10.10 后,我的 ubuntu 遇到了同样的问题。以上都不适合我。我必须从http://rubygems.org/pages/download安装 update_rubygems 脚本并运行一次。事后一切正常。

回答by taiansu

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

我有太多的宝石无法一一修复,两个都尝试了update_rubygemsgem pristine --all但仍然没有运气。

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

所以我用rvm clear gemset错误的gemspec删除所有宝石。执行bundle install以重新安装所有宝石和 Viola!