Skip to content

Commit 9254567

Browse files
authored
Merge pull request #5266 from commercialhaskell/fix-replace-extension
Work around replaceExtension semantic change
2 parents ab0e190 + 3712516 commit 9254567

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/Path/Extended.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ replaceExtension :: MonadThrow m
3333
=> String
3434
-> Path b File
3535
-> m (Path b File)
36-
replaceExtension =
3736
#if MIN_VERSION_path(0,7,0)
38-
Path.replaceExtension
37+
replaceExtension ext = Path.replaceExtension ('.' : ext)
3938
#else
40-
flip (Path.-<.>)
39+
replaceExtension = flip (Path.-<.>)
4140
#endif

src/Stack/Docker.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ import qualified Data.Text.Encoding as T
4141
import Data.Time (UTCTime)
4242
import qualified Data.Version (showVersion, parseVersion)
4343
import Distribution.Version (mkVersion, mkVersion')
44-
#if MIN_VERSION_path(0,7,0)
45-
import Path hiding (replaceExtension)
46-
#else
4744
import Path
48-
#endif
49-
import Path.Extended (replaceExtension)
5045
import Path.Extra (toFilePathNoTrailingSep)
5146
import Path.IO hiding (canonicalizePath)
5247
import qualified Paths_stack as Meta
@@ -156,7 +151,17 @@ getCmdArgs docker imageInfo isRemoteDocker = do
156151
exePath <- ensureDockerStackExe dockerContainerPlatform
157152
cmdArgs args exePath
158153
cmdArgs args exePath = do
159-
exeBase <- replaceExtension "" exePath
154+
-- MSS 2020-04-21 previously used replaceExtension, but semantics changed in path 0.7
155+
-- In any event, I'm not even sure _why_ we need to drop a file extension here
156+
-- Originally introduced here: https://github.com/commercialhaskell/stack/commit/6218dadaf5fd7bf312bb1bd0db63b4784ba78cb2
157+
#if MIN_VERSION_path(0, 7, 0)
158+
let exeBase =
159+
case splitExtension exePath of
160+
Left _ -> exePath
161+
Right (x, _) -> x
162+
#else
163+
exeBase <- exePath -<.> ""
164+
#endif
160165
let mountPath = hostBinDir FP.</> toFilePath (filename exeBase)
161166
return (mountPath, args, [], [Mount (toFilePath exePath) mountPath])
162167

0 commit comments

Comments
 (0)