当使用RVM和git gems安装'bundle install'时,'gem list'无法找到gems。

4
我目前正在尝试运行"bundle install"来安装一个基于git的gem,使用Gemfile,并且使用最新版本的RVM(1.14.3)来使用ruby/其他ruby命令而不用bundler。我认为问题的原因是bundler将git gem安装到.rvm/gems/ruby-1.9.3-p194@something/bundler/gems中,而所有其他gems都安装在.rvm/gems/ruby-1.9.3-p194@something/gems中。因此,'bundle list'会显示gem,但'gem list'不会。
有什么想法吗?我真的不想使用bundle来执行所有操作。
1个回答

6

Bundler用于将gem与应用程序捆绑在一起。使用它来安装系统gems毫无意义。不幸的是,非Bundler gem系统没有直接安装基于git的gems的方法(我之前问过这个问题,请参见从git存储库直接安装gem是否可能?)。相反,您需要手动完成三个步骤:

  1. Clone the gem repo (this is assuming a github repository, but it will work for a repository hosted anywhere, just substitute the right git repo location).

    git clone git://github.com/user/gem.git
    
  2. Go to the cloned gem repo directory and build the gem (this will also check for dependencies and warn you if the install failed because of a missing dependency -- in that case just install the dependencies and try again).

    rake gem
    

    Or if that doesn't work:

    gem build gem.gemspec
    
  3. This should have created a file with a name like pkg/gem-1.2.3.gem (sometimes it will build in the pkg directory like this, sometimes it will build in the gem repo root directory). You can now install it.

    gem install pkg/gem-1.2.3.gem
    

我猜这个问题与 https://github.com/mpapis/rubygems-bundler/issues/21 有关。 - mpapis
我进行了更多的研究,并在https://dev59.com/AU7Sa4cB1Zd3GeqP7NkK中找到了评论,其中引用了http://yehudakatz.com/2010/04/12/some-of-the-problems-bundler-solves/ -- 我知道gem和bundler是不同的,但我真的想找到一种方法,使gem/bundler/gem目录成为相同的目录,这样gem就可以使用bundler安装的git gems了? - Michael Wasser

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接