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.21k stars 348 forks source link

switch create --dry-run actually creates folder #5918

Open tuohy opened 3 months ago

tuohy commented 3 months ago

Current behavior:

$ opam switch --dry-run create lts ocaml=4.14.2

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {= "4.14.2"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Installing base-bigarray.base.
∗ installed base-bigarray.base
Installing base-threads.base.
∗ installed base-threads.base
Installing base-unix.base.
∗ installed base-unix.base
Installing ocaml-options-vanilla.1.
∗ installed ocaml-options-vanilla.1
Installing ocaml-base-compiler.4.14.2.
∗ installed ocaml-base-compiler.4.14.2
Installing ocaml-config.2.
∗ installed ocaml-config.2
Installing ocaml.4.14.2.
∗ installed ocaml.4.14.2
Done.
# Run eval $(opam env --switch=lts) to update the current shell environment
$ opam switch --dry-run create lts ocaml=4.14.2
[ERROR] Directory "/home/username/.opam/lts" already exists, please choose a different name
~$ tree -a ~/.opam/lts
/home/username/.opam/lts
└── .opam-switch
    ├── build
    ├── install
    │   ├── base-bigarray.changes
    │   ├── base-threads.changes
    │   ├── base-unix.changes
    │   ├── ocaml-base-compiler.changes
    │   ├── ocaml.changes
    │   ├── ocaml-config.changes
    │   └── ocaml-options-vanilla.changes
    └── packages
        └── cache

4 directories, 8 files

Expected behavior: --dry-run commands should not write to the filesystem at all outside opam's internal caches

# opam config report
# opam-version         2.1.2
# self-upgrade         no
# system               arch=x86_64 os=linux os-distribution=ubuntu os-version=22.04
# 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), 1 (version-controlled) (default repo at b8624d2c)
# pinned               0
# current-switch       dev2
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /home/username/.opam/dev2/lib/ocaml/stublibs:/home/username/.opam/dev2/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.1.1
kit-ty-kate commented 3 months ago

Thanks for your report. I was able to reproduce with the latest version (2.2.0~beta2)