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

Append paths in global config to progdb in configureCompiler v2 #10826

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

yutotakano
Copy link

@yutotakano yutotakano commented Mar 9, 2025

Supersedes #10790 by adding tests and fixing triple-prime variable naming.

Closes #9800.

QA Notes

Cabal should be able to resolve system packages using pkg-config when pkg-config doesn't exist in the system PATH but is provided in the path specified in ~/.cabal/config in the extra-prog-path.

On Mac/Unix and other systems where pkg-config exists in PATH, there should theoretically be no regressions due to this PR. Package dependency resolution and command line interface should be the same before and after.

On Windows where pkg-config does not exist on PATH by default, specifying one on extra-prog-path (like which is done by recent GHCup automatically) should now work for resolving dependencies, when previously it would not work. You should be able to QA this by:

  1. do a fresh GHCup/Haskell/Cabal install on Windows
  2. check that the mingw64 binary path had been added to the global cabal config file (wherever GHCup put it)
  3. install pkg-config into the Mingw environment: ghcup run -m -- pacman -S mingw64/mingw-w64-x86_64-pkg-config
  4. create a test cabal package that has a pkgconfig-depends on something
  5. BEFORE this PR: building the package will fail with not being able to find pkg-config
  6. AFTER this PR: pkg-config will be found by cabal, building failure/success is entirely on whether the dependency exists or not

Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

jasagredo and others added 2 commits February 10, 2025 23:23
We add a new PackageTest for cabal-install, which makes sure that the
extra-prog-path in the global config is used when resolving pkg-config
instead of anything already on PATH. We do this by specifying a "bad"
pkg-config to extra-prog-path that returns exit code 1.

On Windows, Cabal logs are identical in the following two cases:
- the override didn't work, and pkg-config was not found on the system
- the override did work, and querying it failed (expectedly)
To work around this, we add a "good" pkg-config script to PATH before-
hand, so that cabal succeeds in the first case and the logs differ.

This test is a stripped down reproduction of what happens when a user on
Windows adds MSYS2 paths to extra-prog-path but not the system PATH.
This is a reasonable setup (often, adding MSYS2 to system PATH is not
good practice), and is even created automatically by GHCup.
@yutotakano yutotakano changed the title Append paths in global config to progdb in configureCompiler Append paths in global config to progdb in configureCompiler v2 Mar 9, 2025
@yutotakano yutotakano force-pushed the yt/fix-paths-windows branch from 49b8f22 to 2e768df Compare March 9, 2025 14:42
@yutotakano yutotakano force-pushed the yt/fix-paths-windows branch from 2e768df to d20122d Compare March 9, 2025 14:46
@Mikolaj
Copy link
Member

Mikolaj commented Mar 17, 2025

Hi! Thank you for the fix. Does "UNEXPECTED FAIL: PackageTests/ExtraProgPathGlobal/setup.test.hs" sound reasonable or is this suspect of being an unrelated CI failure?

@yutotakano
Copy link
Author

yutotakano commented Mar 17, 2025

cHi! That's unexpected, and I've been meaning to fix it, but I haven't got my hands on a Linux/Mac machine yet to debug (the test passes on Windows but it's also supposed to pass on other OSes). Please wait a bit! Sorry, I should've marked this PR as a draft or something.

EDIT: in retrospect, I realised that I need this as a non-draft PR to run the CI checks on it. I'll write a message here once it's ready!

@yutotakano
Copy link
Author

@Mikolaj This is ready for review! The failure reason was simple: the script I added in the repo didn't have +x permissions, which is why it failed to run on Mac and Linux.

@Mikolaj
Copy link
Member

Mikolaj commented Mar 25, 2025

@yutotakano: thank you! Let me add a label to get the reviews started.

Copy link
Author

@yutotakano yutotakano Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers, this shim pkg-config was taken as-is from cabal-testsuite\PackageTests\PkgConfigParse\pkg-config, and its sole purpose is to provide something that looks and acts like pkg-config for the purposes of the test. (Importantly, it runs on Windows where pkg-config doesn't exist using the .exe file as a proxy that calls this script)

Copy link
Collaborator

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks very good. Thanks @yutotakano

@ulysses4ever
Copy link
Collaborator

This is subtle stuff. It'd be great to add QA notes https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#qa-notes.

@yutotakano
Copy link
Author

@ulysses4ever I've added some notes on what my intended functionality was and how QA can test it. I hope I'm understanding correctly what you meant by QA notes?

I also realised that the changelog entry file has the superceded PR number, is that fine? I suspect changing it would invalidate existing approval reviews, which is fine by me but additional effort for cabal maintainers.

@ulysses4ever
Copy link
Collaborator

Fixing the changelog file shouldn't invalidate anything, so, please, go ahead and fix it.

QA notes look great, thank you! Next step is to find someone with access to a Windows machine :-)

@yutotakano
Copy link
Author

Done re:changelog file! I'll await the reviews :)

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

Successfully merging this pull request may close these issues.

cabal can not find pkg-config even though the right directory has been added to the extra-prog-path
4 participants