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

Fix precedence for PATH for build-tools-depends #8972

Merged
merged 5 commits into from
Jul 1, 2023
Merged

Conversation

gbaz
Copy link
Collaborator

@gbaz gbaz commented May 24, 2023

Resolves #8951 and modifies #8506 in the process. This is very subtle stuff and definitely needs a regression test added as well.

@andreabedini
Copy link
Collaborator

Well done troubleshooting this and coming up with a fix!

In the issue, you say (emphasis mine):

the code is very gnarly around how this stuff works, so need to think carefully on best way to fix it.

and right after:

My proposed, janky-as-heck, solution is to have the path from extra-prog-path eagerly added at the end of the useExtraPathEnv option in SetupScriptOptions.

If you allow me, this gives me the impression that your solution somewhat falls short of your own expectations and it makes me wonder if togheter we can find another way.

From your diagnosis:

The deeper diagnosis is that invoke in SetupWrapper.hs is called by v2-build to run the actual build, performed by Cabal-the-library. It sets a PATH including the paths of tools created in build-tool-depends at the head. Then the Setup in Cabal-the-library in turn adds the extra-prog-path stuff even further, in front of that.

Repeating in my own words: cabal-install puts extra-prog-path in the PATH, then passes extra-prog-path to Cabal, which also puts it in the PATH causing confusion.

What if cabal-install did not pass extra-prog-path to Cabal at all? using it only to set the PATH before calling Cabal.
Those who call Cabal directly could use that option on their own (or set PATH as they like). Would this be a bad solution?

This means that the usefulness of 8506 is lost in the non v2-build case

#8506 was to resolve #6304, which was raised as a v2-build problem. Was there even a v1-build issue to solve?

What is the difference between

./Setup.hs configure --extra-prog-path /x/y/z ...

and

PATH=/x/y/z:$PATH ./Setup.hs configure ...

?

I am sure I am missing something here; so I thank you in advance for helping me to understand.

@Kleidukos
Copy link
Member

@gbaz Would you like my help with fixing the conflicts of your PR?

@Kleidukos Kleidukos self-assigned this Jun 8, 2023
@Kleidukos Kleidukos force-pushed the gb/change-path-order branch 3 times, most recently from b37d3b5 to 4552405 Compare June 8, 2023 19:54
@Kleidukos Kleidukos force-pushed the gb/change-path-order branch from 4552405 to f33c99b Compare June 8, 2023 21:16
, -- note that the above adds the extra-prog-path directly following the elaborated
-- dep paths, so that it overrides the normal path, but _not_ the elaborated extensions
-- for build-tools-depends.
useExtraEnvOverrides = dataDirsEnvironmentForPlan distdir plan
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comma goes here (for a cleaner diff), I believe.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please.

ProgramSearchPathDir
(fromNubList $ configProgramPathExtra cfg)

-- Note. We try as much as possible to _prepend_ rather than postpend the extra-prog-path
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe postpend → append

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

append doesn't specify to front or back

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not going to debate a native speaker, but “add (something) to the end of a written document.” (def).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fun! I also don't like how artificial "postpend" sounds but on the other hand maybe extra clarity is justified here...

Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW I was surprised by "append doesn't specify"; I've always understood it as meaning "to the end of".

Copy link
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

good AFAICS

Copy link
Member

@sol sol left a comment

Choose a reason for hiding this comment

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

From what I understand, this PR includes unrelated formatting changes, making a review more work than it would need to be.

@ffaf1
Copy link
Collaborator

ffaf1 commented Jun 17, 2023

@sol I believe a rebase will fix those.

@Kleidukos Kleidukos added squash+merge me Tell Mergify Bot to squash-merge and removed attention: needs-review labels Jun 18, 2023
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jun 20, 2023
@ulysses4ever
Copy link
Collaborator

There's a test failure that I don't understand: https://github.com/haskell/cabal/actions/runs/5320595808/jobs/9634585502?pr=8972

@ulysses4ever
Copy link
Collaborator

@gbaz do you think you give some more love to this effort? It looks close!

@mergify mergify bot merged commit 403246c into master Jul 1, 2023
@mergify mergify bot deleted the gb/change-path-order branch July 1, 2023 18:23
@andreasabel andreasabel added the re: build-tool Concerning `build-tools` and `build-tool-depends` label Feb 29, 2024
@andreasabel
Copy link
Member

andreasabel commented Feb 29, 2024

An end-to-end test that could have verified this PR can be harvested from:

@andreasabel andreasabel added the re: extra-prog-path Concerning the `extra-prog-path` configuration option label Feb 29, 2024
@gbaz
Copy link
Collaborator Author

gbaz commented Feb 29, 2024

this subtle fix was apparently wrongly smashed by #9527 ?

alt-romes added a commit to alt-romes/cabal that referenced this pull request Mar 1, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
alt-romes added a commit to alt-romes/cabal that referenced this pull request Mar 1, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
alt-romes added a commit to alt-romes/cabal that referenced this pull request Mar 1, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
alt-romes added a commit to alt-romes/cabal that referenced this pull request Mar 1, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
alt-romes added a commit to alt-romes/cabal that referenced this pull request Mar 1, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
Mikolaj pushed a commit to alt-romes/cabal that referenced this pull request Mar 3, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
mergify bot pushed a commit that referenced this pull request Mar 4, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by #8972 but undone by #9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes #9756

(cherry picked from commit 84c30c2)
gbaz added a commit to alt-romes/cabal that referenced this pull request Mar 6, 2024
erikd pushed a commit to erikd/cabal that referenced this pull request Apr 22, 2024
We must consider the path to the installed build-tool before the path to
existing versions of the build tool in paths such as `extra-prog-path`
or in the system path.

This was previously fixed by haskell#8972 but undone by haskell#9527.

This also renames `appendProgramSearchPath` to
`prependProgramSearchPath` to describe correctly what that function
does.

Fixes haskell#9756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days re: build-tool Concerning `build-tools` and `build-tool-depends` re: extra-prog-path Concerning the `extra-prog-path` configuration option squash+merge me Tell Mergify Bot to squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installed executables take precedence over build-tool-depends
8 participants