如何指示 Capistrano 3 加载我在远程主机上设置的 shell 环境变量? [英] How can I instruct Capistrano 3 to load my shell environment variables set at remote host?

查看:48
本文介绍了如何指示 Capistrano 3 加载我在远程主机上设置的 shell 环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想指示 Capistrano 加载远程服务器上定义的环境变量.我该怎么做?

I want to instruct Capistrano to load environment variables that are defined on remote server. How can I do that?

似乎当我在 .bashrc 文件中导出环境变量时,Capistrano 没有考虑它们.Capistrano 似乎正在执行一个 /usr/bin/env 来创建执行远程命令的环境,但这似乎不是从 .bashrc 加载环境变量.

It seems that when I export my environment variables inside .bashrc file, they are not taken into account by Capistrano. Capistrano seems to be executing a /usr/bin/env to create the environment for executing remote commands, but this does not seem to be loading the environment variables from .bashrc.

我也告诉你,我也在使用 rvm-capistrano(以防万一它可能有帮助).

Let me tell you also that I am using rvm-capistrano too (just in case it might help).

有什么线索吗?

推荐答案

虽然这个问题已经过去六个月了,但我还是把它留在这里,以防有人遇到同样的问题.

Although this question is over six months old now, I'll leave this here in case anyone is facing this same problem.

Capistrano 实际上确实加载.bashrc.但在文件顶部附近,您会发现:

Capistrano actually does load .bashrc. But near the top of the file you will find:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

如果在该行之后执行任何 export 操作,Capistrano 将无法访问它.解决方案只是将我的设置放在此之上,而 Capistrano 可以按照我想要的方式工作.

If you do any exporting after that line, it will not be reached by Capistrano. The solution was simply to put my setup above this and Capistrano works how I want.

此解决方案也在在此 GitHub 问题中得到了注明.

This solution was also noted at this GitHub issue.

这篇关于如何指示 Capistrano 3 加载我在远程主机上设置的 shell 环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