Search code examples
haskellcabal

How to let `cabal install` ignore the local `.cabal` file?


Versions

%cabal --version     
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
%ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7

Problem

I want to install weeder. If there is no *.cabal file in the current directory, running cabal install weeder succeeds. However, if the one exists and contains a dependency that conflicts with what weeder requires, cabal install weeder fails.

For example, if a .cabal file contains text < 1.2.3.0 as build-depends, cabal install weeder fails with the message below:

%cabal install weeder
cabal: Could not resolve dependencies:
[__0] trying: foobarbaz-0.1.0.0 (user goal)
[__1] next goal: text (dependency of foobarbaz)
[__1] rejecting: text-1.2.4.1/installed-1.2.4.1 (conflict: foobarbaz =>
text<1.2.3.0)
[__1] skipping: text-1.2.5.0, text-1.2.4.1, text-1.2.4.0, text-1.2.3.2,
text-1.2.3.1, text-1.2.3.0 (has the same characteristics that caused the
previous version to fail: excluded by constraint '<1.2.3.0' from 'foobarbaz')
[__1] trying: text-1.2.2.2
[__2] next goal: deepseq (dependency of text)
[__2] rejecting: deepseq-1.4.4.0/installed-1.4.4.0 (conflict: text =>
base>=4.2 && <4.11, deepseq => base==4.14.3.0/installed-4.14.3.0)
[__2] trying: deepseq-1.4.5.0
[__3] next goal: array (dependency of text)
[__3] rejecting: array-0.5.4.0/installed-0.5.4.0 (conflict: text => base>=4.2
&& <4.11, array => base==4.14.3.0/installed-4.14.3.0)
[__3] trying: array-0.5.4.0
[__4] next goal: base (dependency of foobarbaz)
[__4] rejecting: base-4.14.3.0/installed-4.14.3.0 (conflict: text => base>=4.2
&& <4.11)
[__4] skipping: base-4.16.0.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0,
base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0,
base-4.11.0.0 (has the same characteristics that caused the previous version
to fail: excluded by constraint '>=4.2 && <4.11' from 'text')
[__4] rejecting: base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0,
base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1,
base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0,
base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2,
base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2,
base-3.0.3.1 (constraint from non-upgradeable package requires installed
instance)
[__4] fail (backjumping, conflict set: base, foobarbaz, text)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, text, deepseq, array, foobarbaz
Try running with --minimize-conflict-set to improve the error message.

I can avoid this by mv foobarbaz.cabal foobarbaz.cabal.bk before cabal install weeder and mv foobarbaz.cabal.bk foobarbaz.cabal after the install, or running cabal install weeder in the other directory. But is there an option to ignore the local .cabal file?


Solution

  • After I posted the question, I found that the -z and --ignore-project options are also what I wanted.

    cabal install -z weeder