Installation of `ocp-indent` fails on Windows under Cygwin with `CYGWIN=winsymlinks:nativestrict`
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
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.
Thanks for the explanation @dra27!
Same issue on Windows MSYS2 @dra27
PS C:\Users\alex> opam install ocp-indent
The following actions will be performed:
=== install 1 package
∗ ocp-indent 1.8.1
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ERROR] Failed to get sources of ocp-indent.1.8.1: "D:\\msys64\\usr\\bin\\tar.exe xfz /c/Users/alex/AppData/Local/opam/download-cache/md5/70/70db6649a8c08a682ad63730c9752e31 -C
/c/Users/alex/AppData/Local/Temp/opam-17280-d4c91e" exited with code 2
#=== ERROR while fetching sources for ocp-indent.1.8.1 ========================#
OpamSolution.Fetch_fail("\027[33m#\027[0m \027[33mpath\027[0m ~\n\027[33m#\027[0m \027[33mcommand\027[0m D:\\msys64\\usr\\bin\\tar.exe xfz /c/Users/alex/AppData/Local/opam/download-cache/md5/70/70db6649a8c08a682ad63730c9752e31 -C /c/Users/alex/AppData/Local/Temp/opam-17280-d4c91e\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-17280-e38eb0.env\n\027[33m#\027[0m \027[33moutput-file\027[0m ~\\AppData\\Local\\opam\\log\\log-17280-e38eb0.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 'otherfile.ml': 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 'link.ml': 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
My configuration:
PS C:\Users\alex> opam config report
# opam config report
# opam-version 2.3.0
# self-upgrade no
# system arch=x86_64 os=win32 os-distribution=msys2 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 7
# repositories 1 (version-controlled)
# pinned 0
# current-switch default
# invariant ["ocaml" {>= "4.05.0"}]
# compiler-packages arch-x86_64.1, conf-mingw-w64-gcc-x86_64.1, flexdll.0.43, msys2.0.1.0, msys2-mingw64.1, ocaml-base-compiler.5.2.1, ocaml-env-mingw64.1, ocaml-options-vanilla.1, system-mingw.1
# msys2:msystem MINGW64
# msys2:carch x86_64
# msys2:chost x86_64-w64-mingw32
# msys2:root /mingw64
# msys2:native-root D:\msys64\mingw64
# msys2:package-prefix mingw-w64-x86_64
# ocaml:native true
# ocaml:native-tools true
# ocaml:native-dynlink true
# ocaml:stubsdir C:\Users\alex\AppData\Local\opam\default/lib/ocaml/stublibs;C:\Users\alex\AppData\Local\opam\default/lib/ocaml
# ocaml:preinstalled false
# ocaml:compiler 5.2.1