Resolve paths when using XDG dirs, fixes #311

This commit is contained in:
Julian Ospald 2022-02-05 16:44:00 +01:00
parent 51690d1df3
commit e40777a5d3
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F
2 changed files with 7 additions and 2 deletions

View File

@ -137,7 +137,9 @@ ghcLinkDestination :: ( MonadReader env m
ghcLinkDestination tool ver = do
Dirs {..} <- getDirs
ghcd <- ghcupGHCDir ver
pure (relativeSymlink binDir (ghcd </> "bin" </> tool))
ghcd' <- liftIO $ canonicalizePath ghcd
binDir' <- liftIO $ canonicalizePath binDir
pure (relativeSymlink binDir' (ghcd' </> "bin" </> tool))
-- | The symlink destination of a hls binary.
@ -152,7 +154,9 @@ hlsLinkDestination :: ( MonadReader env m
hlsLinkDestination tool ver = do
Dirs {..} <- getDirs
hlsd <- ghcupHLSDir ver
pure (relativeSymlink binDir (hlsd </> "bin" </> tool))
hlsd' <- liftIO $ canonicalizePath hlsd
binDir' <- liftIO $ canonicalizePath binDir
pure (relativeSymlink binDir' (hlsd' </> "bin" </> tool))
-- | Removes the minor GHC symlinks, e.g. ghc-8.6.5.

View File

@ -335,6 +335,7 @@ useXDG :: IO Bool
useXDG = isJust <$> lookupEnv "GHCUP_USE_XDG_DIRS"
-- | Like 'relpath'. Assumes the inputs are resolved in case of symlinks.
relativeSymlink :: FilePath -- ^ the path in which to create the symlink
-> FilePath -- ^ the symlink destination
-> FilePath