markjgsmith

Git complains about a non-existent branch while npm installing

2025-01-07 18:37:00 +07:00 by Mark Smith

One of the odd things that happened yesterday was getting completely blocked on Github. The problem turned out to be my fault, but the world certainly didn’t make it any easier. The error I was seing during npm install in my Github action was the slightly cryptic:

npm error npm error command git --no-replace-objects checkout fix-remove-itemlistsclass npm error npm error error: pathspec 'fix-remove-itemlistsclass' did not match any file(s) known to git

I followed the troubleshooting path where it led, right down to the end, eventually deleting all branches apart from the main branch, and was completely stumped. Turned out I had innadvertantly left a bit of test config in one of the repos. It was pointing to a git hosted feature branch of one of it’s dependencies intead of the main branch.

That fact was being hidden because (1) I hadn't done a git pull following merging in it’s feature branch and (2) there was a red herring feature branch name mis-spelling that had been introduced. Bugs hidding behind bugs hiding behind bugs.

These sorts of configuration snafus are an easy mistake to make, especially when you are juggling merging in changes to 6-7 repos at once, all on a small screen. I had checked them all a couple of times, but clearly must have been momentarily distracted both times. That’s certainly not a suprise to me, my whole life feels like a big distraction at the minute.

Anyhow, I eventually found the problem when another programmer online that read the error message I had been presented with made an educated guess. In retrospec it seems obvious, but when you are neck deep in it, it’s anything but obvious. I had gotten rid of all the jungle and brambles but needed that extra pair of eyes, and a clear head, to actually see the solution, which was right in front of me.

It was a bit of a scarier issue than the norm because the only way to test it ended up being to do it on the live website, which wasn’t ideal, but I had exhausted literally all other options. So when it failed in prod, that blocked everything. Once I updated the config though, the plugin started building again and all my website builds started completing without errors.

Hopefully now that I’ve written about it, I’ll remember it in case it happens again. If git is complaining about a branch that doesn’t exist when you are npm installing, it’s probably because somewhere one of your dependencies is pointing at a feature branch that previously existed. #

For enquiries about my consulting, development, training and writing services, aswell as sponsorship opportunities contact me directly via email. More details about me here.