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

[SR-6735] github fetch silently stuck waiting for ssh passphrase #4901

Closed
swift-ci opened this issue Jan 11, 2018 · 8 comments
Closed

[SR-6735] github fetch silently stuck waiting for ssh passphrase #4901

swift-ci opened this issue Jan 11, 2018 · 8 comments
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-6735
Radar rdar://problem/30661854
Original Reporter strangemonad (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: ae9984435e20604dff44fd2413be5862

duplicates:

  • SR-4621 [PackageManager] Package fetch with authentication broken.

is duplicated by:

  • SR-3981 Using private repository for editable package
  • SR-4621 [PackageManager] Package fetch with authentication broken.

Issue Description:

$ swift --version
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9

Repro steps: Get yourself into a situation where a plain old git-clone would prompt for your ssh key passphrase. I normally have ssh-agent running but it had died.

`swift package update` or `swift package resolve` will silently hang at `Fetching git@github.com:dep-org/Dep.git`

@ankitspd
Copy link
Member

A workaround is to clone the repo outside of the package manager and have the auth cached.

@swift-ci
Copy link
Contributor Author

Comment by Shawn Morel (JIRA)

Thanks for the quick update @aciidb0mb3r. I'm curious what the duplicate bug fix was. I couldn't find anything specific other than this old bug SR-561.

If I'm reading the current state of the source code right, I think the bug still exists and is a regression from migrating what used to be the old /Get/Git.swift to the new /Repositories/GitRepository.swift which uses the updated /Basic/Process. By default, Process redirects standard input. If I'm reading Process.swift correctly, this means launch() and waitUntilExit() will consume git's std out into a byte buffer var in the Process instance.

While the workaround certainly works, git auth workflows should probably work out of the box given how reliant on git the whole mechanism is. At the very least, it shouldn't just hang silently while the user thinks a fetch is in progress.

Sorry if I missed an obvious code fix that happened between now and the 4.0.3 release

@ankitspd
Copy link
Member

Oh, you're right, the hang issue is different from the auth issue. It is not supposed to hang anymore, I'll look into that.

I agree that we need to fix the auth issue but it isn't trivial unfortunately. This is more complicated by the fact that we clone dependencies in parallel now.

@ankitspd
Copy link
Member

@swift-ci create

@swift-ci
Copy link
Contributor Author

Comment by Shawn Morel (JIRA)

Agreed, the “correct” fix is probably quite involved and would make use of something like GIT_ASKPASS or some git credential helper.

Given that

1) the std out is redirected and

2) multiple git processes are run concurrently

It seems like git should just be told to fail rather than prompt. There’s the little documented GIT_TERMINAL_PROMPT= env var that can be set when exec-ing git. https://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials

Printing the captured content of stdout is probably still nice to have though after a non-0 process exit code result to help debugging.

@ankitspd
Copy link
Member

We do set that variable but I think it only works for username/password prompt and not the ssh key password prompt 🙁

@swift-ci
Copy link
Contributor Author

Comment by Shawn Morel (JIRA)

Ah right, my bad, I missed Utilities/Git.enviroment().

There is the new-ish GIT_SSH_COMMAND env var that let's you pass flags to ssh (it takes precedence over the more cumbersome GIT_ SSH). This allows passing flags to ssh. In theory it's only available as of git 2.3 though (default git on macOS 10.13 is 2.14 but somehow GIT_SSH_COMMAND seems to be respected so I'm not sure what fork Apple is using here).

References:

Example usage:

`$ GIT_SSH_COMMAND="ssh -oBatchMode=yes %@" git pull
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.`

`$ /usr/bin/git --version
git version 2.14.3 (Apple Git-98)

$ GIT_SSH_COMMAND="ssh -oBatchMode=yes %@" /usr/bin/git pull
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.`

@ankitspd
Copy link
Member

ankitspd commented Nov 2, 2018

#1839

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
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

2 participants