The OS can't help as long as users can create files. But eco-systems (whether Rust, Go, Node or Python doesn't really matter) can help by managing their name spaces properly. The thing that went wrong here is that someone can silently replace a package in a namespace that you think is unique by overruling it through a namespace that takes precedence. Besides the obvious usability issues (this is not the kind of functionality that you would want in any circumstances) if a package suddenly gets pulled from an entirely different repository compared to where the previous instance came from and does so silently (without throwing an error and without so much as a pause to ask the user whether this really is what they want) then I really don't see what kind of OS level awareness of the world at large would be required to fix that.
The problem does not stem from the operating system level, and so it should not be fixed there, and it likely can't be fixed there, at least not without possibly breaking a whole bunch of stuff that is working just fine today.
The problem does not stem from the operating system level, and so it should not be fixed there, and it likely can't be fixed there, at least not without possibly breaking a whole bunch of stuff that is working just fine today.