Skip to content

Commit d63e95d

Browse files
committed
Strip trailing slashes on GHC_PACKAGE_PATH directories #385
1 parent 88b6128 commit d63e95d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/Stack/Setup.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ setupEnv = do
166166
localdbExists <- liftIO $ doesDirectoryExist $ toFilePath localdb
167167
globalDB <- mkEnvOverride platform env1 >>= getGlobalDB
168168
let mkGPP locals = T.pack $ intercalate [searchPathSeparator] $ concat
169-
[ [toFilePath localdb | locals && localdbExists]
170-
, [toFilePath deps | depsExists]
171-
, [toFilePath globalDB]
169+
[ [toFilePathNoTrailingSlash localdb | locals && localdbExists]
170+
, [toFilePathNoTrailingSlash deps | depsExists]
171+
, [toFilePathNoTrailingSlash globalDB]
172172
]
173173

174174
executablePath <- liftIO getExecutablePath
@@ -190,16 +190,16 @@ setupEnv = do
190190
else id)
191191

192192
-- For reasoning and duplication, see: https://github.com/fpco/stack/issues/70
193-
$ Map.insert "HASKELL_PACKAGE_SANDBOX" (T.pack $ toFilePath deps)
193+
$ Map.insert "HASKELL_PACKAGE_SANDBOX" (T.pack $ toFilePathNoTrailingSlash deps)
194194
$ Map.insert "HASKELL_PACKAGE_SANDBOXES"
195195
(T.pack $ if esIncludeLocals es
196196
then intercalate [searchPathSeparator]
197-
[ toFilePath localdb
198-
, toFilePath deps
197+
[ toFilePathNoTrailingSlash localdb
198+
, toFilePathNoTrailingSlash deps
199199
, ""
200200
]
201201
else intercalate [searchPathSeparator]
202-
[ toFilePath deps
202+
[ toFilePathNoTrailingSlash deps
203203
, ""
204204
])
205205
$ env1
@@ -280,7 +280,7 @@ ensureGHC sopts = do
280280
installed <- runReaderT listInstalled config
281281
idents <- mapM (ensureTool sopts installed getSetupInfo' msystem) tools
282282
paths <- runReaderT (mapM binDirs $ catMaybes idents) config
283-
return $ Just $ map toFilePath $ concat paths
283+
return $ Just $ map toFilePathNoTrailingSlash $ concat paths
284284
else return Nothing
285285

286286
when (soptsSanityCheck sopts) $ do
@@ -727,3 +727,6 @@ sanityCheck menv = withSystemTempDirectory "stack-sanity-check" $ \dir -> do
727727
case eres of
728728
Left e -> throwM $ GHCSanityCheckCompileFailed e ghc
729729
Right _ -> return () -- TODO check that the output of running the command is correct
730+
731+
toFilePathNoTrailingSlash :: Path loc Dir -> FilePath
732+
toFilePathNoTrailingSlash = FP.dropTrailingPathSeparator . toFilePath

0 commit comments

Comments
 (0)