Skip to content

"stack ghci" doesn't honor configured cpp flags #970

@peti

Description

@peti

The project https://github.com/peti/nix-paths uses Cabal's extension hooks to register additional flags for CPP in the build process. Both cabal-install and stack can build the project fine. The interactive REPL, however, works only for cabal-install. When I use stack to interpret the source code, I get the following error:

/tmp$ git clone git://github.com/peti/nix-paths.git
Cloning into 'nix-paths'...
remote: Counting objects: 34, done.        
remote: Compressing objects: 100% (21/21), done.        
remote: Total 34 (delta 10), reused 33 (delta 9), pack-reused 0        
Receiving objects: 100% (34/34), 6.14 KiB | 0 bytes/s, done.
Resolving deltas: 100% (10/10), done.
Checking connectivity... done.

/tmp$ cd nix-paths

/tmp/nix-paths$ stack init 
Writing default config file to: /tmp/nix-paths/stack.yaml
Basing on cabal files:
- /tmp/nix-paths/nix-paths.cabal

Checking against build plan lts-3.4
Selected resolver: lts-3.4
Wrote project config to: /tmp/nix-paths/stack.yaml

/tmp/nix-paths$ stack build 
nix-paths-1: configure
Configuring nix-paths-1...
nix-paths-1: build
Preprocessing library nix-paths-1...
[1 of 2] Compiling Nix.Paths        ( src/Nix/Paths.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Nix/Paths.o )
[2 of 2] Compiling Nix.FindFile     ( src/Nix/FindFile.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Nix/FindFile.o )
In-place registering nix-paths-1...
nix-paths-1: install
Installing library in
/tmp/nix-paths/.stack-work/install/x86_64-linux/lts-3.4/7.10.2/lib/x86_64-linux-ghc-7.10.2/nix-paths-1-CYictmtGnnPASIdBC8IhC0
Registering nix-paths-1...

/tmp/nix-paths$ stack ghci
nix-paths-1-75cbca45d7eb4d1f9747e6dd01e83080: unregistering (local file changes)
Configuring GHCi with the following packages: nix-paths
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling Nix.Paths        ( /tmp/nix-paths/src/Nix/Paths.hs, interpreted )

/tmp/nix-paths/src/Nix/Paths.hs:7:18:
    Not in scope: data constructor ‘PATH_TO_NIX_INSTANTIATE’

/tmp/nix-paths/src/Nix/Paths.hs:11:12:
    Not in scope: data constructor ‘PATH_TO_NIX_BUILD’

/tmp/nix-paths/src/Nix/Paths.hs:15:10:
    Not in scope: data constructor ‘PATH_TO_NIX_ENV’

/tmp/nix-paths/src/Nix/Paths.hs:19:12:
    Not in scope: data constructor ‘PATH_TO_NIX_STORE’
Failed, modules loaded: none.
Prelude> 

cabal-install, on the other hand, works just fine:

/tmp/nix-paths$ cabal repl
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
[1 of 1] Compiling Main             ( dist/setup/setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring nix-paths-1...
Preprocessing library nix-paths-1...
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling Nix.Paths        ( src/Nix/Paths.hs, interpreted )
[2 of 2] Compiling Nix.FindFile     ( src/Nix/FindFile.hs, interpreted )
Ok, modules loaded: Nix.Paths, Nix.FindFile.
*Nix.Paths> 

I suppose this means that stack doesn't correctly pick up the extra flags provided by Setup.lhs. I'm using Stack version 0.1.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions