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

Installation of ocp-indent fails on Windows under Cygwin with CYGWIN=winsymlinks:nativestrict #6185

Open
nojb opened this issue Sep 1, 2024 · 2 comments
Assignees

Comments

@nojb
Copy link

nojb commented Sep 1, 2024

I tried to install ocamlformat.0.26.2 under Windows (running under Cygwin, with the Mingw64 compiler), and it fails when trying to install ocp-indent. I have CYGWIN=winsymlinks:nativestrict set (see https://cygwin.com/cygwin-ug-net/using-cygwinenv.html).

$ opam reinstall ocp-indent
The following actions will be performed:
=== recompile 3 packages
  ↻ ocamlformat     0.26.2 [uses ocamlformat-lib]
  ↻ ocamlformat-lib 0.26.2 [uses ocp-indent]
  ↻ ocp-indent      1.8.1

Proceed with ↻ 3 recompilations? [y/n]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[ERROR] Failed to get sources of ocp-indent.1.8.1: "C:\\cygwin64\\bin\\tar.exe xfz /cygdrive/c/Users/nojebar/AppData/Local/opam/download-cache/md5/70/70db6649a8c08a682ad63730c9752e31 -C /tmp/opam-11712-2b7ba0" exited with code 2
⬇ retrieved ocamlformat.0.26.2, ocamlformat-lib.0.26.2  (cached)

#=== ERROR while fetching sources for ocp-indent.1.8.1 ========================#
OpamSolution.Fetch_fail("\027[33m#\027[0m \027[33mpath\027[0m        ~\\dune\n\027[33m#\027[0m \027[33mcommand\027[0m     C:\\cygwin64\\bin\\tar.exe xfz /cygdrive/c/Users/nojebar/AppData/Local/opam/download-cache/md5/70/70db6649a8c08a682ad63730c9752e31 -C /tmp/opam-11712-2b7ba0\n\027[33m#\027[0m \027[33mexit-code\027[0m   2\n\027[33m#\027[0m \027[33menv-file\027[0m    ~\\AppData\\Local\\opam\\log\\log-11712-2a98a1.env\n\027[33m#\027[0m \027[33moutput-file\027[0m ~\\AppData\\Local\\opam\\log\\log-11712-2a98a1.out\n\027[33m### output ###\n\027[0m\027[33m# \027[0m/usr/bin/tar: ocp-indent-1.8.1/tests/inplace/link.ml: Cannot create symlink to \226\128\152otherfile.ml\226\128\153: No such file or directory\n\027[33m# \027[0m/usr/bin/tar: ocp-indent-1.8.1/tests/inplace/link2.ml: Cannot create symlink to \226\128\152link.ml\226\128\153: No such file or directory\n\027[33m# \027[0m/usr/bin/tar: Exiting with failure status due to previous errors\n")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ ⬇ fetch ocp-indent 1.8.1
└─
╶─ No changes have been performed
# Run eval $(opam env) to update the current shell environment

If I set CYGWIN=winsymlinks:native, then it passes, with a warning:

$ CYGWIN=winsymlinks:native opam install ocp-indent
The following actions will be performed:
=== install 1 package
  ∗ ocp-indent 1.8.1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[WARNING] Warning: cannot copy C:\cygwin64\tmp\opam-23436-2572f7\ocp-indent-1.8.1\tests\inplace\link.ml to C:\Users\nojebar\dune\_opam\.opam-switch\sources\ocp-indent.1.8.1\tests\inplace
⬇ retrieved ocp-indent.1.8.1  (cached)
∗ installed ocp-indent.1.8.1
Done.

My config:

nojebar@PERVERSESHEAF ~/dune
$ opam config report
# opam config report
# opam-version         2.2.1
# self-upgrade         no
# system               arch=x86_64 os=win32 os-distribution=cygwin os-version=10.0.22621
# 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                 11
# repositories         1 (http) (default repo at f45685efec14dffa74b060edb3fcc572bfcea34c)
# pinned               0
# current-switch       C:\Users\nojebar\dune
# invariant            []
# compiler-packages    arch-x86_64.1, conf-mingw-w64-gcc-x86_64.1, flexdll.0.43, mingw-w64-shims.0.2.0, ocaml-base-compiler.5.2.0, ocaml-env-mingw64.1, ocaml-options-vanilla.1, system-mingw.1
# mingw-w64-shims:runtime-x86_64 C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin
# mingw-w64-shims:runtime-i686
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       C:/Users/nojebar/dune/_opam/lib/ocaml/stublibs;C:/Users/nojebar/dune/_opam/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.2.0
@dra27 dra27 self-assigned this Sep 3, 2024
@dra27
Copy link
Member

dra27 commented Sep 10, 2024

At some point, we would like to switch to using ocaml-tar for the extraction, which would solve this, but the problem usually is having a tarball where the symlink appears before the file itself - this is a problem on Windows, but not on Unix (this is the reason for the mitigation added in #5953 which you can see with your winsymlinks:native version). Having dangling symlinks in a tarball will always be a problem and we should encourage any package which ships tarballs like that, um, not to!

opam internally sets CYGWIN=winsymlinks:native if it detects that native symbolic links are available - I opted to preserve the winsymlinks:nativestrict for Cygwin, on the basis that the user knows best. I'm persuadable, but at the moment, opam is kinda operating as intended.

Note that MSYS2 has a fallback to copying for symlinks, but as far as I know Cygwin doesn't have an equivalent mode for doing that.

@nojb
Copy link
Author

nojb commented Sep 11, 2024

Thanks for the explanation @dra27!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants