Nixpkgs: cabal-install 1.24 attempts to create /homeless-shelter/.cabal/config causing builds to break

Created on 11 Jun 2016  路  6Comments  路  Source: NixOS/nixpkgs

Issue description

It appears to me that a number of cabal-install commands in cabal install 1.24 have a side effect of attempting to create ~/.cabal/config which gets expanded to /homeless-shelter/.cabal/config which fails. For example, installing ghcjs fails with

Creating package registration file:
/private/var/folders/_b/wj7ns2190gd3hbz9w0f3m17c0000gn/T/nix-build-ghcjs-0.2.0.drv-0/pkgConf-ghc-prim-0.4.01622650073984943658.0
Config file path source is default config file.
Config file /homeless-shelter/.cabal/config not found.
Writing default configuration to /homeless-shelter/.cabal/config
/homeless-shelter: createDirectory: permission denied (Permission denied)
cabal: Leaving directory './boot/ghc-prim'
Failed to install ghc-prim-0.4.0.0
cabal: Error: some packages failed to install:
ghc-prim-0.4.0.0 failed during the final install step. The exception was:
ExitFailure 1

Steps to reproduce

I am not entirely sure. Many Haskell libraries install just fine. I think the issue only occurs with things like ghcjs which attempt to invoke cabal-install itself.

This is the patch to cabal-install which I believe is responsible:

https://github.com/haskell/cabal/commit/3bb8c7a9a2499dc2a06325d290628a8c7d8ab6bf

In particular, wrapperAction is changed to call loadConfigOrSandbox

https://github.com/haskell/cabal/commit/3bb8c7a9a2499dc2a06325d290628a8c7d8ab6bf#diff-53e6b83dd13dd8fb7781bc0ce3e6b36bL282

and loadConfig is responsible for trying to create ~/.cabal/config.

A second data point is my cabalsdist helper:

https://github.com/stepcut/cabalsdist

Previous I was able to use it in my default.nix to ensure that only files listed in the .cabal file were added to the src .tar.gz

mkDerivation {
  pname = "happstack-server";
  version = "7.4.6.1";
  src = cabalsdist { pathname = ./.; };
  # [snip]

But that also started failing with an error about not being able to create /homeless-shelter/.cabal/config.

I have no suggestions for a fix or a work around at this time.

bug haskell

Most helpful comment

I typically set export HOME=$TMP to work around these kind of issues.

All 6 comments

I typically set export HOME=$TMP to work around these kind of issues.

Does this issue still exist?

The issue still exists: If you write a Nix package that runs cabal build, you're going to have to be aware of it and apply the workaround.

I opened a Cabal issue. If they're not interested in fixing it there, then I think we ought to reopen this as a documentation issue here.

Why would anyone call cabal build inside of a Nix build? Just run runhaskell Setup.hs build to achieve the same effect with way less moving parts involved.

Because one didn't know you could do that! Either way, documentation issue? :smiley:

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/testing-haskell-projects-that-use-homeless-shelter-up/7540/2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Infinisil picture Infinisil  路  146Comments

ThomasMader picture ThomasMader  路  65Comments

samueldr picture samueldr  路  88Comments

tfc picture tfc  路  68Comments

globin picture globin  路  65Comments