简体   繁体   English

工厂女孩的“捆绑安装”期间“无效的gemspec”消息(rails 3.1和ruby 1.9.2p290)

[英]“Invalid gemspec” messages during “bundle install” of factory girl (rails 3.1 and ruby 1.9.2p290)

Note: 注意:
I asked this question when I got unexpected messages when doing bundle install with the factory_girl gem using Ubuntu 11.10. 当我使用Ubuntu 11.10使用factory_girl gem进行bundle install时收到意外消息时,我问了这个问题。 Being a noob I had ... and still have ... no idea what was going on. 作为一个菜鸟,我......并且仍然......不知道发生了什么。 The update below attempts to outline what I did to eventually get rid of the messages. 下面的更新试图概述我最终消除了这些消息所做的工作。 I am leaving the question around with a slightly more pertinent title line in case it might be of use to someone else. 我正在提出一个稍微更相关的标题行,以防它可能对其他人有用。

I look at Factory Girl's README.md and I see: 我看看Factory Girl的README.md ,我看到:

Install
      gem install factory_girl
    or add the following line to Gemfile:
      gem 'factory_girl'
    and run bundle install from your shell.

    Supported Ruby versions
    The Factory Girl 3.x series supports Ruby 1.9.x.
    For older versions of Ruby, please use the Factory Girl 2.x series.

Since I am currently using 因为我目前正在使用
Rails 3.1.0 and Rails 3.1.0
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

I add gem 'factory_girl' to my Gemfile and do bundle update . 我将gem'factory_girl gem 'factory_girl'添加到我的Gemfile中并进行bundle update

But then continuing on I open the Getting Started.md file and read 但接下来我打开Getting Started.md文件并阅读

Update Your Gemfile
    If you're using Rails, you'll need to change
    the required version of factory_girl_rails:
      gem "factory_girl_rails", "~> 2.0"
    If you're not using Rails, you'll just have to
    change the required version of factory_girl:
      gem "factory_girl", "~> 3.0"
    Once your Gemfile is updated, you'll want to update your bundle.

OK, fine. 好的。 I remove gem 'factory_girl' from my Gemfile and instead add 我从我的Gemfile中删除了gem'factory_girl gem 'factory_girl' ,而是添加了
gem "factory_girl_rails", "~> 2.0" . gem "factory_girl_rails", "~> 2.0"
I then try bundle update once again. 然后我再次尝试bundle update This time, no joy. 这一次,没有快乐。

$bundle install
    Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/
      factory_girl_rails-2.0.0.gemspec]: Illformed requirement
      ["# 3.0.7"]
    Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/
      factory_girl_rails-2.0.0.gemspec]: Illformed requirement 
      ["# 3.0.7"]
    Fetching source index for http://rubygems.org/
    Using rake (0.9.2.2) 
    Using ZenTest (4.7.0) 
    ... a bunch of "Using" lines omitted for brevity ...
    Using deepopenstruct (0.1.2) 
    Using factory_girl (3.0.0) 
    Installing factory_girl_rails (2.0.0) Invalid gemspec in
      [/usr/local/lib/ruby/gems/1.9.1/specifications/factory_girl_rails-2.0.0.gemspec]:
      Illformed requirement ["# 3.0.7"]  
    Using haml (3.1.4) 
    Using jquery-rails (1.0.19) 
    ... a bunch of "Using" lines omitted for brevity ...
    Using uglifier (1.2.4) 
    Your bundle is complete! Use `bundle show [gemname]` to see where a
      bundled gem is installed.

So now I'm wondering (1) why following the instructions in the READMEs have apparently not worked and (2) what should I do to my Gemfile in order to get Factory Girl smiling and productive? 所以现在我想知道(1)为什么遵循自述文件中的说明显然不起作用,以及(2)我应该怎么做我的Gemfile才能让Factory Girl微笑和富有成效?


Update 更新

While getting error messages which I do not understand is frustrating, getting rid of them but not really being sure what I did to, err, "fix" things is also less special. 虽然获取我不理解的错误消息令人沮丧,但摆脱它们但不确定我做了什么 ,错误,“修复”事情也不那么特别。 Oh, well. 那好吧。

In all honesty, though I have been using bundle I had no idea what the difference was between gem , rvm , and bundle nor did I really understand what each command is supposed to do. rvm ,虽然我一直在使用bundle,但我不知道gemrvmbundle之间的区别是什么,我也不明白每个命令应该做什么。 I think this blog entry I found via Google helped somewhat with that: 我认为通过Google发现的这篇博文对此有所帮助:
RVM and Bundler in Five Seconds RVM和Bundler五秒钟

