shiftkey / desktop

Fork of GitHub Desktop to support various Linux distributions
MIT License
6.8k stars 517 forks source link

GitHub Desktop on Linux working with AWS CodeCommit? #732

Closed JonHolman closed 2 years ago

JonHolman commented 2 years ago

Operating System/Distribution

Which distribution of Linux are you using? Pop!_OS 22.04

Installer

Which version of the app? 3.0.2-linux1 (x64) Which installer type? deb

What happened?

Provide as much detail as possible. Error messages or output are extremely useful.

For years I have been using GitHub desktop with AWS CodeCommit repos on Windows and Mac (with the plugin https://pypi.org/project/git-remote-codecommit/ ). I just installed Pop!_OS 22.04 and when I installed GitHub Desktop from the Pop!_Shop this was working, then I realized it was version 2.8.3 and 3.0.2 is available. I then upgraded to 3.0.2 and since then when I try to work with an AWS CodeCommit repo I am getting the message "git: 'remote-codecommit' is not a git command. See 'git --help'." Right now I'm looking for where that command "remote-codecommit" is coming from, so I can see if I can fix it. I have not found how to get this error from the terminal.

Has anyone else run into this? Any tips? Thanks.

shiftkey commented 2 years ago

Right now I'm looking for where that command "remote-codecommit" is coming from, so I can see if I can fix it. I have not found how to get this error from the terminal.

I believe this is because git-remote-codecommit is a special command that needs to be installed alongside Git, and GitHub Desktop doesn't reuse the user-installed Git. If you're able to use the https:// or ssh:// remote with the repository that should work, but I'm curious how this is working on Windows and Mac as we share the same approach here on Linux.

JonHolman commented 2 years ago

Thanks @shiftkey . I'm on a mac right now and I can confirm git-remote-codecommit is working in GitHub desktop. I have been curious about how as well. In GitHub desktop on the mac when I go into repo settings. The remote origin is codecommit://<aws profile name>@<repo name>. Then syncing with CodeCommit through GitHub desktop just uses my AWS CLI configured credentials. Let me know if you would like me to look at anything else.

shiftkey commented 2 years ago

I'm on a mac right now and I can confirm git-remote-codecommit is working in GitHub desktop. I have been curious about how as well.

My suspicion here is that your PATH environment variable contains the directory where git-remote-codecommit is installed on macOS but not Linux. The main git binary knows how to resolve the scheme of the URL and use the right subprogram to handle interacting with the URL:

> find /usr -name git-remote-https
/usr/lib/git-core/git-remote-https
/usr/lib/github-desktop/resources/app/git/libexec/git-core/git-remote-https

This is how my Ubuntu install looks when I try and locate the subprogram that handles authentication for Git remotes using https:// URLs (first path is the system-installed Git, the second is the one embedded in Desktop)

But if the CLI is working as expected then perhaps Desktop on Linux is being affected by environment variables. I dove into this a while ago and wrote up the gory details in https://github.com/shiftkey/desktop/issues/444#issuecomment-782908783 but what I'd ask next is:

I don't know that we do anything special on macOS or Windows for these environment variables, but if that's the case I think setting environment variables outside of your shell here should apply it to use from the OS app launcher, e.g https://unix.stackexchange.com/a/131326, but I haven't tested that yet.

JonHolman commented 2 years ago

Thanks for your help. I think it must have to do with my default git being different than github desktop's git. How do I make sure github desktop's git knows about git-remote-codecommit? Here are my notes from trying out the commands you shared above, hopefully these are helpful.

On the mac:

% which git
/opt/homebrew/bin/git
% which git-remote-https
git-remote-https not found
% which git-remote-codecommit
/opt/anaconda3/bin/git-remote-codecommit
% sudo find /usr -name git-remote-https
% sudo find /usr -name git-remote-codecommit 
% sudo find /usr -name git                  
/usr/bin/git
/usr/local/lib/node_modules/npm/node_modules/@npmcli/git
/usr/share/file/magic/git

On linux:

$ which git
/usr/bin/git
$ which git-remote-https
$ which git-remote-codecommit
/home/jonholman/anaconda3/bin/git-remote-codecommit
$ sudo find /usr -name git-remote-https
/usr/lib/github-desktop/resources/app/git/libexec/git-core/git-remote-https
/usr/lib/git-core/git-remote-https
$ sudo find /usr -name git-remote-codecommit
$ sudo find /usr -name git
/usr/lib/github-desktop/resources/app/git
/usr/lib/github-desktop/resources/app/git/libexec/git-core/git
/usr/lib/github-desktop/resources/app/git/bin/git
/usr/lib/git-core/git
/usr/share/bash-completion/completions/git
/usr/share/code/resources/app/extensions/git
/usr/share/doc/git
/usr/share/lintian/overrides/git
/usr/share/nodejs/@npmcli/git
/usr/bin/git
/usr/local/lib/node_modules/npm/node_modules/@npmcli/git

I usually launch GitHub desktop from the app launcher, I just tried from the command line and it was the same outcome. In GitHub Desktop on Linux, the error I get is: git: 'remote-codecommit' is not a git command. See 'git --help'.

At the command line, git fetch just works (using my default git). However forcing my terminal commands to use GitHub desktop's git gets these results:

$ /usr/lib/github-desktop/resources/app/git/libexec/git-core/git fetch
git: 'remote-http' is not a git command. See 'git --help'.
$ /usr/lib/github-desktop/resources/app/git/bin/git fetch
git: 'remote-http' is not a git command. See 'git --help'.
shiftkey commented 2 years ago

At the command line, git fetch just works (using my default git). However forcing my terminal commands to use GitHub desktop's git gets these results:

...

Ugh, guess that was a bad demo on my side. I think this is the key bit to focus on:

$ which git-remote-codecommit
/home/jonholman/anaconda3/bin/git-remote-codecommit

So this works because your PATH is correct in the terminal, and I'd check what the PATH is when the app runs. You can get to the dev tools easily and poke at what process.env.PATH is:

If that appears to be different from what's in your terminal, then I think we're onto something.

JonHolman commented 2 years ago

Yeah, I think that is it exactly. How do I add to the path that GitHub desktop is using?

JonHolman commented 2 years ago

This issue is resolved. I created a VM where I was comparing things. I noticed the path in the VM had much more included. Both GitHub desktops used my user profile, as I could see in process.env. I noticed the application's path was different. Then I remembered I had installed GitHub desktop from Pop!_Shop while I followed the instructions in this repo's readme on the VM. I then uninstalled it from Pop!_Shop and reinstalled it with the readme instructions, which resolved my issue. I'm not exactly sure why the other install was not loading my full path.