caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] opam local switch
@ 2014-09-18 21:20 Yotam Barnoy
  2014-09-18 21:24 ` Anil Madhavapeddy
  2014-09-19  7:21 ` Louis Gesbert
  0 siblings, 2 replies; 7+ messages in thread
From: Yotam Barnoy @ 2014-09-18 21:20 UTC (permalink / raw)
  To: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

I have a question about opam. I would like to play with certain compiler
versions, but I don't want the switch to happen globally, because I still
need to compile regular code. Is it possible to switch to another compiler
locally (within a particular shell session) via environment variables,
while using my regular compiler in another shell session?

If this is the way things work already, I apologize in advance -- it
appeared to me that running opam switch modifies some global state that
directly affects other pre-existing shell sessions.

-Yotam

[-- Attachment #2: Type: text/html, Size: 629 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-18 21:20 [Caml-list] opam local switch Yotam Barnoy
@ 2014-09-18 21:24 ` Anil Madhavapeddy
  2014-09-18 21:50   ` Yotam Barnoy
  2014-09-19  7:21 ` Louis Gesbert
  1 sibling, 1 reply; 7+ messages in thread
From: Anil Madhavapeddy @ 2014-09-18 21:24 UTC (permalink / raw)
  To: Yotam Barnoy; +Cc: Ocaml Mailing List

On 18 Sep 2014, at 22:20, Yotam Barnoy <yotambarnoy@gmail.com> wrote:

> I have a question about opam. I would like to play with certain compiler versions, but I don't want the switch to happen globally, because I still need to compile regular code. Is it possible to switch to another compiler locally (within a particular shell session) via environment variables, while using my regular compiler in another shell session?
> 
> If this is the way things work already, I apologize in advance -- it appeared to me that running opam switch modifies some global state that directly affects other pre-existing shell sessions.

It's worth reading the man page for OPAM ("man opam" or "opam --help"), which lists all the environment variables and command-line options available.

There is OPAMSWITCH (or the command line --switch option) which will fix a particular switch to run the opam command set in.

best,
Anil


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-18 21:24 ` Anil Madhavapeddy
@ 2014-09-18 21:50   ` Yotam Barnoy
  2014-09-18 22:28     ` Grégoire Henry
  0 siblings, 1 reply; 7+ messages in thread
From: Yotam Barnoy @ 2014-09-18 21:50 UTC (permalink / raw)
  To: Anil Madhavapeddy; +Cc: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 1430 bytes --]

OPAMSWITCH appears undocumented, though it's referred to in the man page
under opam --switch ("This is equivalent to setting $OPAMSWITCH")

My question is, if I set OPAMSWITCH, will I then be able to run regular
(non-opam) ocaml build commands in the local shell in the given compiler,
while running commands in a different shell with a different compiler? If
not, is such a feature planned?

-Yotam

On Thu, Sep 18, 2014 at 5:24 PM, Anil Madhavapeddy <anil@recoil.org> wrote:

> On 18 Sep 2014, at 22:20, Yotam Barnoy <yotambarnoy@gmail.com> wrote:
>
> > I have a question about opam. I would like to play with certain compiler
> versions, but I don't want the switch to happen globally, because I still
> need to compile regular code. Is it possible to switch to another compiler
> locally (within a particular shell session) via environment variables,
> while using my regular compiler in another shell session?
> >
> > If this is the way things work already, I apologize in advance -- it
> appeared to me that running opam switch modifies some global state that
> directly affects other pre-existing shell sessions.
>
> It's worth reading the man page for OPAM ("man opam" or "opam --help"),
> which lists all the environment variables and command-line options
> available.
>
> There is OPAMSWITCH (or the command line --switch option) which will fix a
> particular switch to run the opam command set in.
>
> best,
> Anil
>
>

