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

Github and logins #100

Open
con-f-use opened this issue Sep 7, 2024 · 8 comments
Open

Github and logins #100

con-f-use opened this issue Sep 7, 2024 · 8 comments

Comments

@con-f-use
Copy link

con-f-use commented Sep 7, 2024

Having a difficult time with npins add github .... Why does it prompt me for a github username and password, if the repo I'm trying to add is public? It's especially puzzling because I have git configured to use ssh and because github has discontinued https username+password auth for a long time.

@piegamesde
Copy link
Collaborator

If you plainly git clone the same repo, does it do the same?

@con-f-use
Copy link
Author

con-f-use commented Sep 8, 2024

It does not, no.

$ git clone https://github.com/nix-community/mineflake
Cloning into 'mineflake'...
remote: Enumerating objects: 2026, done.
remote: Counting objects: 100% (747/747), done.
remote: Compressing objects: 100% (405/405), done.
remote: Total 2026 (delta 584), reused 405 (delta 339), pack-reused 1279 (from 1)
Receiving objects: 100% (2026/2026), 835.01 KiB | 3.41 MiB/s, done.
Resolving deltas: 100% (1078/1078), done.

$ nix-shell -p npins
this path will be fetched (2.43 MiB download, 8.30 MiB unpacked):
  /nix/store/2a6cfqlzmx1wxckp533qa077nlp3grbp-npins-0.2.4
copying path '/nix/store/2a6cfqlzmx1wxckp533qa077nlp3grbp-npins-0.2.4' from 'https://cache.nixos.org'...

$ npins init
[INFO ] Welcome to npins!
[INFO ] Creating `npins` directory
[INFO ] Writing default.nix
[INFO ] Writing initial sources.json with nixpkgs entry (need to fetch latest commit first)
[INFO ] Successfully written initial files to 'npins'.
[ble: elapsed 24.293s (CPU 48.3%)] npins init

$ npins add github nix-community mine-flake
[INFO ] Adding 'mine-flake' …
Username for 'https://github.com': ^C

@piegamesde
Copy link
Collaborator

Oh well. We really need some debug logging, in which it should show which commands npins is executing. Assuming it is failing on the first command, that would likely be some git ls-remote to find out the latest release. Moreover, we really should instruct git to operate in a non-interactive way and to fail instead of prompting.

Some things which would be cool if you tried it out:

  • Which version of npins are you using?
  • Can you interactively enter some credentials into the prompt? (Doesn't have to be correct ones, just any)
  • Does it work for other repos?

@piegamesde
Copy link
Collaborator

Oh I'm just seeing, you got a typo in the repo name of your npins add command. That at least explains why it is failing. However, I still don't understand why you get a prompt, on my machine it fails correctly instead:

npins add github nix-community mine-flake
[INFO ] Adding 'mine-flake' …
[ERROR] git ls-remote failed. stderr output:
[ERROR] > remote: Repository not found.
[ERROR] > fatal: repository 'https://github.com/nix-community/mine-flake.git/' not found
[ERROR] > 
Error: Failed to fully initialize the pin

Caused by:
    0: Couldn't fetch the release tags
    1: Failed to list tags for https://github.com/nix-community/mine-flake.git
    2: git ls-remote failed with exit code 128

@con-f-use
Copy link
Author

con-f-use commented Sep 8, 2024

Oh wow, I'm sorry to have bothered you then. I typoed once and then kept on using the wrong command via bash history. Feel free to close the issue. 🤦
I think the prompt is git's default behavior because the repo could be private and git can´t distingish. Could that be?
In any case, according to the nix shell, I was using npins 0.2.4 from nixpkgs. I can enter credentials, yes.

@piegamesde
Copy link
Collaborator

Yes, that narrows it down. I have a http token for GitHub in my .git-credentials, so I'm already "logged in" to GitHub and it can show me a 404. If I comment it out (or configure only SSH instead), GitHub wants login to check if the repository may exist. I even get a fancy GUI prompt, with fallback to CLI, though both seem to work.

I'll guess that this is not specific to GitHub and may happen with other forges as well.

Regardless, I'd consider this behavior an error, and the proper thing would be to instruct Git to not use interactive authentication.

@piegamesde
Copy link
Collaborator

Can you please try again with GIT_TERMINAL_PROMPT=0?

@con-f-use
Copy link
Author

con-f-use commented Sep 9, 2024

Sure.

$ nix-shell -p npins
this path will be fetched (2.43 MiB download, 8.30 MiB unpacked):
  /nix/store/2a6cfqlzmx1wxckp533qa077nlp3grbp-npins-0.2.4
copying path '/nix/store/2a6cfqlzmx1wxckp533qa077nlp3grbp-npins-0.2.4' from 'https://cache.nixos.org'...

$ export GIT_TERMINAL_PROMPT=0

$ git clone https://github.com/nix-community/mineflake
Cloning into 'mineflake'...
remote: Enumerating objects: 2026, done.
remote: Counting objects: 100% (756/756), done.
remote: Compressing objects: 100% (423/423), done.
remote: Total 2026 (delta 591), reused 397 (delta 330), pack-reused 1270 (from 1)
Receiving objects: 100% (2026/2026), 833.75 KiB | 212.00 KiB/s, done.
Resolving deltas: 100% (1079/1079), done.

$ npins init
[INFO ] Welcome to npins!
[INFO ] Creating `npins` directory
[INFO ] Writing default.nix
[INFO ] Writing initial sources.json with nixpkgs entry (need to fetch latest commit first)
[INFO ] Successfully written initial files to 'npins'.
[ble: elapsed 31.753s (CPU 38.4%)] npins init

$ npins add github nix-community mine-flake
[INFO ] Adding 'mine-flake' …
[ERROR] git ls-remote failed. stderr output:
[ERROR] > error: unable to read askpass response from '/nix/store/s84sf4hdbf4xkfd8mja0llp943l6ghpn-x11-ssh-askpass-1.2.4.1/libexec/x11-ssh-askpass'
[ERROR] > fatal: could not read Username for 'https://github.com': terminal prompts disabled
[ERROR] > 
Error: Failed to fully initialize the pin

Caused by:
    0: Couldn't fetch the release tags
    1: Failed to list tags for https://github.com/nix-community/mine-flake.git
    2: git ls-remote failed with exit code 128

$  npins add github nix-community mineflake
[INFO ] Adding 'mineflake'
    repository: https://github.com/nix-community/mineflake.git
    pre_releases: false
    version: v0.2.2
    revision: 40b5af8e870ff6f9ce95df49d64fd5311f2403ab
    hash: 1zw95pp9xrgmiy2iq00vwr4kfpvsnxs5x9w1snx19iqa8dpsf795

Seems to do the trick.

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

2 participants