Using capistrano when remote git is on a non-stand

2019-06-19 01:44发布

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.

7条回答
Lonely孤独者°
2楼-- · 2019-06-19 02:10

The ~/.ssh/environment file is not executed by a shell. It's a hardcoded environment file. If you want to set the path this way, you'll need to hardcode it instead of appending to $PATH. The other answers are possibly more correct, but setting ~/.ssh/environment correctly is a reliable fallback if all else fails.

查看更多
霸刀☆藐视天下
3楼-- · 2019-06-19 02:14

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.

查看更多
何必那么认真
4楼-- · 2019-06-19 02:17

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 git@github.com: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?

查看更多
再贱就再见
5楼-- · 2019-06-19 02:21

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.

查看更多
手持菜刀,她持情操
6楼-- · 2019-06-19 02:29

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"

查看更多
相关推荐>>
7楼-- · 2019-06-19 02:31
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

查看更多
登录 后发表回答