Skip to content

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

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

Closed
andreasabel opened this issue Jul 26, 2022 · 3 comments · Fixed by #8498
Closed

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

andreasabel opened this issue Jul 26, 2022 · 3 comments · Fixed by #8498
Assignees
Labels
cabal-install: cmd/install can-workaround There is a (maybe partial) workaround for the issue or missing feature re: --ignore-project Concerning flag `--ignore-project` re: target Concerning build targets like pkg:lib

Comments

@andreasabel
Copy link
Member

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.

@andreasabel andreasabel added cabal-install: cmd/install re: target Concerning build targets like pkg:lib can-workaround There is a (maybe partial) workaround for the issue or missing feature labels Jul 26, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Jul 26, 2022

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.

@jneira
Copy link
Member

jneira commented Jul 26, 2022

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)

@andreasabel
Copy link
Member Author

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.

@andreasabel andreasabel added the re: --ignore-project Concerning flag `--ignore-project` label Aug 21, 2022
@gbaz gbaz self-assigned this Sep 27, 2022
@mergify mergify bot closed this as completed in #8498 Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/install can-workaround There is a (maybe partial) workaround for the issue or missing feature re: --ignore-project Concerning flag `--ignore-project` re: target Concerning build targets like pkg:lib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants