cabal
cabal copied to clipboard
`cabal install pkg-x.y.z` fails unless `--ignore-project` is given
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:
- change to a cabal project root
cabal install fix-whitespace-0.0.8fails: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.cabal install fix-whitespacesucceedscabal install --ignore-project fix-whitespace-0.0.8also 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.
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.
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.0works- in the cabal repo
cd cabal-install && cabal install haskell-say-1.0.0.0also 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)
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.