[-- Attachment #2: Type: text/html, Size: 1914 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-18 21:50   ` Yotam Barnoy
@ 2014-09-18 22:28     ` Grégoire Henry
  2014-09-18 22:29       ` Yotam Barnoy
  0 siblings, 1 reply; 7+ messages in thread
From: Grégoire Henry @ 2014-09-18 22:28 UTC (permalink / raw)
  To: Yotam Barnoy; +Cc: OCaml Mailing List

Hi,

> My question is, if I set OPAMSWITCH, will I then be able to run regular
> (non-opam) ocaml build commands in the local shell in the given compiler,
> while running commands in a different shell with a different compiler?

No, it is not. But, what you are looking for is probably:

  eval $(opam config env --switch 3.12.1)

This will setup the proper environment for ocaml-3.12.1 in the current
terminal (including the OPAMSWITCH variable) without changing the
"global default switch".

The previous command is equivalent to:

  export OPAMSWITCH=3.12.1
  eval $(opam config env)

-- Grégoire

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-18 22:28     ` Grégoire Henry
@ 2014-09-18 22:29       ` Yotam Barnoy
  0 siblings, 0 replies; 7+ messages in thread
From: Yotam Barnoy @ 2014-09-18 22:29 UTC (permalink / raw)
  To: Grégoire Henry; +Cc: OCaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

Awesome, thanks.

On Thu, Sep 18, 2014 at 6:28 PM, Grégoire Henry <gregoire.henry@ocamlpro.com
> wrote:

> Hi,
>
> > My question is, if I set OPAMSWITCH, will I then be able to run regular
> > (non-opam) ocaml build commands in the local shell in the given compiler,
> > while running commands in a different shell with a different compiler?
>
> No, it is not. But, what you are looking for is probably:
>
>   eval $(opam config env --switch 3.12.1)
>
> This will setup the proper environment for ocaml-3.12.1 in the current
> terminal (including the OPAMSWITCH variable) without changing the
> "global default switch".
>
> The previous command is equivalent to:
>
>   export OPAMSWITCH=3.12.1
>   eval $(opam config env)
>
> -- Grégoire
>

[-- Attachment #2: Type: text/html, Size: 1209 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-18 21:20 [Caml-list] opam local switch Yotam Barnoy
  2014-09-18 21:24 ` Anil Madhavapeddy
@ 2014-09-19  7:21 ` Louis Gesbert
  2014-09-19  7:30   ` Gabriel Scherer
  1 sibling, 1 reply; 7+ messages in thread
From: Louis Gesbert @ 2014-09-19  7:21 UTC (permalink / raw)
  To: caml-list, Yotam Barnoy

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

Le jeudi 18 septembre 2014, 17:20:37 Yotam Barnoy a écrit :
> I have a question about opam. I would like to play with certain compiler
> versions, but I don't want the switch to happen globally, because I still
> need to compile regular code. Is it possible to switch to another compiler
> locally (within a particular shell session) via environment variables,
> while using my regular compiler in another shell session?
> 
> If this is the way things work already, I apologize in advance -- it
> appeared to me that running opam switch modifies some global state that
> directly affects other pre-existing shell sessions.
> 
> -Yotam
> 
> 

This is already in our new FAQ [1] :)
We're just waiting for 1.2 to be out before we post the new doc pages, because some of it doesn't apply to the current 1.1 stable release. OPAM 1.2 is still in RC stage.


[1] 
http://opam.ocaml.org/doc/1.2/FAQ.html#CanIworkondifferentswitchesatthesametimeindifferentshells

[-- Attachment #2: Type: text/html, Size: 4341 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] opam local switch
  2014-09-19  7:21 ` Louis Gesbert
@ 2014-09-19  7:30   ` Gabriel Scherer
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Scherer @ 2014-09-19  7:30 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml users, Yotam Barnoy

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

Note that you can also use

  opam config exec --switch=<SWITCH> -- <COMMAND>

to execute a command with a local switch choice. This is very helpful in
contexts where you don't exactly remember how to setup the environment (eg.
when prompted for an in-Emacs compilation command), or you want to play
with several versions alternatively in a single terminal (testing a
regression in new OCaml versions).

On Fri, Sep 19, 2014 at 9:21 AM, Louis Gesbert <louis.gesbert@ocamlpro.com>
wrote:

>  Le jeudi 18 septembre 2014, 17:20:37 Yotam Barnoy a écrit :
>
> > I have a question about opam. I would like to play with certain compiler
>
> > versions, but I don't want the switch to happen globally, because I still
>
> > need to compile regular code. Is it possible to switch to another
> compiler
>
> > locally (within a particular shell session) via environment variables,
>
> > while using my regular compiler in another shell session?
>
> >
>
> > If this is the way things work already, I apologize in advance -- it
>
> > appeared to me that running opam switch modifies some global state that
>
> > directly affects other pre-existing shell sessions.
>
> >
>
> > -Yotam
>
> >
>
> >
>
>
>
> This is already in our new FAQ [1] :)
>
> We're just waiting for 1.2 to be out before we post the new doc pages,
> because some of it doesn't apply to the current 1.1 stable release. OPAM
> 1.2 is still in RC stage.
>
>
>
>
>
> [1]
>
>
> http://opam.ocaml.org/doc/1.2/FAQ.html#CanIworkondifferentswitchesatthesametimeindifferentshells
>

[-- Attachment #2: Type: text/html, Size: 4183 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-19  7:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18 21:20 [Caml-list] opam local switch Yotam Barnoy
2014-09-18 21:24 ` Anil Madhavapeddy
2014-09-18 21:50   ` Yotam Barnoy
2014-09-18 22:28     ` Grégoire Henry
2014-09-18 22:29       ` Yotam Barnoy
2014-09-19  7:21 ` Louis Gesbert
2014-09-19  7:30   ` Gabriel Scherer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).