Open jakzale opened 9 years ago
${pkgroot}
, which in fact comes from the ghc-pkg error when you tries to use relative pathsI'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.
@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).
This occured in cabal 3.6.
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, localcabal.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 toghc-pkg
when registering the package.Problem
ghc-pkg
will complain and report an error when the following paths are relative:ghc-pkg
as fully expanded (prefixed with cwd if relative) and does not cause anyghc-pkg
errors if include-dirs is set to a relative path;ghc-pkg
as-it-is, and will cause aghc-pkg
error, if extra-lib-dirs is set to a relative path;.cabal
file, is passed toghc-pkg
as-it-is, and will cause aghc-pkg
error, if framework-dirs is set to a relative path;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:
.cabal
file,.cabal
file,cabal.config
file (by expanding them to absolute paths).~/.cabal/config
file to be absolute.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