ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 354 forks source link

confirm-level=ask is actually yes? #4900

Open vphantom opened 2 years ago

vphantom commented 2 years ago

I can't figure out what I did to trigger this, or if it's actually a bug in 2.1.0, but --confirm-level=yes is assumed by default in my setup. If I use --confirm-level=ask explicitly to try to get the old behavior, it incorrectly behaves as though I had specified yes. If I use --confirm-level=no however, then no is correctly assumed.

I'm not running opam through a wrapper script which might make it think the tty is non-interactive.

Any ideas?

$ set |grep OPAM
OPAM_SWITCH_PREFIX=/home/lis/.opam/4.13.1+musl+flambda
$ if tty -s; then echo Interactive; else echo Non-interactive; fi
Interactive
# opam config report
# opam-version         2.1.0
# self-upgrade         no
# system               arch=x86_64 os=linux os-distribution=debian os-version=10
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 7
# repositories         1 (http) (default repo at c7b1bb0d)
# pinned               0
# current-switch       4.13.1+musl+flambda
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /home/lis/.opam/4.13.1+musl+flambda/lib/ocaml/stublibs:/home/lis/.opam/4.13.1+musl+flambda/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       4.13.1+options+flambda+musl
kit-ty-kate commented 2 years ago

What is the command that gets you this behaviour?

vphantom commented 2 years ago

It's across the board. For example opam install sexp will go right ahead and assume "yes" at the "13 to install, do you want to continue?" prompt.

rjbou commented 2 years ago

if yes is activated by --confirmlevel, --yes, or environment variable, you shouldn't have the prompt Do you want to continue?


$ opam install sexp
The following actions will be performed:
  ∗ install conf-g++                1.0     [required by re2]
[...]
  ∗ install sexp                    v0.14.0
===== ∗ 73 =====
Do you want to continue? [Y/n] n
# I answer 'n'

$ opam install sexp --confirm-level=ask
The following actions will be performed:
  ∗ install conf-g++                1.0     [required by re2]
[...]
  ∗ install sexp                    v0.14.0
===== ∗ 73 =====
Do you want to continue? [Y/n] n
# I answer 'n'

$ opam install sexp --confirm-level=yes
The following actions will be performed:
  ∗ install conf-g++                1.0     [required by re2]
[...]
  ∗ install sexp                    v0.14.0
===== ∗ 73 =====

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved async.v0.14.0  (https://opam.ocaml.org/cache)
⬇ retrieved async_kernel.v0.14.0  (https://opam.ocaml.org/cache)
[ERROR] User interruption
vphantom commented 2 years ago

Weird. In my case I always see the prompt, but it is answered automatically. I can't seem to convince opam that I want interaction.

kit-ty-kate commented 2 years ago

Reading the code for this, I think the issue is that somehow on your machine you’re hitting some kind of Unix exception https://github.com/ocaml/opam/blob/master/src/core/opamConsole.ml#L757 As to why, i have no idea. If you’re feeling up to it you can try adding logs to this function and see what breaks but without knowing what is different on your system I have no idea how to debug this.

By any chance, how did you install opam? Through the precomiled binaries/install.sh or something else?

vphantom commented 2 years ago

I initially used the install.sh but I think that for the upgrade to 2.1.0 I just downloaded the prebuilt binary from GitHub. A binary diff confirms that it's the binary I'm currently using.

Of note is that I use kitty as my terminal and do everything in tmux. I have the relevant files for both in my ~.terminfo/. This was already the case when I used opam <2.1.0 and interactive prompts worked as expected.

rjbou commented 2 years ago

If we prepare a branch, is it possible for you to test it?

vphantom commented 2 years ago

I don't understand the instructions at that page. The "From Source" section doesn't mention any compiling step.

But yes if there's something I can A/B test vs 2.1.0 I'd be happy to help. 😃

rjbou commented 2 years ago

It's normal that there is no compilation step. As you install everything with your opam, you don't need to compile things yourself :) I'll prepare you a branch to test then.