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

Comments

Projects
None yet
7 participants
@astehlik
Contributor

astehlik commented Jun 25, 2015

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

This comment has been minimized.

Show comment
Hide comment
@cs278

cs278 Jun 25, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@astehlik

astehlik Jun 25, 2015

Contributor

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.

Contributor

astehlik commented Jun 25, 2015

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

This comment has been minimized.

Show comment
Hide comment
@sbuzonas

sbuzonas Jun 25, 2015

Contributor

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

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

Contributor

sbuzonas commented Jun 25, 2015

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

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

@astehlik

This comment has been minimized.

Show comment
Hide comment
@astehlik

astehlik Jun 26, 2015

Contributor

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?

Contributor

astehlik commented Jun 26, 2015

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

This comment has been minimized.

Show comment
Hide comment
@alcohol

alcohol Jun 26, 2015

Member

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
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

This comment has been minimized.

Show comment
Hide comment
@staabm

staabm Jun 26, 2015

Contributor

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

Contributor

staabm commented Jun 26, 2015

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

@alcohol

This comment has been minimized.

Show comment
Hide comment
@alcohol

alcohol Jun 26, 2015

Member

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
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

This comment has been minimized.

Show comment
Hide comment
@cs278

cs278 Jun 26, 2015

Contributor

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 '*'
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

Use a longer timeout on SSH multiplex sockets to github.com
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

This comment has been minimized.

Show comment
Hide comment
@alcohol

alcohol Jun 26, 2015

Member

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
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

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 26, 2015

Contributor

@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'),

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

This comment has been minimized.

Show comment
Hide comment
@alcohol

alcohol Jun 26, 2015

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@sbuzonas

sbuzonas Jun 26, 2015

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.

Contributor

sbuzonas commented Jun 26, 2015

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.

@alcohol alcohol added the Support label Jul 21, 2015

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Feb 19, 2016

Member

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

Member

Seldaek commented Feb 19, 2016

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

@Seldaek Seldaek closed this Feb 19, 2016

astehlik added a commit to astehlik/composer that referenced this issue Feb 22, 2016

astehlik added a commit to astehlik/composer that referenced this issue Feb 22, 2016

astehlik added a commit to astehlik/composer that referenced this issue Feb 22, 2016

aminztw pushed a commit to aminztw/composer that referenced this issue Jan 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment