OS X 上的 Rubygame shebang 问题

发布于 2024-08-16 18:26:46 字数 283 浏览 3 评论 0原文

我正在玩 Rubygame。我使用 Mac Pack 安装了它,现在我有了 rsdl 可执行文件。 rsdl game.rb 工作正常,但是当我 chmod +x rb 文件时,将 shebang 添加到 rsdl (尝试了直接路径和 /usr/bin/env rsdl)并尝试执行它(./game.rb),它开始在终端和尝试打开的 rsdl 之间闪烁,最终放弃并给出总线错误。有谁知道是什么原因造成的?如果它有影响的话,我会使用 Snow Leopard (10.6.2)。

谢谢。

I'm playing around with Rubygame. I installed it with the Mac Pack, and now I have the rsdl executable. rsdl game.rb works fine, but when I chmod +x the rb file, add the shebang to rsdl (tried direct path and /usr/bin/env rsdl) and try to execute it (./game.rb), it starts to flicker between the Terminal and rsdl which is trying to open, and eventually gives up and gives a bus error. Anyone know what's causing that? I'm on Snow Leopard (10.6.2) if it makes a difference.

Thanks.

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

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

发布评论

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

评论(2

╭ゆ眷念 2024-08-23 18:26:46

我相信这是嵌入红宝石的问题。 Ruby 有一个可怕的 hack 来处理 shebang 执行,它本质上是在可执行文件名称(即 argv[0])中查找“ruby”。如果您的嵌入式 ruby​​ 可执行文件的名称中没有“ruby”,则此 hack 会失败,并且您会遇到无限循环(如果您重命名它,即使使用普通 ruby​​,也会发生这种情况)。假设这里是这种情况,您可以将 rsdl 符号链接或 mv rsdl 到 rsdl-ruby (或类似的),将 shebang 更改为 #!/usr/bin/env rsdl-ruby ,它将起作用。

I believe that this is a problem with embedded ruby. Ruby has a horrible hack to handle shebang execution which essentially it looks for "ruby" in the executable name (i.e. argv[0]). If your embedded ruby executable doesn't have "ruby" in its name, this hack fails, and you get an infinite loop (this occurs even with the stock ruby if you rename it). Assuming this is the case here, you can sym-link or mv rsdl to rsdl-ruby (or similar), change your shebang to #!/usr/bin/env rsdl-ruby and it will work.

醉生梦死 2024-08-23 18:26:46

rsdl 期望您从何处执行(即从可执行文件,而不是游戏文件)可能存在问题。我找到的方法是弹出 rsdl 可执行文件(假设它只是一个 ruby​​ 脚本),然后在里面查看。我认为了解为什么要尝试从 ruby​​ 脚本独立执行也很有用。

There may be problems with where rsdl expects you to be executing from (i.e. from the executable, rather than a game file). The way i would find out is popping open the rsdl executable (presuming that it's just a ruby script), and poking around inside. I think it'd be useful also to know why you're trying to execute standalone from your ruby script.

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