Skip to content

Commit 16edd01

Browse files
authored
Don't use absolute paths for executables (#639)
1 parent 0159440 commit 16edd01

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ library:
8383
- bytestring
8484
- Cabal
8585
- containers
86-
- dhall >= 1.29.0
86+
- dhall >= 1.31.1
8787
- directory >= 1.3.4.0
8888
- either
8989
- exceptions
@@ -104,7 +104,7 @@ library:
104104
- prettyprinter
105105
- process
106106
- retry
107-
- rio
107+
- rio >= 0.1.13.0
108108
- rio-orphans
109109
- safe
110110
- semver-range

src/Spago/Prelude.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ pretty = PrettyText.renderStrict
228228
-- or die trying
229229
findExecutableOrDie :: HasLogFunc env => String -> RIO env Text
230230
findExecutableOrDie cmd = do
231-
Directory.findExecutable cmd >>= \case
231+
Directory.findExecutable cmd >>= \case
232232
Nothing -> die [ "Executable was not found in path: " <> displayShow cmd ]
233-
Just path -> pure $ Text.pack path
233+
-- Note: we ignore the path and just return the input because the one we get
234+
-- here is absolute, and Windows doesn't seem to be able to deal with that.
235+
-- See: https://github.com/purescript/spago/issues/635
236+
Just _path -> pure $ Text.pack cmd

src/Spago/RunEnv.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Spago.RunEnv where
33
import Spago.Prelude
44
import Spago.Env
55

6+
import qualified Data.Text as Text
67
import qualified System.Environment as Env
78
import qualified Distribution.System as OS
89
import qualified Turtle
@@ -120,14 +121,13 @@ getPurs usePsa = do
120121
UsePsa -> findExecutable "psa" >>= \case
121122
Just _ -> pure "psa"
122123
Nothing -> pure "purs"
123-
try (findExecutableOrDie pursCandidate) >>= \case
124-
Right p -> pure p
125-
-- one last try for Windows
126-
Left (err :: SomeException) -> case OS.buildOS of
127-
OS.Windows -> do
128-
logDebug $ displayShow err
129-
findExecutableOrDie (pursCandidate <> ".cmd")
130-
_ -> throwIO err
124+
-- We first try this for Windows
125+
case OS.buildOS of
126+
OS.Windows -> do
127+
findExecutable (pursCandidate <> ".cmd") >>= \case
128+
Just _ -> pure (Text.pack pursCandidate <> ".cmd")
129+
Nothing -> findExecutableOrDie pursCandidate
130+
_ -> findExecutableOrDie pursCandidate
131131

132132
getPackageSet :: (HasLogFunc env, HasConfigPath env) => RIO env PackageSet
133133
getPackageSet = do

0 commit comments

Comments
 (0)