Thinking that rvm and bundle are supposed to automate the management of a group of gems while gem just manages gems, I looked at the gem commands. 考虑到rvm和bundle应该自动管理一组gem,而gem只管理gems,我查看了gem命令。

I tried gem check which IIRC did nothing. 我试过gem check哪个IIRC什么也没做。 I then tried gem cleanup which came back with a long list of gems it wanted to uninstall. 然后我尝试了gem cleanup ,它带来了一大堆想要卸载的宝石。 Trusting that I could (probably) get back to where I needed to be by using bundle install , I let it do the uninstalls. 相信我可以(可能)通过使用bundle install回到我需要的位置,我让它进行卸载。 (Though I had to use sudo gem cleanup because I lacked write permission to some of the directories involved). (虽然我不得不使用sudo gem cleanup因为我缺少对所涉及的一些目录的写入权限)。

After doing this gem check and gem cleanup came back clean. 做完这个gem checkgem cleanup回来后干净。 However, bundle check returned: 但是, bundle check返回:

The following gems are missing
 * activesupport (3.1.0)
 * activemodel (3.1.0)
 * rack-cache (1.0.3)
 * actionpack (3.1.0)
Install missing gems with `bundle install`

So I did both bundle install followed by (why not?) bundle update . 所以我做了bundle install然后(为什么不呢?) bundle update This installed the gems listed above with no problems. 这安装了上面列出的宝石没有问题。 In particular, this time I did not get the Invalid gemspec or any other error messages. 特别是,这一次我没有得到Invalid gemspec或任何其他错误消息。 (Hurrah!) (欢呼!)

Of course, bundle update did nothing as, frankly, I was expecting it to do. 当然, bundle update没有任何作用,坦率地说,我期待它可以做到。

So while I'm still not sure what happened, the original reason for my question has been kinda, sorta solved. 因此,虽然我仍然不确定发生了什么,但我的问题的原因有点,有点解决了。

I'll leave this question unanswered for a week or so to see if anyone else wants to contribute any comments. 我会在一个星期左右的时间内回答这个问题,看看是否有其他人想要提出任何意见。 After that if no one else provides a more informative answer, I guess I'll just "answer" this question myself to close it out. 在此之后,如果没有其他人提供更具信息性的答案,我想我会自己“回答”这个问题,然后将其关闭。

Thanks to all who helped nudge me towards a cleaner set of gems. 感谢所有帮助我推动更清洁宝石的人。

I ran into pretty much the same problem when trying to install the factory_girl_rails gem and was able to resolve it by removing the offending specifications file and then running 我在尝试安装factory_girl_rails gem时遇到了同样的问题,并且能够通过删除有问题的规范文件然后运行来解决它

gem update --system gem update --system

followed by 其次是

bundle install 捆绑安装

There is apparently some errors generated in the gemspec. gemspec中显然存在一些错误。 Open it and remove the shitty bits! 打开它,删除糟糕的位!

personally I did it using vim like so: 我个人用vim这样做:

vim ~/.rvm/gems/ruby-1.8.7-p357/specifications/factory_girl_rails-1.7.0.gemspec
:%s/".*YAML.*\ /"/
:wq

then re bundle 然后重新捆绑

and the problem should be solved ! 问题应该解决!

With ruby 1.8.7 and factory_girl_rails you can pin the version of factory_girl to 2.6 and let bundler do the rest. 使用ruby 1.8.7和factory_girl_rails你可以将factory_girl的版本固定为2.6,然后让bundler完成剩下的工作。

gem 'factory_girl', '~> 2.6'
gem "factory_girl_rails"

Worked for me. 为我工作。

There is no point that I can see in keeping this question open any longer. 我不能再看到这个问题再开放了。 While I never did clearly understand why I was getting Invalid gemspec , the steps which are listed in my update to my question "solved" that "problem". 虽然我从来没有清楚地理解为什么我得到Invalid gemspec ,我的问题更新中列出的步骤“解决”了“问题”。

It would be nice if there was a way to simply close a question as " An answer is no longer a priority for me " or even simply " I've moved on ". 如果有一种方法可以简单地将问题关闭为“ 答案不再是我的优先事项 ”,或者甚至只是“ 我已经继续前进 ”,那就太好了。 But there isn't. 但事实并非如此。 This "answer" will at least take this question off the list of things to still be looked at. 这个“答案”至少会将这个问题从待查看的事物列表中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM