给定一个 ruby 脚本,如何找出它依赖的是什么?
我想向我的许多朋友分发一个 ruby 脚本,因为它很有用。但我怎么知道他们可能还需要安装什么?我的意思是在脚本的顶部,有这样的内容:
require 'rubygems' #
require 'activerecord' #TODO: figure out what packages this depends on
require 'activesupport' #
require 'duration' #
这让我对他们需要安装的内容有了一些了解,但上次我在朋友的计算机(Linux)上尝试时,上述每个都需要移动软件包。例如,activesupport 需要一个数据库,在这个脚本中是 sqlite3,所以我必须安装 sqlite3 和一堆 lib 甚至开发包。
是否有任何工具或方法可以收集所有依赖项的列表,以便我可以将它们包含在安装说明中?或者更好的是,有没有办法将它们打包成一个简单的安装程序?
I want to distribute a ruby script to many of my friends, because it's useful. But how do I know what else they might have to install? I mean at the top of the script, there is this:
require 'rubygems' #
require 'activerecord' #TODO: figure out what packages this depends on
require 'activesupport' #
require 'duration' #
That gives me some idea about what they need to install, but last time I tried it on a friend's computer(Linux) each of the above turned out to require move packages. For example, activesupport requires a database, which in case of this script is sqlite3, so I had to install sqlite3 and a bunch of lib and maybe even dev packages.
Is there any tool or method to gather up a list of all the dependencies so I can include them in installation instructions? Or even better, is there a way to package them into an easy installator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其作为宝石分发。 gem 允许您添加依赖项,如果依赖项有依赖项,rubygems 系统将为您安装它。
Distribute it as a gem. The gem lets you add dependencies, and if a dependency has a dependency, the rubygems system will install it for you.
如果您需要 ActiveRecord,则需要安装某种 ActiveRecord 适配器驱动程序或与数据库相对应的 gem,例如 pg、mysql、sqlite-ruby 以及设置连接到所述数据库的连接。
每当您使用当前的 rubygems 安装 gems 时,它们都会安装依赖项,只是 activerecord 有点……“有趣”?
If you are requiring activerecord, you need some sort of activerecord adapter driver installed or the gem corresponding to the db, e.g. pg, mysql, sqlite-ruby as well as a connection set up to connect to said db.
Whenever you install gems using the current rubygems they will install dependencies, its just that activerecord is a bit ... "funny" ?