haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 695 forks source link

Handling paths for include-dirs, extra-lib-dirs, and framework-dirs. #2641

Open jakzale opened 9 years ago

jakzale commented 9 years ago

Sorry for writting a lengthy bug report, but while trying to fix #694 during ZuriHac 2015, I consulted with @kosmikus and @dcoutts, and we realised that there is no simple solution to this problem.

Handling options in Cabal

Currently cabal treats options specified in global ~/.cabal/config file, local cabal.config file, project's .cabal file, together with options passed on the command line in an uniform way, by merging them during the configure step and performing a single check. These options include paths that will be supplied to ghc-pkg when registering the package.

Problem

ghc-pkg will complain and report an error when the following paths are relative:

Additionally, as @bos mentioned in #694, it would make little sense for some of these paths to be relative and lie outside of the project tree. Actually, there is a check in Cabal to determine if the absolute paths are outside of the project tree and produces a PackageBuildWarning, but I am not sure if it works correctly.

Proposed solution

During configure step, Cabal should pick up any path that would cause a ghc-pkg error and produce a sensible warning message, that will clearly instruct the developer what to do.

Desirable handling of paths, as proposed by @dcoutts:

Currently, I am working on extending checkPaths to check for paths that need to be absolute. Any inputs and opinions are welcome.

Related Issues

So far I found the folllowing issues related to this problem: #694, #1317, #1378

jneira commented 2 years ago
jneira commented 2 years ago
SturdyPose commented 1 year ago

I'm on win11 with MSYS and get these reports when I run cabal run:

sdl2-image-2.1.0.0: include-dirs: /mingw64/include/SDL2 is a relative path which makes no sense (as there is nothing for it to be relative to). You can make paths relative to the package database itself by using ${pkgroot}. (use --force to override)

cabal install --overwrite-policy=always links executable to cabal/bin folder and that works fine.

Funny how it mentions that relative paths make no sense when path is absolute and therefore the error itself makes no sense.

Mikolaj commented 1 year ago

@Poselsky: for the record, which cabal version did you use?

Let me upgrade this ticket to a bug status, because many of the recently linked tickets are closed, so they are not the same problem (or the problem only occurs with old cabals, but I probably hope for too much).

SturdyPose commented 1 year ago

This occured in cabal 3.6.