ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.21k stars 348 forks source link

Allowing packages to override default environment updates #6051

Open dra27 opened 1 week ago

dra27 commented 1 week ago

Opening this is as a draft PR so it doesn't get forgotten. This has come up in the context of https://github.com/ocaml/opam-repository/pull/25928.

The problem is that it is not possible for a package to prepend a directory before opam's bin directory in PATH and this feels like a mistake. Given, say, /usr/local/bin:/usr/bin:/bin etc. in a standard posix PATH, it feels reasonable that opam prepends the switch bin directory before packages - i.e. we have <package-PATH-directory>:<switch-PATH-directory>:/usr/local/bin:/usr/bin:/bin. This is also mildly more coherent with other environment variable updates in build-env, which the manual explicitly states can be overridden.

In the context of the opam-repository PR above, it means that

build-env: PATH += "%{some-package:share}%/bin"

doesn't allow binaries in the additional directory to override those in the switch directory, which seems incorrect.