update_installed_extensions.sh
will ALWAYS fail with the redhat.java (and possibly others) extensions
#329271
Labels
0.kind: bug
Something is broken
Hi! I've found a pretty nasty (bug? ms issue? extension issue?) thing that I would like to raise as an issue, in case someone else runs into the same mind twisting nonsense.
A few months back I wrote a relatively simple script called code2nix, which was intended to convert my vscode extensions -> nix expressions. It has since worked flawlessly until yesterday, when I tried it and it would consistently fail when pulling the latest versions but would pass when pulling whatever I had currently installed.
Strange! So I went to debugging and attempting tests. What I discovered was honestly mind boggling. Every single time the hash of certain extensions kept randomly changing. Furthermore, there was indeed one singular extension that would consistently fail when pulling its latest. Which one?
redhat.java
. After realizing this I quickly took to figuring out what the hell was going on, and I discovered that while both were internally VERSIONED the same (1.33.2024072008
at the time of writing), the file content was subtly different.Here's a simple shell snippet to see what I mean:
However:
A completely different narHash and store path!? Now of course you must be thinking, well obviously these must be completely different versions of the extension, right? Well...
For some reason, these files are versioned the exact same, but actually contain some kind of difference. I extracted the files using unzip and reviewed the file structure with
diff
and found:Seems the difference is in the
extension.vsixmanifest
and[Content_Types].xml
. I'm not quite sure who to pin the blame for this since this is an issue that I can only so far find with this specific extension. Maybe its a combination of both.So why does this all matter? This matters because https://github.com/NixOS/nixpkgs/blob/71770c17e76268cb001cf03ad670a01db8d00ad6/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh will occasionally fail if given extensions like this. Actually this was the second script I attempted to try after my own app failed me, thinking that maybe I had actually missed a bug, but no, it turns out the root issue was impure nonsense from upstream. This is an issue that can easily propagate and can lead to a lot of confusing issues if not known about.
The personal fix I am planning to implement is to pull the latest package, pull the version, then re-download the versioned package and use that for hashing. Super inefficient but its unfortunately necessary in this context. I don't really know if a similar approach is feasible for nixpkgs, but I figure I should both share my findings and my take on a "solution" for others who may struggle with the same behaviour.
If anyone feels like having an evening laugh, feel free to take a look at the commit history here, noting especially how the hashes will randomly change when pulling certain versioned things vs. certain latest things. My personal favorite has to be this commit where the hashes completely swap despite no logical reason to.
The text was updated successfully, but these errors were encountered: