tutorial - rails 5.2 capistrano




Using capistrano when remote git is on a non-standard path (3)

My shared host did not provide git, so I built and installed it into ~/bin. When I ran it, I got the following error on most commands, although they were successful.

stdin: is not a tty

I can solve that problem by adding:

default_run_options[:pty] = true

to my deploy.rb, but then I get this error, which blocks deployment:

sh: git: command not found

How can I resolve both errors?

I tried adding a ~/.ssh/environment file with "PATH=$PATH:$HOME/bin" (and changing sshd_config to use it) but it did nothing.

It seems whatever shell is being used by capistrano is not using the ~/.bashrc or ~/.bash_profile on the remote server.

Any ideas how to set the path on the remote machine?

other info: I'm using OS X locally, and the shared server is linux on Site5.


Thanks, Chu - you put me on the right path.

just using: set :scm_command, "~/bin/git"
still gave me errors, since my local git is not in that place.

However, the following seems to work, and to solve my issues:
set :scm_command, "~/bin/git"
set :local_scm_command, "/usr/local/bin/git"


The problem is that you've set

default_run_options[:pty] = true

which means that your .bash_profile or your usual shell init file won't be run, which is not the case when you set it to false -- but then you'll have issues when it wants to ask you for the password.

To get around this problem, you can manually set your PATH environment variable in your deploy file:

default_environment['PATH'] = "/your/path/to/git:/and/any/other/path/you/need"

Capistrano/Git not recognising checkout -B flag unless logged in via ssh

I managed to find a simple solution (though not sure if it's right, it works for me).

Editing the ~/.bashrc file to update $PATH as this is run by non-interactive shells where as ~/.bash_profile where I had originally updated my $PATH, is only run by bash on interactive shell login.

So here's the code.

$nano ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
#add ~/packages/bin installed apps/git to $PATH
export PATH=~/packages/bin:$PATH