Skip to content

cabal install pkg-x.y.z fails unless --ignore-project is given #8325

Closed

Description

@andreasabel

If you sit in a local project directory and cabal install a remote package, you cannot give its version suffix unless you also pass --ignore-project.

Reproducer:

  1. change to a cabal project root
  2. cabal install fix-whitespace-0.0.8 fails:
    Error: cabal: No targets given and there is no package in the current
    directory. Use the target 'all' for all packages in the project or specify
    packages or components by name or location.
    
  3. cabal install fix-whitespace succeeds
  4. cabal install --ignore-project fix-whitespace-0.0.8 also succeeds

In the wild: https://github.com/haskell/cabal/runs/7509048343?check_suite_focus=true#step:6:1

Run cabal install --install-method=copy --installdir=$HOME/.local/bin fix-whitespace-0.0.8
cabal: No targets given and there is no package in the current directory. Use
the target 'all' for all packages in the project or specify packages or
components by name or location.

Activity

  1. added
    re: target
    can-workaround
    on Jul 26, 2022
  2. Mikolaj commented on Jul 26, 2022

    @Mikolaj
    Member

    I think there were suggestions in some other tickets to make cabal install foo ignore the current project file. As it stands, it fully takes the file into account (e.g., using flags and constraints from the file), which probably also manifests in the strange way you mention.

  3. jneira commented on Jul 26, 2022

    @jneira
    Member

    Hmm, there is another factor, the command fails if there is no .cabal files in the project root dir (the layout of cabal repo itself) but

    • mkdir test && cd test && cabal init -n && cabal install haskell-say-1.0.0.0 works
    • in the cabal repo cd cabal-install && cabal install haskell-say-1.0.0.0 also works

    As stated in that issue cabal install foo should be affected by project configuration cause you could have a constraint: foo > 1.1 in your cabal.project. That is the case if package foo contains a library used in your project but it also contains an executable which you might use. And that is a design decision (which could be revisited of course)

  4. andreasabel commented on Jul 26, 2022

    @andreasabel
    MemberAuthor

    What is surprising to me is that $PACKAGE-$VERSION can be a local target. What is the use of that?
    Intuitively, I would always associate a remote target with the form $PACKAGE-$VERSION.
    But clearly, the OP points out a bug: that $PACKAGE is recognized as remote target but $PACKAGE-$VERSION is not.

  5. added
    re: --ignore-project
    on Aug 21, 2022
  6. self-assigned this
    on Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cabal-install: cmd/installcan-workaroundre: --ignore-projectre: target

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions