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

[nix] "error: undefined variable `xxx' at (string):1:yyy" #1584

Closed
xor-xor opened this issue Jan 1, 2016 · 8 comments
Closed

[nix] "error: undefined variable `xxx' at (string):1:yyy" #1584

xor-xor opened this issue Jan 1, 2016 · 8 comments
Assignees

Comments

@xor-xor
Copy link
Contributor

xor-xor commented Jan 1, 2016

I'm getting some strange behavior from stack build when trying to install some extra deps via nix section.

Steps to reproduce:

  1. cd /tmp && stack new test-project
  2. cd test-project && vim stack.yaml - change resolver to let's say lts-3.16 (with 3.19 and 3.20 there seems to be a problem with terminfo not picking up curses headers, which is a whole different story), and add nix section defined as:
nix:
  enable: true
  packages: [brick]

(it doesn't have to be this particular package, though - I've got the same error with different ones)
3. run stack build

Expected:
Minimal, working environment containing brick-0.3.1.

Actual:

error: undefined variable ‘brick’ at (string):1:216
(use ‘--show-trace’ to show detailed location information)

stack build --verbose gives:

Version 0.1.10.0 x86_64
2016-01-01 13:35:58.166018: [debug] Checking for project config at: /tmp/test-project/stack.yaml @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Config src/Stack/Config.hs:576:9)
2016-01-01 13:35:58.166313: [debug] Loading project config file stack.yaml @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Config src/Stack/Config.hs:599:13)
2016-01-01 13:35:58.168133: [debug] Using a nix-shell environment with nix packages: brick, haskell.packages.lts-3_16.ghc @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Nix src/Stack/Nix.hs:89:6)
2016-01-01 13:35:58.168257: [debug] Run process: nix-shell -E "with (import <nixpkgs> {}); runCommand \"myEnv\" { buildInputs=lib.optional stdenv.isLinux glibcLocales ++ [ brick haskell.packages.lts-3_16.ghc ]; STACK_IN_NIXSHELL =1 ; STACK_IN_NIX_EXTRA_ARGS='' --extra-lib-dirs=${brick}/lib --extra-include-dirs=${brick}/include  --extra-lib-dirs=${haskell.packages.lts-3_16.ghc}/lib --extra-include-dirs=${haskell.packages.lts-3_16.ghc}/include  '' ; } \"\"" --command "'/nix/store/ypidmrljwdmdnj0b7xkjm8flycpx5lfh-stack-0.1.10.0/bin/stack' '--internal-re-exec-version=0.1.10.0' 'build' '--verbose' $STACK_IN_NIX_EXTRA_ARGS" @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Exec src/Stack/Exec.hs:51:5)
error: undefined variable ‘brick’ at (string):1:216
(use ‘--show-trace’ to show detailed location information)

After changing nix section to:

nix:
  enable: true
  packages: []

...running stack build --verbose for the second time gives:

Version 0.1.10.0 x86_64
2016-01-01 13:44:52.981475: [debug] Checking for project config at: /tmp/test-project/stack.yaml @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Config src/Stack/Config.hs:576:9)
2016-01-01 13:44:52.981762: [debug] Loading project config file stack.yaml @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Config src/Stack/Config.hs:599:13)
2016-01-01 13:44:52.983593: [debug] Using a nix-shell environment with nix packages: haskell.packages.lts-3_16.ghc @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Nix src/Stack/Nix.hs:89:6)
2016-01-01 13:44:52.983713: [debug] Run process: nix-shell -E "with (import <nixpkgs> {}); runCommand \"myEnv\" { buildInputs=lib.optional stdenv.isLinux glibcLocales ++ [ haskell.packages.lts-3_16.ghc ]; STACK_IN_NIXSHELL =1 ; STACK_IN_NIX_EXTRA_ARGS='' --extra-lib-dirs=${haskell.packages.lts-3_16.ghc}/lib --extra-include-dirs=${haskell.packages.lts-3_16.ghc}/include  '' ; } \"\"" --command "'/nix/store/ypidmrljwdmdnj0b7xkjm8flycpx5lfh-stack-0.1.10.0/bin/stack' '--internal-re-exec-version=0.1.10.0' 'build' '--verbose' $STACK_IN_NIX_EXTRA_ARGS" @(stack_BImf5flmxwxISqhhaJ4o3e:Stack.Exec src/Stack/Exec.hs:51:5)
[rest of the output truncated for brevity]

...and the whole command finishes successfully (although w/o installing aforementioned dependency).

The difference between these two cases boils down to this fragment, which is not present in the latter:

--extra-lib-dirs=${brick}/lib --extra-include-dirs=${brick}/include

(and of course, [ brick haskell.packages.lts-3_16.ghc ] vs [ haskell.packages.lts-3_16.ghc ], but that's not where the error comes from).

I've tested that on my other machine, which runs OS X + Nix + stack 1.0.0 (instead of NixOS + stack 0.1.10.0, as reported here) and I get exactly the same error.

@mgsloan
Copy link
Contributor

mgsloan commented Jan 3, 2016

Pinging @YPares

@YPares
Copy link
Collaborator

YPares commented Jan 5, 2016

@xor-xor Actually, it seems the package brick doesn't exist in Nix packages. (what you're seeing is a Nix error, not Stack)

Updating the nix channel (nix-channel --update) and trying to launch a shell with it (nix-shell -p brick) juste gives the same error.

Do you mean by any chance brickd?

@YPares YPares self-assigned this Jan 5, 2016
@YPares
Copy link
Collaborator

YPares commented Jan 5, 2016

@xor-xor Ok, I think I get it. You're referring to this package : http://hackage.haskell.org/package/brick right?
The packages: section under nix: is only for non-Haskell packages, the brick package should be handled by Stack as usual. If that's your sole dependency you don't even need nix support.

@xor-xor
Copy link
Contributor Author

xor-xor commented Jan 5, 2016

@YPares Yes, that's the one. And thanks for the clarification re: packages: section vs Haskell packages.

On the other hand, I can think of at least one use case where supporting Haskell packages via packages: section would be useful: circumventing some obscure build problems.

For instance, I've been trying to build a project which uses terminfo package, but Stack is unable to build this dependency with lts-3.20 and lts-3.19 resolvers - it cannot find curses headers (configure: error: curses headers could not be found, so this package cannot be built), despite providing paths to them via extra-include-dirs and extra-lib-dirs in stack.yaml (it may be just a bug in terminfo's configure scripts, I don't know). So I thought that instead of being blocked by this, I can just get terminfo's binary from Nix and continue with it.

What do you think..?

@mboes
Copy link
Contributor

mboes commented Jan 5, 2016

The nix support allows you to do just that. If you have a package depending on terminfo, then add

nix:
  enable: true
  packages: [ncurses]

to your project's stack.yaml. I just tested building a fresh project with terminfo-0.4.0.2 as a dependency that way. It works fine.

@xor-xor
Copy link
Contributor Author

xor-xor commented Jan 5, 2016

0.4.0.2..? Which resolver did you use to get that..? I had to use lts-3.16 (which gives terminfo-0.4.0.1), b/c anything higher than that produces an error like this one: error: attribute ‘lts-3_20’ missing, at (string):1:291 (I'm on nixos-unstable and I did nix-channel --update).

@mboes
Copy link
Contributor

mboes commented Jan 5, 2016

I added it as an extra-dep. I used that version for my test because terminfo-0.4.0.1 ships by default with GHC so there was no particular issue building that one - it's there out-of-the-box.

@xor-xor
Copy link
Contributor Author

xor-xor commented Jan 5, 2016

Allright... Everything is clear to me now. Thanks for the explanations! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants