开发者

Retrieve sources for all installed gems

I'm in the process of switching all my projects over to using the rather wonderful rvm and bundler. On one of them, i want to basically mirror the gem 开发者_运维百科environment on the server which hosts the app.

In order to do this, i did the following:

  • went onto the server

-did "gem list" which gave me a big list of gems like

actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
amatch (0.2.3)
archive-tar-minitar (0.5.2)
etc
  • copied this into a new Gemfile in my local project folder
  • did a bit of find and replace to change the format into the Gemfile-friendly format
  • added the gem sources that i knew about to the top of the Gemfile
  • did "bundle install" -FAIL

The fail is happening because there's always some gem that can't be found because the source isn't specified. So, what i was wondering was

a) on the server, is there any way to query the installed gems to get a list of the sources where each was installed from?

b) is this even a good way to do it? Would it be better to somehow export the gems that are on the server, and install them directly in my new gemset, rather than try to install them from remote sources? Or something else?

grateful for any advice - max


At the risk of stating the obvious, there are some gems being required in the Gemfile that are not available in the sources specified. At the top of the file there should be one or more sources:

source 'http://rubygems.org'

You could try adding

source "http://gems.rubyforge.org"

If bundler still can't find a gem, you could try googling the gem name - see if its been renamed or something. I'd be surprised if it wasn't out there, though, unless it was one you handrolled locally. If you're really stuck, you could copy the gem off the server and include it in the vendor/gems directory of your project, in which case you would need to specify its path in the Gemfile (see the bundler manual for that).

Bear in mind that you don't have to specify all your gem's dependencies; requiring rails will automatically require activerecord, activeresource etc. You can specify them if you like, but if you upgrade a dependent gem then you will have to edit the versions of the dependencies if they don't match.

To answer your original question, I don't believe there is a way of tracing the exact source of the gems installed on a machine.


You can use gem list -d and will list, at least the homepages

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