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

--cabal-file needs to go #8395

Closed
ulysses4ever opened this issue Aug 18, 2022 · 7 comments · Fixed by #9123
Closed

--cabal-file needs to go #8395

ulysses4ever opened this issue Aug 18, 2022 · 7 comments · Fixed by #9123
Labels
cabal-install: other re: flag Concerning user-defined flags in cabal files re: project root Concerning what cabal considers the root of the project re: user experience User experience (UX) issue type: bug type: discussion

Comments

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Aug 18, 2022

As discussed in #6880, --cabal-file has never been used for what people think it's meant. The best way forward, seemingly, is to remove the option (edit by @fgaz: from cabal-install). This follows up on not only #6880 but also #7225.

Alternatives

Different people want different things from --cabal-file, e.g.:

  1. Call cabal out of the package directory (Unnecessarily difficult to run executables from outside of project #7940).
  2. Call cabal inside of the package directory but with a cabal file located outside of the directory (cabal file not found despite --cabal-file #6880, --cabal-file appears not to work #7225).

The second scenario is not supported currently. The first one can be worked around with another option: --project-file. In particular, you can create a project file along with the package of interest (if there's none currently), and point to it calling cabal from anywhere. In that case the respective package will be built/ran/installed. Beware of a current bug not allowing to use relative paths with --project-file: use absolute path until #7749 (or analogous fix) is merged.

@ulysses4ever ulysses4ever added type: bug cabal-install: other re: flag Concerning user-defined flags in cabal files re: user experience User experience (UX) issue labels Aug 18, 2022
@andreasabel
Copy link
Member

Yes, option --cabal-file should be replaced by a --cwd / --directory option as suggested in:

Alternatively, it could be fixed to mean these two things (conjunction):

  1. Set the project root to the location of the given --cabal-file.
  2. Disambiguate in case there are several .cabal files in this directory.

@andreasabel andreasabel added the re: project root Concerning what cabal considers the root of the project label Aug 19, 2022
@fgaz
Copy link
Member

fgaz commented Aug 19, 2022

-1 to giving it some other behaviour, +1 to removing it from cabal-install.

if an option to select a cabal file is needed, we could make packages a valid cli option (#3585).

@andreasabel andreasabel self-assigned this Aug 20, 2022
@andreasabel
Copy link
Member

I played a bit with removing the option. It seems to be used in the testsuite. So most work in removing this option would go into restructuring the test that currently use it.
E.g. here are several .cabal files in the same directory, and selected using the --cabal-file option: https://github.com/haskell/cabal/tree/a97e1f13bdb28a3f761d55845f14a9072bee17ca/cabal-testsuite/PackageTests/ReexportedModules/p

@fgaz
Copy link
Member

fgaz commented Aug 20, 2022

Those look like Setup.hs tests though, so removing the option from cabal-install should be fine

@andreabedini
Copy link
Collaborator

I had a go myself here. I am a bit confused (not new 😂). The option --cabal-file is (originally) a Cabal option. The options of Cabal and cabal-install (both v1 and v2 commands) are all jumbled up and this is how it becomes a cabal-install option.

Do we want to remove it from Cabal or only from cabal-install?

AFAIU we do have a mechanism to hide some Cabal flags when we use them from cabal-install. But that's also a bit messed up because it's duplicated in a few places and doesn't really inspire confidence.

Also Cabal's cabalFilePath gets passed to what I understand is the Hooks API (haddockCabalFilePath, hscolourCabalFilePath, copyCabalFilePath, installCabalFilePath, regCabalFilePath, cleanCabalFilePath, ...) and there's some warning in the code about breaking that API.

@fgaz
Copy link
Member

fgaz commented Jul 4, 2023

From cabal-install. Yes I think we can just hide it

@andreasabel andreasabel removed their assignment Jul 4, 2023
@mergify mergify bot closed this as completed in #9123 Dec 9, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Dec 9, 2023

The ticket got closed via the excellent PR by @andreabedini. Is there anything left here to do? If so, maybe let's move it to other tickets with clear scopes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: other re: flag Concerning user-defined flags in cabal files re: project root Concerning what cabal considers the root of the project re: user experience User experience (UX) issue type: bug type: discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants