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 --program-suffix resulting in invalid symlink #10056

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

wismill
Copy link
Collaborator

@wismill wismill commented May 25, 2024

Please read Github PR Conventions and then fill in one of these two templates.


Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • Manual QA notes have been included.
  • Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)

Fixes #9919
Fixes #8823

Based on this comment.

It took me a lot of time to understand where to look at and I am still unsure this fix does not introduce side effects. I would need some guidance if improvements are needed.

@wismill wismill added cabal-install: cmd/install re: --program-suffix Concerning option `--program-suffix` labels May 25, 2024
@wismill wismill force-pushed the install/fix-program-suffix branch from 9120622 to 0e47036 Compare May 25, 2024 14:03
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this very annoying issue! I am wondering, whether it would be easy to add a regression test that makes sure this doesn't break again, e.g. a PackageTests/ConfigProgTest which installs a local executable with --program-suffix into the current directory and simply tests, whether the binary can be executed?

cabal-install/src/Distribution/Client/CmdInstall.hs Outdated Show resolved Hide resolved
@wismill wismill force-pushed the install/fix-program-suffix branch from 0e47036 to af2989a Compare May 26, 2024 07:37
@wismill
Copy link
Collaborator Author

wismill commented May 26, 2024

I have not seen that somebody pushed some commits before force-pushing… Was it just a rebase?

@wismill
Copy link
Collaborator Author

wismill commented May 26, 2024

Updated code: fix --program-prefix as well, add a test for both affix options and both --install-methods. I think it fixes #8823 as well.

Reworked commit message for full explanation:

Currently the options --program-{prefix,suffix} for cabal install
affects the name of the file in the install directory and the
executable name in the store. The installation fails:

  • If using --install-method=symlink, the target of the symlink is
    not affected by the affix options and it results in an invalid symlink.
  • If using --install-method=copy, the copy fails because the source
    is not found.

Another issue is that it affects the computation of the hash of the
build directory in the store, resulting in needless rebuild when using
successively different affix options.

Fixed by making the name of the executable in the store canonical, i.e.
always ignoring the program affix options.

Added a test for all the combinations of --install-method and program
affixes options.

@wismill wismill force-pushed the install/fix-program-suffix branch from af2989a to 1091537 Compare May 26, 2024 07:54
@wismill
Copy link
Collaborator Author

wismill commented May 26, 2024

Rebased

@wismill wismill requested review from fendor and geekosaur May 26, 2024 09:12
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

I have one documentation nitpick, please explain in ignoreProgramAffixes why we are ignoring these prefixes, so that the knowledge isn't lost in the future :)

cabal-install/src/Distribution/Client/CmdInstall.hs Outdated Show resolved Hide resolved
@wismill wismill force-pushed the install/fix-program-suffix branch from 1091537 to 09adccb Compare May 26, 2024 19:31
@wismill wismill added the merge me Tell Mergify Bot to merge label May 31, 2024
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jun 2, 2024
Currently the options `--program-{prefix,suffix}` for cabal install
affects the name of the file in the install directory *and* the
executable name in the store. The installation fails:

- If using `--install-method=symlink`, the *target* of the symlink is
  not affected by the affix options and it results in an invalid symlink.
- If using `--install-method=copy`, the copy fails because the source
  is not found.

Another issue is that it affects the computation of the hash of the
build directory in the store, resulting in needless rebuild when using
successively different affix options.

Fixed by making the name of the executable in the store canonical, i.e.
always ignoring the program affix options.

Added a test for all the combinations of `--install-method` and program
affixes options.
@Mikolaj Mikolaj force-pushed the install/fix-program-suffix branch from 09adccb to 8593474 Compare June 2, 2024 09:30
@mergify mergify bot merged commit dda541c into haskell:master Jun 2, 2024
53 checks passed
@ulysses4ever
Copy link
Collaborator

@mergify backport 3.12

Copy link
Contributor

mergify bot commented Jun 6, 2024

backport 3.12

✅ Backports have been created

@wismill wismill deleted the install/fix-program-suffix branch June 6, 2024 19:09
@wismill wismill restored the install/fix-program-suffix branch June 6, 2024 19:09
mergify bot added a commit that referenced this pull request Jun 7, 2024
…10079)

* Fix --program-{prefix,suffix} resulting in invalid installation

Currently the options `--program-{prefix,suffix}` for cabal install
affects the name of the file in the install directory *and* the
executable name in the store. The installation fails:

- If using `--install-method=symlink`, the *target* of the symlink is
  not affected by the affix options and it results in an invalid symlink.
- If using `--install-method=copy`, the copy fails because the source
  is not found.

Another issue is that it affects the computation of the hash of the
build directory in the store, resulting in needless rebuild when using
successively different affix options.

Fixed by making the name of the executable in the store canonical, i.e.
always ignoring the program affix options.

Added a test for all the combinations of `--install-method` and program
affixes options.

(cherry picked from commit 8593474)

# Conflicts:
#	cabal-install/src/Distribution/Client/CmdInstall.hs

* fixup! resolve conflicts

---------

Co-authored-by: Pierre Le Marre <[email protected]>
Co-authored-by: Artem Pelenitsyn <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@andreasabel andreasabel added this to the Considered for 3.12 milestone Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/install merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge re: --program-suffix Concerning option `--program-suffix`
Projects
None yet
5 participants