cabal
cabal copied to clipboard
scope:private executables broken with v2-install
Describe the bug
If I use a private executable with v1-install (tested inside a v1-sandbox) I get the behaviour I'm looking for:
- the private executable is only installed in the
libexecdir - I can run the executable from another program in the package with the help of the
Paths_module
With v2-install (on Linux):
cabal-installinstalls a broken symlink ininstalldirfor the private executable- executables can have different component hashes. Using
getLibexecDirfrom the public executable in the package doesn't give me the location of the others.
item 1. seems to be a bug.
I'm not sure about 2. How should I find a private executable if it's not a bug?
For reference, the code that doesn't work (from Main.hs in the attached archive):
main = do
putStrLn "Hello, Haskell! (public)"
libexec <- getLibexecDir
callProcess (libexec </> "private") []
To Reproduce
$ cabal v2-install testprivate-0.1.0.0.tar.gz
Expected behavior
testprivate is installed in installdir. When run, it should the private executable. The expected output is:
Hello, Haskell! (public)
Hello, Haskell! (private)
Thanks for the report.
(1) does sound like a bug yeah and
(2) is a known problem. The whole Paths_* mechanism is still in need of an overhaul for v2-build. Essentially we'd need to have a way to refer to other components' paths, so everything would have to be parameterised by UnitId for example.
Related issues: #5997, #4503
Even though I introduced this feature I've stopped needing it so I don't really have much motivation to get it working on v2, but I'd be happy to help guide anyone who wants to tackle it.
When used with --install-method=copy, private executables cause the whole install to fail, rather than continuing after creating a broken symlink:
luite@linux$ cabal v2-install --install-method=copy
Wrote tarball sdist to
/home/luite/tmp/testprivate-0.1.0.0/dist-newstyle/sdist/testprivate-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- testprivate-0.1.0.0 (exe:testprivate) (requires build)
- testprivate-0.1.0.0 (exe:private) (requires build)
Starting testprivate-0.1.0.0 (exe:testprivate)
Starting testprivate-0.1.0.0 (exe:private)
Building testprivate-0.1.0.0 (exe:private)
Building testprivate-0.1.0.0 (exe:testprivate)
Installing testprivate-0.1.0.0 (exe:private)
Completed testprivate-0.1.0.0 (exe:private)
Installing testprivate-0.1.0.0 (exe:testprivate)
Completed testprivate-0.1.0.0 (exe:testprivate)
Copying 'testprivate'
Copying 'private'
/home/luite/.cabal/store/ghc-8.6.5/testprivate-0.1.0.0-c74c0b2822283528a9b67bc922efc84031490d8d9d1396723a6340809089a5a8/bin/private: copyFile:atomicCopyFileContents:withReplacementFile:copyFileToHandle:openBinaryFile: does not exist (No such file or directory)
Unfortunately on Windows, we have to use --install-method=copy, since cabal-install doesn't support creating symlinks on Windows (the operating system does, although it's not enabled by default), and aborts the installation.
Looks like this problem is in Distribution.Client.CmdInstall, which should skip the private executable components in installExes or installUnitExes
Bumped into this issue today... ping.
For scope: private, still generates a broken link, and fails with --install-method=copy
$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.3.0 of the Cabal library
Probably not fixed, but could you try with cabal 3.8.0.20220526 (https://discourse.haskell.org/t/cabal-3-8-pre-released)?
Noticing...
At https://cabal.readthedocs.io/en/3.6/cabal-package.html#executables says the executable is stored at $libexecdir/$libexecsubdir
But there is not a Path_name.getLibexecSubdir, to access the supposed $libexecdir/$libexecsubdir
https://cabal.readthedocs.io/en/3.6/cabal-package.html#accessing-data-files-from-package-code
Also the Path_name.getLibexecDir returns ~/.cabal/libexec/x86_64-linux-ghc-9.0.2/name-0.1.0
But ~/.cabal/libexec does not exist, ~/.cabal/store/ghc-9.0.2/abxm-0.1.0-e-name-332ce6bc0916b5af18d41d066c39d02b1c4eb6afb09f86d4c711a76aefab8689/libexec is where the un-linked executable is stored.
O.o ... scope: private seams a mess.
Probably not fixed, but could you try with cabal 3.8.0.20220526 (https://discourse.haskell.org/t/cabal-3-8-pre-released)?
using version from nixpkgs... and have no idea on how to install a newer version.
tried: cabal install cabal-install
... and got not that version:
In order, the following will be built (use -v for more details):
- Cabal-syntax-3.6.0.0 (lib) (requires download & build)
- HTTP-4000.3.16 (lib) (requires download & build)
- base16-bytestring-1.0.2.0 (lib) (requires download & build)
- cryptohash-sha256-0.11.102.1 (lib) (requires download & build)
- echo-0.1.4 (lib) (requires download & build)
- ed25519-0.0.5.0 (lib) (requires download & build)
- edit-distance-0.2.2.1 (lib) (requires download & build)
- hsc2hs-0.68.8 (exe:hsc2hs) (requires download & build)
- regex-base-0.94.0.2 (lib) (requires download & build)
- resolv-0.1.2.0 (lib:resolv) (requires download & build)
- lukko-0.1.1.3 (lib) (requires download & build)
- regex-posix-0.96.0.1 (lib) (requires download & build)
- hackage-security-0.6.2.1 (lib) (requires download & build)
- cabal-install-3.4.1.0 (exe:cabal) (requires download & build)
... i can survive without scope:private... :) ... just reporting the bug.
You'd install with ghcup, It's described in the link I gave.
Sorry, did not follow the link at all... ( i presumed it would lead me to compiling cabal from source, or some messy install )
After updating nix channels, and adding ghcup to the list of packges, i get this from nix-shell:
error: Package ‘ghcup-0.1.17.10’ in /nix/store/69pqivsw2n1mg90fnq24dsg8k4w6yaz6-nixpkgs/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix:109308 is marked as broken, refusing to evaluate.
O.o ... so... noticed that there is a https://downloads.haskell.org/cabal/cabal-install-3.8.1.0-rc1/cabal-install-3.8.0.20220526-x86_64-linux-deb10.tar.xz
Downloaded, uncompressed, it has a cabal and a plan.json.
Tried it, it runs... :) ... and the bug persists, exactly as i described it initialy... :(
Thank you for the confirmation. I appreciate it.
And thank you for the investigation of what's failing. I guess we have enough clues, together with the old discussion, for somebody to dig deeper and fix it.