commercialhaskell / commercialhaskell/stack

compiler-tools-bin path is changing (if nix is enabled) if you add a shell-file attribute (breaks intero)

Open
#4,950 6 comments 0 reactions 0 assignees View on GitHub
component: nix further investigation required type: bug
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments (optional)

When using Nix with Stack and with the setting of
```
nix:
enable: true
packages: [ zlib ]
```
(in `~/.stack/global-project/stack.yml`)
then
`stack path --compiler-tools-bin`
gives a result of
`/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin`
(notice **x86_64-linux-nix**)

BUT if I add a `shell-file` attribute (and remove packages)
```
nix:
enable: true
shell-file: shell.nix
```
(in `~/.stack/global-project/stack.yml`)
then
`cd ~/.stack/global-project ; stack path --compiler-tools-bin`
gives a result of
`/home/tim/.stack/compiler-tools/x86_64-linux/ghc-8.6.5/bin`
(notice **x86_64-linux**)
but if you just leave the ~/.stack/global-project/stack.yml file alone
`cd ~ ; stack path --compiler-tools-bin`
gives a result of
`/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin`
(notice **x86_64-linux-nix**)

### Steps to reproduce

1. Add and remove a shell-file to your nix section of stack.yml
2. Watch the `stack path --compiler-tool-bin` setting change (depending on what directory you are in: project, non-project or ~/.stack/global-project dirs)

### Expected

I expect that if I'm on NixOS and I set Nix to `enable: true` that the complier-tools-bin path wouldn't change.

### Actual

This switching around the compiler-tool-bin dir breaks `intero`'s self-installing into crumbling bits as it installs intero into
`/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin` (sometimes global compiler-tools-bin path)
but then checks if the executable is on disk in `/home/tim/.stack/compiler-tools/x86_64-linux/ghc-8.6.5/bin` (project's compiler-tools-bin path)

The same problems happen when a local project has the same changes happening to it's local stack.yml

### Stack version

1.9.3

### Method of installation

nixpkgs

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.