Skip to content

--cabal-file needs to go #8395

Closed
Closed

Description

@ulysses4ever

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.

Activity

  1. added
    re: flag
    re: user experience
    on Aug 18, 2022
  2. andreasabel commented on Aug 19, 2022

    @andreasabel
    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.
  3. added
    re: project root
    on Aug 19, 2022
  4. fgaz commented on Aug 19, 2022

    @fgaz
    Member

    -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).

  5. self-assigned this
    on Aug 20, 2022
  6. andreasabel commented on Aug 20, 2022

    @andreasabel
    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

  7. fgaz commented on Aug 20, 2022

    @fgaz
    Member

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

  8. andreabedini commented on Jul 3, 2023

    @andreabedini
    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.

  9. fgaz commented on Jul 4, 2023

    @fgaz
    Member

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

  10. removed their assignment
    on Jul 4, 2023
  11. Mikolaj commented on Dec 9, 2023

    @Mikolaj
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cabal-install: otherre: flagre: project rootre: user experiencetype: bugtype: discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions