Git push - no gh found in bin

Hi, I tried to push some code changes to my local github repo where I have authenticated through the Github CLI, gh . It worked fine last week but this week i get the following error:

[muitilingualism@yaboi:/etc/nixos]$ git push origin main
/nix/store/n5n5ksn2pykk9a2y50zsv0znw0jly2mc-gh-2.49.2/bin/gh auth git-credential get: line 1: /nix/store/n5n5ksn2pykk9a2y50zsv0znw0jly2mc-gh-2.49.2/bin/gh: No such file or directory

And the following window shows up which prompts for my GitHub username:

image

(Filling out this prompt obviously won’t work as this form of direct authentication is not supported anymore).

I recently did a garbage collection on my system, and this is the only “change” I have made to my nix system:

These two are the commands in my terminal history:

 4479  nix-env --delete-generations 30d
 4480  nix-collect-garbage --delete-older-than 30d

gh still works (kinda), when I try to authenticate

[muitilingualism@yaboi:/etc/nixos]$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: XXXX-XXXX
Press Enter to open github.com in your browser... 
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
open /home/muitilingualism/.config/gh/config.yml: read-only file system

Not sure what to do. Doing sudo nixos-rebuild switch did not resolve the issue.

Hope someone can help, thanks!

Got it resolved by changing the credential helper!

Pointing git to use the actual location gh.

git config --global credential.helper ""
git config --global credential.helper "/etc/profiles/per-user/muitilingualism/bin/gh auth git-credential"

I think the problem was caused with how I initially installed NixOS on this machine. When I install NixOS on a new machine I use nix-shell -p gh vim git. I then authenticate with gh auth login and pull my config from GitHub with git clone <repo-loc>.

Because this initial installation of gh and git together. The git credential helper was pointing to the nix-shell installation of gh instead of my home-manager installation which came after.

Not sure what is a better way to install my config on a new NixOS machine, if anybody have any tips let me know or point me in the right direction!