When I try to use the push (o) and pull (i) features I get these error messages:
Push:
Error
authentication required: Repository not found.
Pull:
Error
done
There errors are surrounded with their corresponding boxes in TUI
Often the pull command gives the same error as the push commands. For example, I pulled all bugs from my repo using the corresponding GitHub bridge, and then I opened the TUI and tries to do a pull and I got the same error as push.
I configured my bridge as in the documentation and I can push and pull perfectly in CLI
sudoforge commented
thanks for opening this issue -- sorry you're experiencing a bug.
as a note to start off with, pushing in the TUI doesn't actually push to your bridge (yet). pushing and pulling to bridges is scoped under the git bug bridge {pull,push} commands explicitly. so, the statement that you can push and pull via the bridge is a bit of a red herring -- this is using your bridge credentials to interact with the API, where the TUI's "push" action is using git to push the bugs to your remote.
i talk a little bit about why this is problematic and how i plan to solve it in my vision document for the future of git-bug -- i'd be interested in hearing your thoughts, if you were interested in reading through it (commenting on that discussion would be best).
i'll need a bit more information before i can verify the source of this issue.
what does the URL for your origin remote look like? (you can redact the user and repo names if you'd prefer)
git remote get-url --all origin
what happens if you run git bug push on the command line?
this uses go-git under the hood to push and pull from your remote. you should be prompted to unlock your authentication key (unless it's already cached).
if this works for you without error, then the problem you were likely encountering is simply that your key wasn't cached when you tried to push/pull in the TUI. git-bug doesn't currently have a way to handle this from the TUI (which... yeah, sucks). in the TUI, when i push or pull with an uncached ssh key, my pinentry program starts, but the TUI still intercepts the keys and all sort of chaos occurs such that i can't enter my passphrase.
JoaKing (JoacoG) commented
Hello. I read your vision of the future and the corresponding discussion, but I really don't have much technical knowledge on many of the topics you discussed, I leaved a comment but I don't address much issues there. Maybe I could reread that in the future and give a much more informed opinion :)
what does the URL for your origin remote look like? (you can redact the user and repo names if you'd prefer)
what happens if you run git bug push on the command line?
It does not work. It gives me the same error as in the TUI Error: authentication required: Repository not found.
I can push and pull using git bug bridge push origin and git bug bridge pull origin respectively.
sudoforge commented (edited)
thanks for getting back to me.
I can push and pull using git bug bridge push origin and git bug bridge pull origin respectively.
yes -- as stated in my comment, git-bug-bridge-{push,pull} and git-bug-{push,pull}behave differently. the former uses your bridge credentials (e.g. your oauth token) to hit your bridge's API. the latter uses git (well, go-git) to effectively do a git push (of your git-bug entities).
is this the url for your git remote (as in, the actual output from git remote get-url origin on the command line)? if so, this is the issue -- git-bug's git operations don't support authentication for http(s) remotes.
normally, with a remote like this, git prompts you for your username and password (or access token). IIRC github requires that you use a personal access token instead of your password, so your workflow would look something like this:
➜ git remote get-url origin
https://github.com/sudoforge/test.git
➜ git pull
Username for 'https://github.com': <username>
Password for 'https://github.com': <personal access token>
but git-bug doesn't currently "know" how to do this for sort check-first-and-then-prompt-the-user-for-creds. additionally, go-git (the library we use) doesn't support reading from ~/.netrc, or any credential.helper configuration you've set up for git.
we probably should, since git does, so i'll change this issue's title so that it represents the feature request more accurately.
in the meantime, you can solve this in a couple of different ways.
changing your git remote to https://<user>:<token>@github.com/foo/bar.git
RECOMMENDED: use ssh instead; this is more secure and generally a better way to use git for private repositories (anywhere; not just for ones on github).
sudoforge changed the title from git: support authenticated http(s) remotes to push, pull should handle authenticated http(s) remotes
JoaKing (JoacoG) commented
is this the url for your git remote (as in, the actual output from git remote get-url origin on the command line)?
Yes, it is
normally, with a remote like this, git prompts you for your username and password (or access token). IIRC github requires that you use a personal access token instead of your password, so your workflow would look something like this:
➜ git remote get-url origin
https://github.com/sudoforge/test.git
➜ git pull
Username for 'https://github.com': <username>
Password for 'https://github.com': <personal access token>
Git does not give me those prompts, I can pull and push without having to authenticate each time.
in the meantime, you can solve this in a couple of different ways.
changing your git remote to https://:@github.com/foo/bar.git
RECOMMENDED: use ssh instead; this is more secure and generally a better way to use git for private repositories (anywhere; not just for ones on github).
The second option does not work. It gives me this error
Error: error creating SSH agent: "SSH agent requested, but could not detect Pageant or Windows native SSH agent"
It happens in both CLI and termui. In CLI I used git bug push origin and git bug pull origin with the recommended configuration with SSH.
I then tried the first option.
This first option works for git bug push origin2 and git bug pull origin2 where origin2 is a new remote with the corresponding configuration. If I drop the origin2 remote en both commands, then it does not work, but I don't know if these commands are intended to work if I do not give them remotes explicitly. In TUI push and pull do not work and give the same error as in the second option. Maybe this happens because I cannot explicitly pick in TUI which remote I want to use.
I can push and pull normally from/to my repo using just git with both options.
sudoforge commented (edited)
Git does not give me those prompts, I can pull and push without having to authenticate each time.
you have to have configured your credentials somewhere. it'd be normal to use git's credential.helper for http authentication like this, but like i said, go-git (and thus, git-bug) does not support re-using this.
The second option does not work. It gives me this error
Error: error creating SSH agent: "SSH agent requested, but could not detect Pageant or Windows native SSH agent"
It happens in both CLI and termui. In CLI I used git bug push origin and git bug pull origin with the recommended configuration with SSH.
git-bug currently requires that an ssh agent is running (e.g. in linux/macos, eval $(ssh-agent), and requires that the SSH_AUTH_SOCK environment variable is set. based on the error you got, i am assuming that you didn't have an agent running.
I then tried the first option.
This first option works for git bug push origin2 and git bug pull origin2 where origin2 is a new remote with the corresponding configuration. If I drop the origin2 remote en both commands, then it does not work but I don't know if these commands are intended to work if I do not give them remotes explicitly.
well... you configured the token-based URI for the origin2 remote, and told git-bug to push/pull with that remote. then you ran push/pull without specifying the origin2 remote, meaning that git-bug will default to origin, where you had not set your token in the URI.
that was a user error, not an issue with git-bug.
In TUI push and pull do not work and give the same error as in the second option. Maybe this happens because I cannot explicitly pick in TUI which remote I want to use.
this is a known issue. on the CLI, you can specify the remote you want to push to or pull from:
but in the TUI, the remote is not (yet) configurable, and always tries to interact with origin. if you change the origin remote to embed the token in the URI, git-bug's TUI will be able to push and pull for you without issue.
JoaKing (JoacoG) commented
if you change the origin remote to embed the token in the URI, git-bug's TUI will be able to push and pull for you without issue.
This works.
I wanted to set the recommended option but I'm not able to make it work, and apparently this has nothing to do with git-bug do that I will use the first suggested configuration.
Thank you! :)
sudoforge commented
github publishes some documentation about connecting with ssh that you may find useful:
Is there a workaround to push bugs with usual git commands (need to push some refs/*?)
sudoforge commented (edited)
hey @vitalyster, if you aren't able to use the workarounds discussed here (e.g. because you depend on git's credential.helper), there's some discussion about pushing and pulling manually here: https://github.com/git-bug/git-bug/discussions/1332
the gist of it is to push refs/bugs and refs/identities.
git-bug won't cache these if you pull them down manually (e.g. on another machine that has already been initialized), so you'd need to delete git-bug's cache, and then simply run git bug bug to re-initialize the cache for bugs, and git bug user to re-initialize the cache for identities.
it's not ideal, i know - addressing the core network protocols and authentication mechanisms that git-bug is missing is top of mind.
sudoforge changed the title from push, pull should handle authenticated http(s) remotes to git: support authenticated http(s) remotes