Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam init --reinit without -ni has a confusing UI #5702

Open
kit-ty-kate opened this issue Oct 16, 2023 · 3 comments
Open

opam init --reinit without -ni has a confusing UI #5702

kit-ty-kate opened this issue Oct 16, 2023 · 3 comments

Comments

@kit-ty-kate
Copy link
Member

Whenever someone upgrades opam and does opam init --reinit -ni (as done in the install.sh script provided), the ${OPAMROOT}/opam-init/env_hook.{,z,c}sh file is removed and thus now users have to call eval $(opam env) manually.

This is because opam init --reinit by itself does not take into account what is was configured and reconfigures the env hook again, which removes it if it exists already.

Expected behaviour: By default opam init --reinit should always keep what was configured, thus -n shouldn't be needed anymore in the install script.

@rjbou
Copy link
Collaborator

rjbou commented Oct 16, 2023

Is it related to 1dfd536 ?

@kit-ty-kate
Copy link
Member Author

That looks to be indeed a regression in 2.2. I’ve added it to the todo list.

@kit-ty-kate
Copy link
Member Author

Nevermind it’s not a regression.

I can’t reproduce. I think i used opam init --reinit without argument and expected option 5 to not do anything instead of removing files.

<><> Required setup - please read <><><><><><><><><><><><><><><><><><><><><>  🐫

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

  However, to best integrate with your system, some environment variables
  should be set. If you allow it to, this initialisation step will update
  your zsh configuration by adding the following line to ~/.zshrc:

    [[ ! -r ~/.opam/opam-init/init.zsh ]] || source ~/.opam/opam-init/init.zsh  > /dev/null 2> /dev/null

  Otherwise, every time you want to access your opam installation, you will
  need to run:

    eval $(opam env)

  You can always re-run this setup with 'opam init' later.

Do you want opam to configure zsh?
> 1. Yes, update ~/.zshrc
  2. Yes, but don't setup any hooks. You'll have to run eval $(opam env) whenever you change your current 'opam switch'
  3. Select a different shell
  4. Specify another config file to update instead
  5. No, I'll remember to run eval $(opam env) when I need opam

I’m still keeping this issue opened as I think the interface on reinit is not the best but removed it from the 2.2 as it is not an issue for the release. I’ll rename the issue.

@kit-ty-kate kit-ty-kate changed the title opam init --reinit removed the previously configured "eval $(opam env)"-less setup opam init --reinit without -ni has a confusing UI Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants