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

Clearer message on error extracting sources #5583

Open
dra27 opened this issue Jun 24, 2023 · 5 comments
Open

Clearer message on error extracting sources #5583

dra27 opened this issue Jun 24, 2023 · 5 comments

Comments

@dra27
Copy link
Member

dra27 commented Jun 24, 2023

Noting ocaml/opam-repository#23954 (comment):

[ocamlbuild.0.14.2+win] downloaded from https://github.com/ocaml/ocamlbuild/archive/refs/tags/0.14.2.tar.gz
...
[ERROR] The sources of the following couldn't be obtained, aborting:
          - ocamlbuild.0.14.2+win

The underlying problem here is that tar was failing owing to a (now-reported) Cygwin packaging error. This can also happen even more confusingly:

[ocamlbuild.0.14.2+win] found in cache
...
[ERROR] The sources of the following couldn't be obtained, aborting:
          - ocamlbuild.0.14.2+win

We should update the error message to be clearer that the sources were obtained, but could not be extracted for some reason.

@dra27
Copy link
Member Author

dra27 commented Jun 24, 2023

Naturally, this is also more weight for the already-planned switch to using ocaml-tar!

@Simn
Copy link

Simn commented Jan 5, 2024

I came across this today and also got distracted by the error message, although it now at least prints some more information:

#=== ERROR while fetching sources for ocamlbuild.0.14.2 =======================#
OpamSolution.Fetch_fail("C:\\git\\opam\\opam.exe: \"lstat\" failed on C:\\Users\\simn\\AppData\\Local\\Temp\\opam-9612-d84f5a\\ocamlbuild-0.14.2\\examples\\07-dependent-projects\\libdemo: No such file or directory")

It took me forever to realize that this was related to symlinks after having many "but the file is clearly there..." moments, so I concur that a clearer error message would be good!

(Also, how do I actually resolve this?)

@kit-ty-kate
Copy link
Member

@Simn this is surprising, ocamlbuild.0.14.2 should not be available on Windows. Only ocamlbuild.0.14.2+win is.
Could you show the output of opam config report, opam repo and opam pin ?

@Simn
Copy link

Simn commented Jan 5, 2024

I broke my setup after encountering this, but I think I accidentally built a mscv version when I meant to use MinGW. At least I'm assuming that that's what "on Windows" would actually mean. I was also surprised to find my opam root in the Windows Users directory, as opposed to Cygwin's ~/.opam like before. I'll try to reproduce the mess I made and report back!

@Simn
Copy link

Simn commented Jan 5, 2024

Retracing my steps, something goes wrong during opam init already:

$ ./opam init git+https://github.com/ocaml-opam/opam-repository-mingw
No configuration file found, using built-in defaults.
[NOTE] Configured with Cygwin at C:\cygwin64 for depexts
Checking for available remotes: rsync and local, git.
  - you won't be able to use mercurial repositories unless you install the hg command on your system.
  - you won't be able to use darcs repositories unless you install the darcs command on your system.


<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised

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

  In normal operation, opam only alters files within C:\Users\simn\AppData\Local\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 bash configuration by adding the following line to ~\.bash_profile:

    test -r C:\Users\simn\AppData\Local\opam\opam-init\init.sh && . C:\Users\simn\AppData\Local\opam\opam-init\init.sh > /dev/null 2> /dev/null || true

  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 bash?
> 1. Yes, update ~\.bash_profile
  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

[1/2/3/4/5] 1

User configuration:
  ~\.bash_profile is already up-to-date.
[NOTE] Make sure that ~\.bash_profile is well sourced in your ~/.bashrc.


<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}]) ><><>

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

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
✶ installed base-bigarray.base
✶ installed base-threads.base
✶ installed base-unix.base
▼ retrieved ocaml-variants.4.14.1+msvc64c  (https://github.com/ocaml/ocaml/archive/refs/tags/4.14.1.tar.gz)
[ERROR] The compilation of ocaml-variants.4.14.1+msvc64c failed at "./configure
        --prefix=C:\\Users\\simn\\AppData\\Local\\opam\\default --with-flexdll --host=x86_64-pc-windows".

#=== ERROR while compiling ocaml-variants.4.14.1+msvc64c ======================#
# context     2.2.0~alpha4~dev | win32/x86_64 |  | git+https://github.com/ocaml-opam/opam-repository-mingw
# path        C:\Users\simn\AppData\Local\opam\default\.opam-switch\build\ocaml-variants.4.14.1+msvc64c
# command     C:\Users\simn\AppData\Local\opam\default\.opam-switch\build\ocaml-variants.4.14.1+msvc64c\./configure --prefix=C:\Users\simn\AppData\Local\opam\default --with-flexdll --host=x86_64-pc-windows
# exit-code   77
# env-file    C:\cygwin64\tmp\opam-simn-23812\ocaml-variants-23812-c79406.env
# output-file C:\cygwin64\tmp\opam-simn-23812\ocaml-variants-23812-c79406.out
### output ###
# [...]
# checking host system type... x86_64-pc-windows
# checking target system type... x86_64-pc-windows
# checking for x86_64-pc-windows-ld... no
# checking for x86_64-pc-windows-link... no
# checking for ld... no
# checking for link... link
# checking how to print strings... printf
# checking for x86_64-pc-windows-gcc... cl
# checking whether the C compiler works... no
# configure: error: in `/cygdrive/c/Users/simn/AppData/Local/opam/default/.opam-switch/build/ocaml-variants.4.14.1+msvc64c':
# configure: error: C compiler cannot create executables
# See `config.log' for more details



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 4.14.1+msvc64c
└─
┌─ The following changes have been performed (the rest was aborted)
│ ✶ install base-bigarray base
│ ✶ install base-threads  base
│ ✶ install base-unix     base
└─
# Run eval $(opam env --switch=default) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n] y
[NOTE] Opam has been initialised, but the initial switch creation failed.
       Use 'opam switch create <compiler>' to get started.

simn@SIMNPHONY20 /cygdrive/c/git/opam
$ opam config report
bash: opam: command not found

simn@SIMNPHONY20 /cygdrive/c/git/opam
$ .opam config report
bash: .opam: command not found

simn@SIMNPHONY20 /cygdrive/c/git/opam
$ ./opam config report
# opam config report
# opam-version         2.2.0~alpha4~dev (265fbcbfa68aef11c4ea4e905f614eac34688c13)
# self-upgrade         no
# system               arch=x86_64 os=win32 os-distribution=cygwin os-version=10.0.19041
# 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                 15
# current-switch       none set

I don't know why it's going for 4.14.1+msvc64c automatically, I expected it to use mingw here, even more so because I'm (now) running this from within the cygwin shell.

Edit: An explicit opam switch create 4.14.1+mingw64c works fine, but the eval $(opam env --switch=4.14.1+mingw64c) then fails with bash: OPAM_LAST_ENV='C:\Users\simn\AppData\Local\opam\4.14.1+mingw64c\.opam-switch\last-env\env-f4346fb8d6031e4d9fc5f882b2d67e34-0';: command not found

And a subsequent opam install ocamlbuild then gives the error which originally brought me here.

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

3 participants