opam icon indicating copy to clipboard operation
opam copied to clipboard

`Required setup` message contains incorrect path to opam root when using `OPAMROOT`

Open Khady opened this issue 3 years ago • 4 comments
trafficstars

If I set the opam root to be non default, with the OPAMROOT env variable, during opam init the required setup section still points to ~/.opam instead of the content of OPAMROOT

$ export OPAMROOT="/tmp/opam-root"
$ opam init --bare
[ ... ]
<><> Required setup - please read <><><><><><><><><><><><><><><><><><><><><><><>

  In normal operation, opam only alters files within ~/.opam.
[ ... ]

opam 2.1.0

Khady avatar Jan 13 '22 14:01 Khady

The message still holds though. "normal operation" refers to "opam without any environment variable set". The next line states:

  In normal operation, opam only alters files within ~/.opam.

  However, to best integrate with your system, some environment variables
  should be set.

But I understand the confusion. Maybe we could replace this by:

  In normal operation, opam only alters files within ~/.opam.
  In your particular case, $OPAMROOT has been set to $your-path, thus as long as --root or $OPAMROOT is set, only files within $your-path will be altered.

  However, to best integrate with your system, some environment variables
  should be set.

when $OPAMROOT is set. But it might be a bit verbose.

Maybe we should rethink this message entirely instead. Any ideas?

kit-ty-kate avatar Jan 13 '22 14:01 kit-ty-kate

Suggestion:

  • if $OPAMROOT is not defined:
In normal operation, opam only alters files within ~/.opam.

as before

  • if it is defined:
In normal operation, opam only alters files within %{opamroot}%.

(verbatim, don't expand the variable)

AltGr avatar Jan 14 '22 10:01 AltGr

Only problem with that is that it doesn't cover --root. It's reasonable to assume that this only happens to a user who knows about roots (because they have set OPAMROOT or added --root) so it could reasonably be: "opam only alters files within your opam root (~/.opam)" and display the actual value if it's not the default. Referring to the opam root in the message loosely covers the case where you then unset OPAMROOT later.

dra27 avatar Jan 14 '22 10:01 dra27

(putting in 2.2 as the Windows shell stuff touches this message anyway, and it's not a big change!)

dra27 avatar Jan 14 '22 10:01 dra27