Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Find and run cabal in user original $PATH #1406

Merged
merged 6 commits into from
Oct 15, 2019

Conversation

jneira
Copy link
Member

@jneira jneira commented Oct 10, 2019

  • We've found that the cabalexecutable used within stack install.hs executions after a first stack install.hs stack-install-cabal is the cached in $STACK_ROOT/snapshots/{hash}/bin. The cause is stack prepends that directory to the $PATH environment variable. That supposes:
    • If you delete the cabal executable in $PATH after running stack install.hs stack-install-cabal, another invocation doesn't copy again the cabal executable, cause the version cached by stack is found. (thanks @jchia for detected it)
    • All stack install.hs cabal-* use that cached version and no the original one, so if you upgrade your cabal in $PATH to 3.0.0.0 stack will continue using its cached version, (currently 2.4.1.0)
      • So in windows you could not use those goals

To avoid it i had to remove manually $STACK_ROOT/snapshots/{hash}/bin from $PATH, an ugly ugly hack, but i didint find better way to do it (via stack flags or alternative env vars)

I think this one would fix haskell/vscode-haskell#131

@jneira jneira requested a review from samuelpilz October 10, 2019 09:34
@samuelpilz
Copy link
Contributor

I like the idea, but the approach is very hacky indeed.

Is it a possible alternative to use findExecutables and select the appropriate executable from that list?

@jneira
Copy link
Member Author

jneira commented Oct 10, 2019

I thought in use that at first but unfortunately in windows findExecutables only returns the first one (as it states in the comments).

Imho the right one would be to have in stack a way (flag or whatever) to ignore its modifications over the $PATH variable... 😟

Copy link
Contributor

@samuelpilz samuelpilz left a comment

Choose a reason for hiding this comment

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

If there is no better cross platform solution, this PR is fine

@alanz
Copy link
Collaborator

alanz commented Oct 10, 2019

I am having issues on Debian with tests failing when I build locally, but passing fine on CI, e.g. https://circleci.com/workflow-run/57c08f4c-eca4-46af-bedd-97c3ae0d0835.

I wonder if this cached cabal could be the issue for me.

@jneira jneira changed the title Find and run cabal in user original $PATH [WIP] Find and run cabal in user original $PATH Oct 11, 2019
@jneira
Copy link
Member Author

jneira commented Oct 11, 2019

i've opened an issue in stack to try to remove or make less britle the hack: commercialhaskell/stack#5055

@jneira jneira changed the title [WIP] Find and run cabal in user original $PATH Find and run cabal in user original $PATH Oct 14, 2019
@jneira
Copy link
Member Author

jneira commented Oct 14, 2019

I've updated the pr:

  • change the hack function name to withoutStackCachedBinaries: an ugly hack deserves a precise name
  • Remove just ${snapshot-install-root}/bin and ${local-install-root}\bin

This could be merged, as the stack issue has not feedback and there is no better alternative

@jneira jneira requested a review from samuelpilz October 14, 2019 11:21
@samuelpilz
Copy link
Contributor

Im ok with this. @fendor should we merge this now?

@jneira jneira merged commit 53acb90 into haskell:master Oct 15, 2019
@jneira jneira deleted the stack-install-cabal branch October 15, 2019 10:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cabal-install is not installed. Check the README...
3 participants