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

Opam setenv for path lists is broken on Windows/Cygwin #4690

Closed
MisterDA opened this issue May 31, 2021 · 0 comments · Fixed by #5636
Closed

Opam setenv for path lists is broken on Windows/Cygwin #4690

MisterDA opened this issue May 31, 2021 · 0 comments · Fixed by #5636
Assignees

Comments

@MisterDA
Copy link
Contributor

MisterDA commented May 31, 2021

Opam doesn't handle well setenv in Windows / Cygwin, especially with file lists.
To demonstrate, I'm using the opam images for Docker on Windows. The image ships OCaml for Windows from fdopen, and opam 2.0.8.

Dockerfile

FROM  ocaml/opam:windows-mingw-ocaml-4.13
COPY bugs.cmd .
RUN .\bugs.cmd

bugs.cmd

ocaml-env exec -- echo %PKG_CONFIG_PATH%
@rem nothing, ok

ocaml-env exec -- printenv PKG_CONFIG_PATH
@rem nothing, ok

ocaml-env exec -- opam depext -yi conf-pkg-config

ocaml-env exec -- echo %PKG_CONFIG_PATH%
@rem wrong: nothing's exported

ocaml-env exec -- printenv PKG_CONFIG_PATH
@rem good C:/opam/.opam/4.13/lib/pkgconfig

ocaml-env exec -- C:\cygwin64\bin\bash.exe --login -c "printenv PKG_CONFIG_PATH"
@rem C:/opam/.opam/4.13/lib/pkgconfig:C:/opam/.opam/4.13/lib/pkgconfig
@rem wrong: duplicated, uses : as path separator, should use cygwin-style paths

C:\cygwin64\bin\bash.exe --login -c "ocaml-env exec -- printenv PKG_CONFIG_PATH"
@rem C:/opam/.opam/4.13/lib/pkgconfig;C:/opam/.opam/4.13/lib/pkgconfig:
@rem wrong: duplicated, ends with a :, should use cygwin-style paths

For reference, the ENTRYPOINT of the image is ["ocaml-env" "exec" "--64" "--"] and its CMD is cmd.exe.

I have to work around this issue with lines such as

ocaml-env exec -- opam source mirage-crypto.0.10.4
cd mirage-crypto.0.10.4
ocaml-env exec -- opam install -y --deps-only --with-test ./mirage-crypto.opam
ocaml-env exec -- env PKG_CONFIG_PATH=/cygdrive/c/opam/.opam/4.13/lib/pkgconfig dune build -p mirage-crypto @install
ocaml-env exec -- env PKG_CONFIG_PATH=/cygdrive/c/opam/.opam/4.13/lib/pkgconfig opam install -y ./mirage-crypto.opam

# the following would be simpler, but doesn't work (maybe it's another unrelated problem)
ocaml-env exec -- env PKG_CONFIG_PATH=/cygdrive/c/opam/.opam/4.13/lib/pkgconfig opam install -y mirage-crypto

The culprit line in conf-pkg-config is here:

setenv: [PKG_CONFIG_PATH += "%{lib}%/pkgconfig"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants