shell脚本中的cd命令是否加载目标目录中的rvmrc?
当你在projectx中给出类似的内容时,
一个.rvmrc文件指定ruby 1.9.2并且我的系统上有两个rubies(ree-1.8.7和ruby1.9.2),
#!/bin/bash
cd applications/projectx
which ruby
ruby -v
最后两行输出ree-1.8.7及其路径这不是我打算使用的。
when you have something like..
given inside projectx an .rvmrc file specifying ruby 1.9.2 and having two rubies on my system (ree-1.8.7 and ruby1.9.2)
#!/bin/bash
cd applications/projectx
which ruby
ruby -v
the last two lines output ree-1.8.7 and its path which was not I intended to use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,
Rvm 确实定义了一个围绕
cd
的包装器,如下所示:很难说出为什么您的
.rvmrc
不起作用。 Rvm 确实支持项目特定的.rvmrc
文件,但您没有发布您的文件。Yes
Rvm does define a wrapper around
cd
that looks like this:It's difficult to tell why your
.rvmrc
isn't working. Rvm does support project-specific.rvmrc
files, but you didn't post yours.您需要在脚本中获取rvm,当您运行脚本时,它不会加载您的
.bashrc
。 添加一行即可。只需在脚本的开头
You need to source rvm inside your script, when you run a script it doesn't load your
.bashrc
. Simply add a line liketo the start of your script.
如果您使用的是 RVM 1.7.0 或更高版本,则需要通过将此行添加到 ~/.rvmrc(或系统 .rvmrc)来启用项目特定的 .rvmrc 文件:
rvm_project_rvmrc=1
请参阅:https://rvm.io/workflow/rvmrc/
If you are using RVM 1.7.0 or later you need to enable project specific .rvmrc files by adding this line to ~/.rvmrc (or system .rvmrc):
rvm_project_rvmrc=1
See: https://rvm.io/workflow/rvmrc/