Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
klezm opened this issue Feb 26, 2024 · 1 comment · May be fixed by #600
Open

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

klezm opened this issue Feb 26, 2024 · 1 comment · 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"
}

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

Successfully merging a pull request may close this issue.

1 participant