cabal sandbox paths default to not being relative paths
if i do
mkdir test
cd test
cabal sandbox init
cabal install void # or any other package
cd ..
mkdir test2
mv test test2/
cd test2/test
cabal install data-reify
i get
carter test2/test » cabal install data-reify
cabal: No sandbox exists at /Users/carter/test/.cabal-sandbox
this suggests to me that the default paths in the cabal sandbox config (for the data that is local to the sandbox) should be relative paths, because its very unintuitive that moving a sandbox breaks the config files
hrmmm. seems like theres no support for relative paths currently in cabal, I tried changing the sandbox config file to use relative paths and cabal errored out
Yes, that's a known limitation.
I would like to be able to point to paths in ./cabal.config using $pwd/blah/blah
@tonymorris where $pwd is the sandbox root directory?
Yes, the directory containing cabal.config.
+1
+1
+1
I faced that multiple time and that would be great to avoid all the manual editing...
+1
A $pwd var would suffice.
+1 Would make it easier to commit sandbox files and use them on different machines.
Another use case: installing a package with cabal inside a Docker container.
+1
I've found a workaround: search/replace old path to new path in all .conf files, then run ghc-pkg recache on the package db of the sandbox:
find /path/to/.cabal-sandbox -iname "*.conf" -type f | xargs sed -i 's, /.*/\.cabal-sandbox, /path/to/.cabal-sandbox,g'
ls /path/to/.cabal-sandbox/ | grep 'conf\.d' | xargs -t -n1 -i_db_ ghc-pkg --package-db=/path/to/.cabal-sandbox/_db_ recache
Replace /path/to/.cabal-sandbox with your own path for the relocated sandbox.
sandbox functionality is removed.