Capistrano: Can I set an environment variable for the whole cap session?

后端 未结 5 798
遇见更好的自我
遇见更好的自我 2020-11-29 02:29

I\'ve got a staging server with both standard Ruby and Ruby Enterprise installed. As standard Ruby refuses to install a critical gem, I need to set $PATH so that ruby/gem/r

5条回答
  •  情话喂你
    2020-11-29 02:50

    If you need to set a variable on the remote host other than PATH, you should know that sshd only allows certain /etc/profile or ~/.bashrc environment variables by default, for security reasons. As Lou said, you can either do cap shell and use the cap> printenv command, or you can do cap COMMAND=printenv invoke in one command.

    If you see the variable when you ssh into the remote shell normally, but you don't see it in the cap printenv command, here's one solution:

    1. Set PermitUserEnvironment yes in your remote server's /etc/ssh/sshd_config file, and restart sshd
    2. Edit the ~/.ssh/environment file for the remote user you are ssh'ing in as, and put your variable(s) there as VARIABLE=value

    Now those should show up when you do cap COMMAND=printenv invoke

提交回复
热议问题