process icon indicating copy to clipboard operation
process copied to clipboard

Problems with pcWorkingDir on macOS

Open k-bx opened this issue 6 years ago • 1 comments

Migrating from https://github.com/fpco/typed-process/issues/31

Here's a script that works differently on macOS and Linux.

#!/usr/bin/env stack
{- stack script
     --resolver=lts-15.0
     --package process
-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Concurrent
import System.Exit (ExitCode(..))
import qualified System.Process as P

main :: IO ()
main = do
  let cp0 = P.proc "./webapp" []
      pcWorkingDir = Just "./inner"
      cp = cp0 {P.cwd = pcWorkingDir}
  (minH, moutH, merrH, pHandle) <- P.createProcess_ "startProcess" cp
  putStrLn "> started"
  threadDelay (2 * 1000000)
  putStrLn "> exiting"

The problem is that it succeeds in running a program ./webapp located in ./inner dir on Linux, but fails on macOS. If you put "./inner/webapp" as a path on macOS, it launches it fine.

Dir where you can reproduce this in full: https://github.com/k-bx/playground/tree/master/typed-process-issue-31

k-bx avatar Feb 20 '20 20:02 k-bx

As I mentioned in that previous issue, I think this is an inherent difference in Mac vs Linux, though I could be mistaken. I'm worried about trying to fix this one, as it will silently change the behavior of programs on one of these two OSes. If we can do it with a flag, that would be better.

snoyberg avatar Feb 24 '20 07:02 snoyberg