如何使用 Ruby 应用程序(而非 Rails)分发冻结的二进制 gem

发布于 2024-12-05 15:59:15 字数 810 浏览 1 评论 0原文

我编写了一堆 Ruby 脚本,它们集成了不同的工具来创建“学术工作流程”。我的许多朋友都非常有兴趣尝试这一点,但是他们因安装或复制我的环境有多困难而犹豫不决。

虽然 Ruby 是 Mac OSX 内置的(我集成的应用程序都是 Mac 应用程序,所以不幸的是该解决方案只能在 Mac 上运行),但我使用了一些二进制 gem,包括 Appscript(到 AppleScript 的桥梁)。问题是这需要 XCode,而我的非程序员朋友没有安装 XCode(要求他们安装 3GB 的软件来运行几 kb 的代码似乎有点苛刻)。

我尝试通过使用 gem -i 将宝石安装到源的子目录中(在 github 上)来冻结宝石,并尝试删除本地计算机上的整个中央 gems 目录 - 它工作正常,脚本仍然运行等。但是,当我的朋友尝试运行脚本时,他们收到有关缺少库文件等的错误消息。

所以我的两个问题是: * 编译的二进制 gem 的具体程度如何?它们可以在其他 Mac OSX 版本上运行吗?与其他版本的 Ruby 一起使用吗? ETC * 我怎样才能准确地找出 Ruby gem 所依赖的二进制文件(位于中心位置),并将其与源代码一起打包(以及如何告诉 gem 在非标准位置中在哪里找到这些文件)

我知道这一点可能不是“标准程序”,我应该将其打包为宝石并让我的朋友处理问题等 - 但我真的很想解决这个问题,并且我确信一定有某种方法可以做到这一点?

多谢

I wrote a bunch of Ruby scripts that integrate different tools to create a "workflow for academics". A number of my friends have been very interested in trying this out, however they are held back by how hard it is to install or replicate my environment.

Although Ruby comes built-in with Mac OSX (the applications I integrate are all Mac applications, so unfortunately the solution can only work on Mac), I use a few binary gems, including Appscript (bridge to AppleScript). The problem is that this requires XCode, which my non-programmer friends do not have installed (and it seems a bit demanding to ask them to install 3GB of software to run a few kbs of code).

I tried freezing the gems by installing them with gem -i, into a subdirectory of the source (on github), and tried removing my entire central gems directory on my local computer - it worked fine, the scripts still ran, etc. However, when my friends tried running the scripts, they got error messages about missing library files etc.

So my two questions are:
* how specific are compiled binary gems? will they work on other Mac OSX versions? with other versions of Ruby? etc
* how can I find out exactly which binary files (located in central locations) a Ruby gem depends on, and package this with the source (and how do I tell the gem where to find these files in non-standard locations)

I know this might not be "standard procedure", and I should just package it as a gem and let my friends deal with the problems etc - but I'd really like to solve this, and I am sure there must be some way of doing this?

Thanks a lot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你在我安 2024-12-12 15:59:15

根据我的经验,编译的 gem 不可移植。它们依赖于 ruby​​ 的确切版本以及它们使用的任何其他库。更好的解决方案是让您的朋友安装 Xcode 的“命令行工具”版本 - 它只有 100-150 MB,并且包含构建 gem(和其他软件)所需的所有内容。不过,您需要一个(免费)Apple 开发者 ID 才能下载它。

https://developer.apple.com/downloads?q=Command%20Line%20Tools

In my experience, compiled gems are not portable. They're dependent on the exact version of ruby and whatever other libraries they use. A better solution would be to have your friends install the "Command Line Tools" version of Xcode -- it's only 100-150 MB and includes everything you need to build gems (and other software). You'll need a (free) Apple Developer ID to download it though.

https://developer.apple.com/downloads?q=Command%20Line%20Tools

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文