Skip to content

runInteractiveProcess not using new PATH

run the below program with something like: rm -r foo; ghc env.hs && ./env

import System.Process( runInteractiveProcess, waitForProcess, ProcessHandle )
import System.Directory

main = do
  createDirectory "foo"
  writeFile "foo/bar" "#!/bin/sh\necho baz"
  (inH,outH,errH,procH) <- runInteractiveProcess "chmod" ["+x", "./foo/bar"] Nothing $ Just [("PATH","./foo")]
  ex <- waitForProcess procH
  print ex -- ExitSuccess
  (inH,outH,errH,procH) <- runInteractiveProcess "env" ["PATH=./foo", "bar"] Nothing $ Just [("PATH","./foo")]
  ex <- waitForProcess procH
  print ex -- ExitSuccess
  (inH,outH,errH,procH) <- runInteractiveProcess "bar" [] Nothing $ Just [("PATH","./foo")]
  ex <- waitForProcess procH
  print ex -- ExitFailure 127 (indicates command not found)
Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information