Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

[Bug]: Haskell: globalPackages option installs no libraries #584

Open
klezm opened this issue Feb 26, 2024 · 2 comments · Fixed by devcontainers-extra/features#52 · May be fixed by #600
Open

[Bug]: Haskell: globalPackages option installs no libraries #584

klezm opened this issue Feb 26, 2024 · 2 comments · Fixed by devcontainers-extra/features#52 · May be fixed by #600
Labels
bug Something isn't working

Comments

@klezm
Copy link

klezm commented Feb 26, 2024

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 to globalPackages 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 the cabal install command here:

cabal update && echo "${CABAL_INSTALLS}" | xargs cabal install

For more info on cabal install --lib and the difference between libraries and executables see: haskell/cabal#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

@klezm klezm added the bug Something isn't working label Feb 26, 2024
@klezm klezm changed the title [Bug]: globalPackages installs no libraries [Bug]: Haskell: globalPackages option installs no libraries Feb 26, 2024
@klezm
Copy link
Author

klezm commented Feb 27, 2024

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"
}

@evilhamsterman
Copy link

This project is not associated with the devcontainer project and appears to have been abandoned #628 . The official project has removed all devcontainer-contrib features from their listing. devcontainers/devcontainers.github.io#451. There is a fork that is being worked on to update and maintain the features https://github.com/devcontainers-extra/features

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
2 participants