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.24k stars 353 forks source link

PKG_CONFIG_PATH is being double-quoted in the environment #5923

Closed jonahbeckford closed 4 months ago

jonahbeckford commented 5 months ago

This is opam 2.2~beta2. The problem did not manifest itself in opam 2.2~alpha0.

The dump from opam option is:

setenv                 [[PKG_CONFIG_SYSTEM_LIBRARY_PATH = ""] [PKG_CONFIG_SYSTEM_INCLUDE_PATH = ""] [PKG_CONFIG_PATH =
                       "Y:\\source\\dkml\\build\\pkg\\bump\\msys64\\clang64\\lib\\pkgconfig"]]

Yet the environment variable available inside opam install (and in the opam .env log file) is:

PKG_CONFIG_PATH="Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig"
jonahbeckford commented 5 months ago

Test Cases without double quotes

# Cygwin and pkg-config

$ env 'PKG_CONFIG_PATH=Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig' pkg-config --cflags libffi
-IY:/source/dkml/build/pkg/bump/msys64/clang64/include

# MSYS2 and pkgconf

$ env 'PKG_CONFIG_PATH=Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig' pkgconf --cflags libffi
-IY:/source/dkml/build/pkg/bump/msys64/clang64/include

Conclusion: double-quotes are not needed

jonahbeckford commented 5 months ago

Test Cases with double quotes

# Cygwin and pkg-config
$ env 'PKG_CONFIG_PATH="Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig"' pkg-config --cflags libffi
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'virtual:world', not found

# MSYS2 and pkgconf

$ env 'PKG_CONFIG_PATH="Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig"' pkgconf --cflags libffi
-IZ:/msys64/clang64/bin/../include

Conclusion: adding double-quotes breaks both pkg-config and pkgconf

jonahbeckford commented 5 months ago

Correction for Cygwin examples

# Cygwin using Cygwin native /usr/bin/pkg-config

$ cygpath -aw .
Z:\cygwin64\home\beckf

$ /usr/bin/pkg-config --version
2.2.0

$ env 'PKG_CONFIG_PATH=Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig' /usr/bin/pkg-config --cflags libffi
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi' not found

$ (cd /cygdrive/y && env 'PKG_CONFIG_PATH=Y:\source\dkml\build\pkg\bump\msys64\clang64\lib\pkgconfig' /usr/bin/pkg-config --cflags libffi)
-I/clang64/include
dra27 commented 4 months ago

The regression should be addressed in #5972, but the proper fix needs some more investigation. Certainly for pkgconf, under Cygwin we'll need to translate the Windows paths - the separator there is definitely a colon. I haven't yet checked MSYS2, but as pkgconf I think it is a native tool, I expect it may be using semicolons.