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

Cannot push with Fork instance of git #1397

Open
keybuk opened this issue Jun 12, 2021 · 23 comments
Open

Cannot push with Fork instance of git #1397

keybuk opened this issue Jun 12, 2021 · 23 comments

Comments

@keybuk
Copy link

keybuk commented Jun 12, 2021

Mac mini M1, Fork 2.8

When Git instance is set to the default (2.31.1 Fork instance), cannot push due to the following error:

Pushing to https://github.com/keybuk/...
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/keybuk/.../'

In a case you entered incorrect password, please
update it in Keychain Access application.

Changing Git instance to 2.30.1 (Apple Git-130) /usr/bin/git works

@DanPristupov
Copy link
Contributor

Hi. Did you try to log in to your GitHub account in Fork? Accounts -> Git -> + -> GitHub

@DanPristupov
Copy link
Contributor

May be your global git config contains credential.helper to osxkeychain which doesn't exist in the system:

What is the result of git config --show-origin --get credential.helper?

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

Repository settings in Fork are set to "Use global git credentials"

My .gitconfig does indeed contain that:

[credential]
	helper = osxkeychain
file:/Users/developer/.gitconfig	osxkeychain

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

The system git has the command available:

Artificer developer% git credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase>

But the version of git that Fork uses can't see it…

Artificer developer% /Applications/Fork.app/Contents/Resources/git-instance/bin/git credential-osxkeychain
git: 'credential-osxkeychain' is not a git command. See 'git --help'.

Which is weird, because it has its own copy right next to it…

Artificer developer% /Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase>

So it looks like the git instance bundled with Fork is not correctly finding its own subcommands

@DanPristupov
Copy link
Contributor

Repository settings in Fork are set to "Use global git credentials"

Those are only affect the identity you use when commit (user.name and user.email).

remote: Invalid username or password.

Did you change the password recently? Or is that possible that Fork doesn't have an access to the github.com password entry in the KeyChain Access application?

Anyway, I'd recommend to log in to GitHub account in Fork. The login/password authentication on GitHub is deprecated.

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

There is a GitHub.com password in the login keychain which is a personal access token that works with git on the command-line.

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

This is a setup that previously worked, and was broken by a Fork update… as mentioned switching to the system (Xcode) git instance from the Fork one works around the issue.

The instance bundled with Fork isn't resolving the location of its subcommands:

Artificer developer% GIT_TRACE=1 /Applications/Fork.app/Contents/Resources/git-instance/bin/git credential-osxkeychain
10:54:45.358073 git.c:733               trace: exec: git-credential-osxkeychain
10:54:45.358692 run-command.c:667       trace: run_command: git-credential-osxkeychain
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
zsh: exit 1     GIT_TRACE=1 /Applications/Fork.app/Contents/Resources/git-instance/bin/git 

/Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain exists, the git build in Fork is just not correctly looking for it.

The system instance has the extra step

Artificer developer% GIT_TRACE=1 /usr/bin/git credential-osxkeychain
10:54:58.249476 exec-cmd.c:139          trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git
10:54:58.249956 exec-cmd.c:238          trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin
10:54:58.250307 git.c:730               trace: exec: git-credential-osxkeychain
10:54:58.250320 run-command.c:664       trace: run_command: git-credential-osxkeychain

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

Also just to confirm a hunch, placing the contents of Fork.app in PATH allows it to find it:

Artificer developer% PATH=$PATH:/Applications/Fork.app/Contents/Resources/git-instance/bin/ /Applications/Fork.app/Contents/Resources/git-instance/bin/git credential-osxkeychain 
usage: git credential-osxkeychain <get|store|erase>

So the problem here is that the current version of Fork is shipping a broken included git instance that is not able to resolve the executable path of its own subcommands sitting in the directory alongside it

@DanPristupov
Copy link
Contributor

DanPristupov commented Jun 12, 2021

There is a GitHub.com password in the login keychain which is a personal access token that works with git on the command-line.

Does Fork have an access to that record?

The thing is, helper = osxkeychain should not be in ~/.gitconfig. If it is, it must be available in PATH. Otherwise, how can it be found?

So the problem here is that the current version of Fork is shipping a broken included git instance that is not able to resolve the executable path of its own subcommands sitting in the directory alongside it

No, this is wrong.

Fork doesn't use (or need) osxkeychain, however, if you define/override credential.helper explicitly and globally, it must also be in PATH.

This is a setup that previously worked, and was broken by a Fork update…

I believe, I didn't touch the authentication code for at least 10 versions.

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

