Open klezm opened 7 months ago
My workaround for the moment is to add the cabal install --lib
at the onCreateCommand
. This will move the time consuming build process to the image creation (which is favorable for prebuilding devcontainers). But, if the build of a package fails the onCreateCommand
fails as well which renders the image useless! Another alternative is to use another feature bash-command
.
{
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers-contrib/features/haskell:2": {
"globalPackages": "hspec hspec-contrib"
},
// Alternative 1
"ghcr.io/devcontainers-contrib/features/bash-command:1": {
"command": "echo \\\"cabal install --lib hspec hspec-contrib\\\" | sudo -iu $_REMOTE_USER"
}
},
// Or without using another feature, you can just install the libraries using onCreateCommand
// Alternative 2
"onCreateCommand": "cabal install --lib hlint hspec hspec-contrib"
}
Feature id and version
ghcr.io/devcontainers-contrib/features/haskell:2
Devcontainer base Image
mcr.microsoft.com/devcontainers/base:jammy
What happened?
Packages (e.g.
hspec
) passed toglobalPackages
are only installed as executables and not as libraries, which often is necessary. For them to be accessible as libraries the--lib
flag is missing in thecabal install
command here: https://github.com/devcontainers-contrib/features/blob/9a1d24b27b2d1ea8916ebe49c9ce674375dced27/src/haskell/install.sh#L89For more info on
cabal install --lib
and the difference between libraries and executables see: https://github.com/haskell/cabal/issues/6481 and cabal.readthedocs.io [1], [2]Maybe an additional option (e.g.
globalLibraries
) for this feature would be the best.Relevant log output
No response