# Stop opam blurb about environment sync

**URL:** https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649
**Category:** Ecosystem
**Tags:** opam, script
**Created:** [October 23, 2020, 3:27pm UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649 "2020-10-23T15:27:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nobrowser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nobrowser/32/2099_2.png) [@nobrowser](https://discuss.ocaml.org/u/nobrowser)
#### Post date: [October 23, 2020, 3:27pm UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649/1 "2020-10-23T15:27:48Z")

</div>

Is there any way, when running `opam switch`, to turn off the blurb about needing `opam env` next? I want to use `opam switch` in a script, and it is indeed followed by sourcing the output of `opam env`. But the blurb is distracting, I want the script to run silently when successful. And OTOH I don’t want to send stderr to `/dev/null` lest I miss a real error message.

---

<div class="post-metadata">

### Author: ![Khady](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/khady/32/469_2.png) [@Khady](https://discuss.ocaml.org/u/Khady)
#### Post date: [October 23, 2020, 5:56pm UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649/2 "2020-10-23T17:56:10Z")

</div>

You can skip the `opam switch` invocation and do `eval $(opam env --switch=the_name --set-switch)` instead. It is equivalent to `opam switch the_name && eval $(opam env)`. I am not 100% sure if the `--set-switch` part is needed, but I believe so.

---

<div class="post-metadata">

### Author: ![Chet\_Murthy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chet_murthy/32/1501_2.png) [@Chet\_Murthy](https://discuss.ocaml.org/u/Chet_Murthy)
#### Post date: [October 23, 2020, 6:09pm UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649/3 "2020-10-23T18:09:00Z")

</div>

While I share your distaste at superfluous messages from commands I’d like to use in scripts, maybe this would help?

```auto
$ opam switch 4.10.1 | 2>&1 grep -v 'update the current'
$ opam switch 4.10.1
# Run eval $(opam env) to update the current shell environment
$ opam switch 4.10.1 | 2>&1 grep -v 'update the current'
$ 

```

---

<div class="post-metadata">

### Author: ![nobrowser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nobrowser/32/2099_2.png) [@nobrowser](https://discuss.ocaml.org/u/nobrowser)
#### Post date: [October 23, 2020, 10:17pm UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649/4 "2020-10-23T22:17:08Z")

</div>

Hi, I was going to do just this … but I just recently had to do it for another program [1] and I was a bit fed up 😛 @Khady suggestion looks perfect alhough I have not tested it yet.

[1] [feed2exec](https://gitlab.com/anarcat/feed2exec)

---

<div class="post-metadata">

### Author: ![xavierleroy](https://avatars.discourse-cdn.com/v4/letter/x/a9adbd/32.png) [@xavierleroy](https://discuss.ocaml.org/u/xavierleroy)
#### Post date: [October 24, 2020, 8:44am UTC](https://discuss.ocaml.org/t/stop-opam-blurb-about-environment-sync/6649/5 "2020-10-24T08:44:58Z")

</div>

In a script you generally don’t want to run `opam switch`, because it changes a global state, affecting later runs of `opam` in other windows, for example.

In my experience, `eval $(opam env --switch=...)` works fine, and has no side-effects beyond the current script.
