如何在Makefile中使用rvm?

时间:2013-02-03 18:10:25

标签: ruby rvm nvm

处理此项目:https://github.com/cucumber/bool

有一个makefile来构造各种项目,我想使用RVM能够在ruby目录中的rubies之间切换,但是,当我给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,它就可以了,所以这是别的一个症状,但我不确定是什么。

2 个答案:

答案 0 :(得分:4)

当您从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"

答案 1 :(得分:0)

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

例如:

rvm wrapper 1.9.3@bool ruby bool

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

相关问题