ruby-on-rails - 工厂女孩 "Invalid gemspec"期间的 "bundle install"消息(rails 3.1 和 ruby​​ 1.9.2p290)

标签 ruby-on-rails ruby-on-rails-3 rubygems factory-bot

注意:
当我在做 bundle install 时收到意外消息时,我问了这个问题与 factory_girl使用 Ubuntu 11.10 的 gem。作为一个菜鸟,我曾经……并且仍然……不知道发生了什么。下面的更新试图概述我为最终摆脱这些消息所做的事情。我将问题留下一个稍微相关的标题行,以防对其他人有用。

我看工厂女孩的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.

由于我目前正在使用
Rails 3.1.0
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

我添加gem 'factory_girl'到我的 Gemfile 并执行 bundle update .

但随后我继续打开 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.

好的,好的。我删除gem 'factory_girl'从我的 Gemfile 中添加
gem "factory_girl_rails", "~> 2.0" .
然后我尝试 bundle update再次。这一次,没有喜悦。

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

所以现在我想知道(1)为什么按照自述文件中的说明显然不起作用以及(2)我应该对我的 Gemfile 做什么才能让 Factory Girl 微笑并提高工作效率?

<小时/>

更新

虽然收到我不理解的错误消息令人沮丧,但摆脱它们但并不确定我做了什么,呃,“修复”事情也没什么特别的。哦,好吧。

老实说,虽然我一直在使用 bundle ,但我不知道 gem 之间有什么区别。 , rvm ,和bundle我也不明白每个命令应该做什么。我认为我通过 Google 找到的这篇博客文章对此有所帮助:
RVM and Bundler in Five Seconds

认为rvm和bundle应该自动管理一组gems,而gem只是管理 gem ,我查看了 gem 命令。

我试过gem check IIRC什么也没做。然后我尝试了 gem cleanup它返回了一长串想要卸载的 gem。相信我可以(可能)通过使用 bundle install 回到我需要的地方,我让它进行卸载。 (尽管我必须使用sudo gem cleanup,因为我缺乏对某些涉及的目录的写权限)。

这样做之后gem checkgem cleanup干净地回来了。然而,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`

所以我都做了bundle install其次是(为什么不?)bundle update 。这安装了上面列出的 gem,没有任何问题。特别是,这次我没有得到 Invalid gemspec或任何其他错误消息。 (万岁!)

当然,bundle update坦率地说,没有做任何事情,正如我所期望的那样。

所以,虽然我仍然不确定发生了什么,但我问题的最初原因已经有点解决了。

我将在一周左右的时间内不回答这个问题,看看是否还有其他人愿意发表评论。之后,如果没有其他人提供更多信息的答案,我想我会自己“回答”这个问题以结束它。

感谢所有帮助我走向更清晰的 gem 的人。

最佳答案

在尝试安装 factory_girl_rails gem 时,我遇到了几乎相同的问题,并且能够通过删除有问题的规范文件然后运行来解决它

gem update --system

其次是

bundle install

关于ruby-on-rails - 工厂女孩 "Invalid gemspec"期间的 "bundle install"消息(rails 3.1 和 ruby​​ 1.9.2p290),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9928514/

相关文章:

ruby-on-rails - 如何删除 Permission denied @ rb_sysopen - Gem 安装错误?

ruby-on-rails - Rails,gemfile 中的许多 gem 会减慢网站的速度吗?

ruby-on-rails - Ruby on Rails 中的用户角色

ruby-on-rails - 将 Date 对象转换为 TimeWithZone

ruby-on-rails - 如何从 ActiveAdmin 调用 Controller 操作?

ruby-on-rails - 推荐使用 Gem 在 Ruby on Rails 中构建一个非常简单的浏览器游戏

Javascript 在 Rails 应用程序中包含标签的最佳实践

ruby-on-rails - 在 Rails 3 中弃用的继承资源......响应者

javascript - 日历时间表

javascript - 找不到在 app/assets/javascript 中创建的 CoffeeScript 函数