views:

1318

answers:

6

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.

+2  A: 

A quick workaround is to set the following in your deploy.rb file:

set :deploy_via, :copy

This will cause the checkout to occur on your own machine and then be copied to the deployment server.

Denis Hennessy
+3  A: 

You should be able to specify the full path to git like so:

set :scm_command, "/home/your_cap_runner_user/bin/git"

I haven't tried this out for myself - found it in the documentation in the source code for git.rb in Capistrano itself.

Chu Yeow
that works so long as both the local and remote git commands are in the same path
Jess Bowers
+4  A: 

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"

Matt Van Horn
+1  A: 

This is a great help, as I was running into the same issue as the original poster.

"Before" symptoms:

  • run cap deploy:setup (successful)
  • ran cap deploy:check (fails, with 'git command not found')

I now added set :scm_command, "~/bin/git" to my deploy.rb file.

  • ran cap deploy:setup (successful)
  • ran cap deploy:check (successful)
  • ran cap deploy:cold (fails, with the following error)

    :97:in ``': No such file or directory - ~/bin/git info [email protected]:quintar/eu reka.git -rHEAD (Errno::ENOENT)

So it looks like 'git' is recognized, but the repository I included in my deploy.rb is bypassed?

+1  A: 

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"
ckim
Your default_environment suggestion just got me past a huge headache for the Rails Rumble 2010. Thanks!
Jared
A: 
stdin: is not a tty

This is probably because of CPanel installed on your shared host. It executes "mesg y" in global /etc/.bashrc file that is included in your ~/.bashrc one. So you can just comment-out the inclusion.

Here’s the source: http://webhostingneeds.com/Git_stdin_is_not_a_tty

Sergei Morozov