stack exec failed when using http-client/http-client-tls in pure nix

Viewed 173

I'm using nix, stack and http-client-tls to GET/POST data from/to HTTPS in Haskell.

The problem is, stack exec project-exec fails with:

project-exe: security: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

However, if I setup pure: false for nix in stack.yaml, it can work normally.

So did I lose something in my nix env? How can I solve this?


main.hs:

{-# LANGUAGE OverloadedStrings #-}
--
module Main where
--
import qualified Data.ByteString.Lazy as B
--
import Network.HTTP.Client
import Network.HTTP.Client.TLS
--
url = "https://www.google.com.tw/search?q=test"
--
main :: IO ()
main = do
    mgt <- newManager tlsManagerSettings
    request <- parseRequest url
    res <- httpLbs request mgt :: IO (Response B.ByteString)
    print res

stack.yaml:

resolver: lts-14.11

packages:
- .

nix:
  enable: true
  pure: true
  # shell-file: shell.nix
  # packages: [ ]
1 Answers

pure: true means to exclude executable defined in your 'existing' shell.

So it looks like you probably just need to explicitly define the packages you depend on.

Related