I'm completely confused by your questions about keychain record access.

The error is that Fork's instance of git cannot find find the git-credential-osxhelper binary that is shipped right alongside it.

This works in older versions of Fork, so has been broken recently - perhaps as a result of the git update

@keybuk
Copy link
Author

keybuk commented Jun 12, 2021

If you could make the .dmg files of older versions of Fork available, I'll let you know which version of Fork this was broken in

@DanPristupov
Copy link
Contributor

I'm completely confused by your questions about keychain record access.

I wasn't sure about the problem first and tried to ensure that it's not a lack of the access to the password.

This works in older versions of Fork, so has been broken recently - perhaps as a result of the git update

I see now. Yes, you are right. We indeed replaced git instance some time ago and there might be differences. But I don't consider credential-osxhelper not being in PATH as a bug, because Fork doesn't use it.

The error is that Fork's instance of git cannot find find the git-credential-osxhelper binary that is shipped right alongside it.

I think, this is fine because Fork doesn't need it. In your case git calls credential-osxhelper only because you added helper = osxkeychain to the global ~/.gitconfig, while it's not available in PATH.

@keybuk
Copy link
Author

keybuk commented Jun 13, 2021

This works in older versions of Fork, so has been broken recently - perhaps as a result of the git update

I see now. Yes, you are right. We indeed replaced git instance some time ago and there might be differences. But I don't consider credential-osxhelper not being in PATH as a bug, because Fork doesn't use it.

So given the above, why does the Fork distribution contain git-credential-osxhelper at all?

It's at /Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain

Artificer developer% file /Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain
/Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [i386:Mach-O executable i386]
/Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain (for architecture x86_64):	Mach-O 64-bit executable x86_64
/Applications/Fork.app/Contents/Resources/git-instance/bin/git-credential-osxkeychain (for architecture i386):	Mach-O executable i386

Should Fork be adding that directory to PATH before executing its own instance of git, so that it gets the correct version?

The error is that Fork's instance of git cannot find find the git-credential-osxhelper binary that is shipped right alongside it.

I think, this is fine because Fork doesn't need it. In your case git calls credential-osxhelper only because you added helper = osxkeychain to the global ~/.gitconfig, while it's not available in PATH.

This is the recommended instructions by GitHub: https://docs.github.com/en/github/getting-started-with-github/getting-started-with-git/caching-your-github-credentials-in-git

Without this in .gitconfig, how would you suggest a developer be able to use the git command line tool and Fork on the same Github hosted repository?

@solrevdev
Copy link

I'm having the same issue. (I can provide system or application details or versions if needed.)

I am trying to push to a bitbucket repo that once worked fine. I can push from command line git but cannot push from Fork. Same error as @keybuk.

The mentioned workaround of changing the git instance that fork uses from the bundled one to a system one works for now.

@lewisl
Copy link

lewisl commented Mar 17, 2022

Was this ever fixed? I am still seeing it with Fork 2.16 on MacOS. For now, I'll switch to the system image of Git.

@DanPristupov
Copy link
Contributor

@lewisl no. For me it doesn't look like a bug.

@lewisl
Copy link

lewisl commented Mar 17, 2022 via email

@lewisl
Copy link

lewisl commented Mar 17, 2022 via email

@oliveratgithub
Copy link

oliveratgithub commented Sep 10, 2022

Hi there,
I have the same issue with Fork.app on a fresh installed macOS with Xcode CLT installed as well.

Fork always tries to Push using simply the 1st of 2 added GitHub-Accounts under Fork > Accounts…
Had to revert to the Terminal for pushing my changes to the Remote.

Has anybody found a working "fix" for this behaviour?

@DanPristupov
Copy link
Contributor

@oliveratgithub

Fig always tries to Push using simply the 1st of 2 added GitHub-Accounts under Fork > Accounts…

You can specify account for a particular remote. Right click on a remote on the sidebar and select 'Edit'. In the dialog you can select the account.

@oliveratgithub
Copy link

You can specify account for a particular remote. Right click on a remote on the sidebar and select 'Edit'. In the dialog you can select the account.

Yeeez – THANK YOU @DanPristupov!
The only place I was looking to select the corresponding GitHub account was under «Repository » Settings for This Repository…» – wouldn't have the idea to look directly on the Origin in the Repo Sidebar 🙈

@AbanoubZaki
Copy link

Thanks @DanPristupov that fixed my issue 🙏🏻

@SameelNawaz
Copy link

Thanks @DanPristupov. it works :)

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

No branches or pull requests

7 participants