Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer hangs when cloning SSH repository with enabled ControlMaster #4180

Closed
astehlik opened this issue Jun 25, 2015 · 13 comments
Closed

Composer hangs when cloning SSH repository with enabled ControlMaster #4180

astehlik opened this issue Jun 25, 2015 · 13 comments
Labels

Comments

@astehlik
Copy link
Contributor

This is a really strange bug.

I'm using the ControlMaster setting of SSH to speed up connections to our Git server:

Host mygitserver
    ControlMaster auto
    ControlPath ~/.ssh/master-%r@%h:%p
    ControlPersist 1h

I can manually access the Server with SSH and clone repositories without a problem.

But when I use composer and the master file does not exist, composer just stops working on this command:

git clone --no-checkout 'git@mygitserver:mydir/myrepo.git' '/the/target/dir' && cd '/the/target/dir' && git remote add composer 'git@mygitserver:mydir/myrepo.git' && git fetch composer

When I look at the process tree, I see this:

php /usr/local/bin/composer.phar -vvv update
  \_ [sh] <defunct>

When I open a connection to the SSH server before running composer and the master file already exists the composer command runs without problems.

@cs278
Copy link
Contributor

cs278 commented Jun 25, 2015

Eureka, I've been having this problem for ages never occurred to me it might be down to SSH connection multiplexing. This would explain why I don't see it very often and a SIGINT and re run always works.

@astehlik
Copy link
Contributor Author

I'm glad I'm not the only one ;)

As a workaround I'm using a script that does a ssh -t mygitserver before the composer run.

@sbuzonas
Copy link
Contributor

This has been a bug in SSH for a while with control persist.

https://bugzilla.mindrot.org/show_bug.cgi?id=1988

@astehlik
Copy link
Contributor Author

Thanks for the pointer.

Since this does not seem to be a composer bug, maybe this should be added to the troubleshooting section in the docs?

@alcohol
Copy link
Member

alcohol commented Jun 26, 2015

Odd, I use roughly the same settings but I have never had any trouble with it.

Host *
    TCPKeepAlive no
    ServerAliveInterval 10
    ServerAliveCountMax 3
    ControlMaster auto
    ControlPath ~/.ssh/ssh-%r@%h:%p
    ControlPersist 2h

@staabm
Copy link
Contributor

staabm commented Jun 26, 2015

@alcohol maybe you dont use a ssh version which is affected by the bug (see bugreport)

@alcohol
Copy link
Member

alcohol commented Jun 26, 2015

On my server

rob@robbast ~ (master) $ ssh -V
OpenSSH_6.8p1, OpenSSL 1.0.2c 12 Jun 2015

On my macbook

rob@emac019 ~ (master) $ ssh -V
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011

Yay for homebrew

rob@emac019 ~ (master) $ ssh -V
OpenSSH_6.8p1, OpenSSL 1.0.2c 12 Jun 2015

@cs278
Copy link
Contributor

cs278 commented Jun 26, 2015

By the sounds of things it was never fixed in SSH they just added the -E option so you could stop it opening stderr. So I suspect unless that option is being used it should be present in all versions that support multiplexing.

@alcohol I'm using 6.6 and can reproduce the problem, the difference is I use a time out of 10 minutes rather than your much longer 2 hours. I think I'll bump mine up for GitHub.

Console output on my machine: https://gist.github.com/cs278/7e60c231159bc2249cd8

Steps to reproduce are basically:

cd "$(mktemp -d)"
ssh -O exit git@github.com
composer require --prefer-source psr/log '*'

cs278 added a commit to cs278/dotfiles that referenced this issue Jun 26, 2015
When running SSH without an existing socket a new instance is forked
holding open stderr, this causes Composer to hang waiting for output
from that stream. Increase the timeout so there is less chance of
running Composer when there is no socket open.

See: composer/composer#4180
@alcohol
Copy link
Member

alcohol commented Jun 26, 2015

Eh your steps to reproduce doesn't really work for me...

rob@emac019 ~/Music (master) $ cd "$(mktemp -d)"
rob@emac019 /var/folders/q2/s6l2p2gj36l710r752smh96c0000gp/T/tmp.4dok4Aw4Dv $ ssh -O exit git@github.com
Control socket connect(/Users/rob/.ssh/ssh-git@github.com:22): No such file or directory
rob@emac019 /var/folders/q2/s6l2p2gj36l710r752smh96c0000gp/T/tmp.4dok4Aw4Dv $ composer require --prefer-source psr/log '*'
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing psr/log (1.0.0)
    Cloning fe0936ee26643249e916849d48e3a51d5f5e278b

Writing lock file
Generating autoload files

Edit: never mind, had to add a github.com entry to my .ssh config;

Host github.com
    User git
    IdentityFile ~/.ssh/id_rsa
rob@emac019 ~ (master) $ cd "$(mktemp -d)"
rob@emac019 /var/folders/q2/s6l2p2gj36l710r752smh96c0000gp/T/tmp.kSrT2CsKd6 $ ssh -O exit git@github.com
Exit request sent.
rob@emac019 /var/folders/q2/s6l2p2gj36l710r752smh96c0000gp/T/tmp.kSrT2CsKd6 $ composer require --prefer-source psr/log '*'
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing psr/log (1.0.0)
    Cloning fe0936ee26643249e916849d48e3a51d5f5e278b

Writing lock file
Generating autoload files

@stof
Copy link
Contributor

stof commented Jun 26, 2015

@alcohol you should also force composer to use the ssh url when cloning the repo. If it clones over https, it will of course not be impacted. and by default, SSH is the last protocol: https://getcomposer.org/doc/06-config.md#github-protocols and

'github-protocols' => array('git', 'https', 'ssh'),

@alcohol
Copy link
Member

alcohol commented Jun 26, 2015

I see. So I guess his internal server doesn't support the git and https protocol, hence the ssh fallback.

@sbuzonas
Copy link
Contributor

I have the issue with private repos. I have my environment set up to point GIT_SSH to a wrapper that spawns a control master if the socket isn't available. Then calls ssh.

@Seldaek
Copy link
Member

Seldaek commented Feb 19, 2016

Closing as it's not clear what we can do to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants