检索所有已安装 gem 的来源
我正在将我的所有项目切换为使用相当出色的 RVM 和捆绑器。在其中之一上,我想基本上镜像托管应用程序的服务器上的 gem 环境。
为了做到这一点,我做了以下操作:
- 进入服务器
-did“gem list”,它给了我一个很大的 gem 列表,例如
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
- 将其复制到本地项目文件夹中的新 Gemfile 中,
- 做了一些查找和替换以进行更改格式转换为 Gemfile 友好格式,
- 将我知道的 gem 源添加到 Gemfile 的顶部,
- 并进行了“捆绑安装” -FAIL
发生失败是因为总是有一些 gem 因为未指定源而找不到。所以,我想知道的是
a) 在服务器上,有没有办法查询已安装的 gems 以获取每个宝石的安装源列表?
b) 这是一个好方法吗?以某种方式导出服务器上的 gem,并将它们直接安装在我的新 gemset 中,而不是尝试从远程源安装它们,会更好吗?或者其他什么?
感谢任何建议 - 最大
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
冒着陈述显而易见的风险,Gemfile 中需要一些 gem,但在指定的源中不可用。在文件的顶部应该有一个或多个来源:
您可以尝试添加
如果捆绑程序仍然找不到gem,您可以尝试谷歌搜索gem名称 - 看看它是否被重命名或其他什么。不过,如果它不在外面,我会感到惊讶,除非它是你在本地手卷的。如果您真的陷入困境,您可以从服务器复制 gem 并将其包含在项目的供应商/gems 目录中,在这种情况下,您需要在 Gemfile 中指定其路径(请参阅捆绑器手册)。
请记住,您不必指定所有 gem 的依赖项;需要rails将自动需要activerecord,activeresource等。如果您愿意,您可以指定它们,但是如果您升级依赖项gem,那么如果它们不匹配,则必须编辑依赖项的版本。
为了回答你原来的问题,我不相信有一种方法可以追踪机器上安装的宝石的确切来源。
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:
You could try adding
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.
您可以使用 gem list -d 并至少列出主页
You can use
gem list -d
and will list, at least the homepages