cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Add --project-dir flag

Open cydparser opened this issue 2 years ago • 4 comments

  • Added --project-dir flag for specifying the project's root directory

  • Deprecated using --project-file with an absolute path

  • Partially resolves #7695 by deprecating absolute project file paths

  • A partial alternative to #7749 (see open questions below)

  • Implements one of the proposed features of #7940

  • Resolves #8037

  • [X] Patches conform to the coding conventions.

  • [x] Any changes that could be relevant to users have been recorded in the changelog.

  • [X] The documentation has been updated, if necessary.

Open Questions

  1. Should referring to parent directories in --project-file be forbidden? E.g. --project-file ../cabal.project results in a child directory being the project root (same as on HEAD), whereas the user probably wanted the behavior of --project-dir ../.

cydparser avatar Sep 05 '22 01:09 cydparser

It looks like a really comprehensive PR. I don't remember, is there a near-consensus to use this approach in the tickets you mention? Or do you plan to initiate discussion once the PR is ready? I'm asking to avoid a situation where you sit tight on a perfectly good PR, while people bemoan the lack of progress in the other tickets. :)

Mikolaj avatar Sep 05 '22 12:09 Mikolaj

This looks like a new approach to me, but a fairly clear and helpful one. I suggest to put forward a note that specifying --project-dir doesn’t require you to have an actual cabal.project — that was one of the complaints about --project-file (https://github.com/haskell/cabal/issues/7940#issuecomment-1220691915). I see that it seems to hold judging by your comments here and there, but it’s never spelled out clearly.

ulysses4ever avatar Sep 05 '22 12:09 ulysses4ever

@Mikolaj

is there a near-consensus to use this approach in the tickets you mention?

No, this approach was:

  • One of the proposed features in #7940
  • Requested in #8037
  • Hinted at here

Or do you plan to initiate discussion once the PR is ready?

I'm hoping that this PR can serve as the forum for discussion.

cydparser avatar Sep 05 '22 17:09 cydparser

I'm hoping that this PR can serve as the forum for discussion.

Splendid. In that case, could you drop a note in the relevant tickets?

Mikolaj avatar Sep 05 '22 23:09 Mikolaj

I've added more details and an alternative proposal to the description. If others like the alternative better, I would be happy to implement the change.

cydparser avatar Nov 23 '22 05:11 cydparser

I think the alternative scenario is better (if the breaking change in scenario 3 is acceptable) as it works with an absolute path as well and fixes the relative path behaviour (this is the main reason for the existence of the other PR, see this comment by @fgaz for an explanation of the relative behaviour). So the new situation will be,

  • project root is the directory where --project-file is located in unless --project-dir is specified.

I wonder if one of the motivations mentioned (https://github.com/haskell/cabal/issues/7695#issuecomment-1086775269) is now better solved with imports in cabal.project.

If the breaking behaviour is not acceptable and we want to just add the new --project-dir flag, I don't see why we would want to deprecate support for absolute paths when relative behaviour is definitely a bug

pranaysashank avatar Nov 23 '22 14:11 pranaysashank

I wonder if one of the motivations mentioned (https://github.com/haskell/cabal/issues/7695#issuecomment-1086775269) is now better solved with imports in cabal.project.

Unfortunately not (unless I'm mistaken). How would one conditionally import a file based on whether or not the user is building with Nix? Can one check for the presence of an environmental variable in an if-clause condition?

cydparser avatar Nov 25 '22 21:11 cydparser

I think the RFC period is over. I propose to review and, if reviews are positive, merge to be released in cabal 3.10 and then collect feedback from users of 3.10.

Mikolaj avatar Jan 09 '23 11:01 Mikolaj

Hi, i only want to note that i am not sure if changes has enough integration tests: i see a great unit test case but it is not clear to me changes in integration ones covers main cases of the new functionality

jneira avatar Jan 09 '23 22:01 jneira

An integration test can certainly help clarifying the expected behaviour of the patch.

Kleidukos avatar Jan 19 '23 18:01 Kleidukos

I've (hopefully) made all requested changes.

cydparser avatar Jan 30 '23 07:01 cydparser

@cydparser Fantastic, thank you very much! I'll let you set the "squash+merge me" label on this PR and the merge train will take it from here. :)

Kleidukos avatar Feb 23 '23 09:02 Kleidukos

Mergify failed with an obscure message. I manually rebased and squashed the commits into a single commit. "Validate macos-latest ghc-8.4.4" failed after running over 5 hours.

cydparser avatar Mar 01 '23 20:03 cydparser

@cydparser I'm sorry that you have to deal with CI falkiness, but it is only that and nothing else. Let's try once again (I restarted failing jobs).

ulysses4ever avatar Mar 01 '23 20:03 ulysses4ever

Yes, OSX runners sometimes do that. No idea. Potentially just GHA flakiness. The solution is stop the job and restart it.

Mikolaj avatar Mar 01 '23 21:03 Mikolaj

Too bad this was merged just days after 3.10 was frozen (informally, but so I heard)...

ulysses4ever avatar Mar 02 '23 03:03 ulysses4ever

Yes, unfortunately, But to clarify, we were in semi-freeze mode for some time already and for the last week or two we were only merging 3.8 and 3.9 regression fixes (and doc and CI tweaks). I failed to announce that on the IRC channel, probably.

Mikolaj avatar Mar 02 '23 09:03 Mikolaj