You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever using system OCaml compilers in switches it can be easy to accidentally have the wrong system compiler in PATH when you have multiple compilers. This leads to accidentally creating a new switch with say a 4.13.1 compiler and then installing packages with a 4.12.1 compiler. I realise the PATH management is the user's responsibility but (if possible) it might be useful for opam to be able to detect that something isn't quite right when using a different system compiler?
More concretely assume I have a 4.13.1 switch in /foo/bin and a 4.12.1 compiler in the more conventional /usr/local/bin with the former not in PATH. I create a new switch:
$ PATH=/foo/bin:$PATH opam switch create system 4.13.1
Opam creates a new switch called system with the 4.13.1 compiler it found in PATH. Now I install say ocaml-lsp-server forgetting to set PATH correctly such that the 4.13.1 compiler is the first compiler that will be found:
I realise this is pretty niche but I was just wondering if there is some sort of check that could be done to provide a better error message perhaps? Opam does catch if the system compiler is no longer in the right place i.e. if you mv /foo/bin /bar/bin and then opam install you get:
[WARNING] System file /foo/bin/ocamlc, which package ocaml-system.4.13.1 depends upon, no longer
exists.
The package will need to either be removed, or reinstalled. You may need to restore its system dependencies for
the latter.
The compiler itself is something abstract for opam. It only knows about a package that have the flag compiler, and that need to perform specific actions with it (for switch eg.). What makes ocaml-system detect ocamlc move, is that ocaml-system config file contains the detected path, and this path (and its checksum) is checked afterwards by opam. As long the file is unchanged, opam won't notice.
What can be done is to check if it is an executable, and in this case check if it is reachable from PATH.
Whenever using system OCaml compilers in switches it can be easy to accidentally have the wrong system compiler in
PATH
when you have multiple compilers. This leads to accidentally creating a new switch with say a4.13.1
compiler and then installing packages with a4.12.1
compiler. I realise thePATH
management is the user's responsibility but (if possible) it might be useful for opam to be able to detect that something isn't quite right when using a different system compiler?More concretely assume I have a
4.13.1
switch in/foo/bin
and a4.12.1
compiler in the more conventional/usr/local/bin
with the former not inPATH
. I create a new switch:Opam creates a new switch called
system
with the4.13.1
compiler it found inPATH
. Now I install sayocaml-lsp-server
forgetting to setPATH
correctly such that the4.13.1
compiler is the first compiler that will be found:I realise this is pretty niche but I was just wondering if there is some sort of check that could be done to provide a better error message perhaps? Opam does catch if the system compiler is no longer in the right place i.e. if you
mv /foo/bin /bar/bin
and thenopam install
you get:Thanks :))
Config Report
The text was updated successfully, but these errors were encountered: