【问题标题】:How can I use rvm within a Makefile?如何在 Makefile 中使用 rvm?
【发布时间】:2013-02-03 18:10:25
【问题描述】:

正在处理这个项目:https://github.com/cucumber/bool

有一个 makefile 来构建各种项目,我想使用 RVM 能够在 ruby​​ 目录中切换 ruby​​ 目录中的东西,但是,当我发出 makefile 命令来切换 rubies 时,我得到一个严重错误

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

当然,如果我在命令行上发出rvm use 1.9.3,它就可以正常工作,所以这是其他问题的症状,但我不确定是什么。

【问题讨论】:

  • 问题和答案也适用于 nvm。能不能加个nvm标签,让nvm的人找到答案?

标签: ruby rvm nvm


【解决方案1】:

当您从 cron(或 Makefile,我希望)调用 RVM 时,设置正确的环境很重要。 Scout 团队有一篇很棒的博客文章解释了这一点:

http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production

重要的部分是确保您拥有完整的登录 shell,以便您可以访问 RVM。

/bin/bash -l -c 'the_command_inside_makefile"

【讨论】:

    【解决方案2】:

    这似乎是 an RVM wrapper script 的一个很好的用途,它可以让您生成一个 shell 脚本,将给定的 RVM ruby​​ 实例加载到该环境中,而无需使用正常的交互式 RVM 设置。

    例如:

    rvm wrapper 1.9.3@bool ruby bool
    

    ... 将创建一个名为 'bool' 的包装脚本,并选择给定的 Ruby。

    【讨论】:

      猜你喜欢
      • 2012-10-26
      • 2014-09-04
      • 2018-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      相关资源
      最近更新 更多