Reputation: 5962
Capistrano Doc says
ssh me@remote "[[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'"
Interactive
me@localhost $ ssh me@remote "shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'"
Not login shell
Capistrano state that the command runs on ssh me@remote in "Interactive and Non login shell". Very well but here is my point.
What I did is, I added a simple test in my .bashrc that look like this
echo $-
# If not running interactively, don't do anything
case $- in
*i*) echo 'Interactive';;
*) echo 'Non Interactive';;
esac
Now, Instead of double quote ("
) I wrapped the Capistrano example in a single quote ('
) because I felt the double quote expand the expression for the current shell (in my case it's my laptop tty
terminal)
Result :
ssh me@remote '[[ $- == *i* ]] && echo "Interactive" || echo "Not interactive"'
hBc
Non Interactive
Not interactive
Question 1:
- Is the Capistrano doc correct?. Looking my result above it seems that command runs via ssh run in non-interactive and non-login shell.
Question 2:
If I'm correct(in term of Question 1) how can I run a command in an interactive shell?. I was under the impression -t
options would force tty
allocation and that would help. But that doesn't help either.
ssh me@remote -t '[[ $- == *i* ]] && echo "Interactive" || echo "Not interactive"'
hBc
Non Interactive
Not interactive
Connection to remote closed.
Question 3:
To the Original question now. I'm using Mina for my deployment stuff.Now, during mina deploy the rvm never loads.
Reason my bash has the following definitions in bashrc
# bashrc
case $- in #when mina load bashrc it's a non-interactive shell.
*i*) ;;
*) return;;
esac
source ~/.rvm/scripts/rvm # this is never gets executed
Question 4(a)
How do people work around this problem?. Surely moving the rvm source load at the top of the file help but I looking for a different answer.
Question 4 b
: How does Capistrano and Mina handle it. If they can?
Upvotes: 0
Views: 504
Reputation: 2653
I don't use RVM, but I'll take a quick crack at your question:
Q1: Unless there is another piece of the documentation that I'm missing, you've mis-quoted. It says:
By default Capistrano always assigns a non-login, non-interactive shell.
Q2: You can't/shouldn't. Capistrano deploys should be fully unattended, in which case there is no need for an interactive shell.
Q3: This is where I'm not sure, because I've only used rbenv. However I'll give it a shot. Use https://github.com/capistrano/rvm to set up RVM. Once you have that, if you have a command in addition to those listed here: https://github.com/capistrano/rvm/blob/master/lib/capistrano/tasks/rvm.rake#L53, use append :rvm_map_bins, 'nameofexecutable'
to make RVM apply to your command.
Q4a/b: See Q3.
Upvotes: 2