Search code examples
opam

OPAM: Can I work on different switches at the same time in different shells?


This question is addressed in OPAM FAQ [1], but both solutions provided do not work with OPAM v.1.2.2, as env and exec commands are both unknown. How can I run a single command from the different switch?

[1] https://opam.ocaml.org/doc/2.0/FAQ.html#Can-I-work-on-different-switches-at-the-same-time-in-different-shells


Solution

  • You linked to the FAQ for opam 2.0. Here it is for opam 1.2: https://opam.ocaml.org/doc/FAQ.html#Can-I-work-on-different-switches-at-the-same-time-in-different-shells

    🐫 Can I work on different switches at the same time in different shells ?

    Yes. Use one of:

    eval $(opam config env --switch <switch>)        # for the current
    shell opam config exec --switch <switch> -- <command>  # for one command
    

    This only affects the environment.