cabal install isn’t the problem, the problem is --lib, which the error messages tell you to use.
According to posters on this thread, even --lib is safe to use under modern v2 / nix-style builds, because cabal-install (the executable) creates a dummy package env per build.
However, as I keep on trying to emphasize there, --lib is a general disaster. The only valid use, imo, is to create a package environment file by cabal install base --lib, and then it’s still footgunny once the package environment file exists (because apparently you’ll end up with different versions of the same package with the same identifier; cabal itself doesn’t care, but ghci / ghc do).
What I’d suggest would be:
- cabal install --lib is dead; it’s marked experimental and I’m unsure as to anyone wants to finish the experiment?
- cabal pkgenv and cabal pkgenv globalclean comes in with an unsafe warning.
Long-term, I hear some people working cabal seem interested in managing the global package env, but I guess it’s more a question of speculation, since that requires labor and effort, and… ummm…