Commit caa67f62 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Fixing IHaskell path resolution for 'IHaskell setup'.

parent 56bbd249
...@@ -57,8 +57,8 @@ setupIPythonProfile profile = shelly $ do ...@@ -57,8 +57,8 @@ setupIPythonProfile profile = shelly $ do
let profileDir = ipythonDir ++ "/profile_" ++ pack profile ++ "/" let profileDir = ipythonDir ++ "/profile_" ++ pack profile ++ "/"
path <- liftIO $ fmap FS.encodeString getArgv0Absolute path <- getIHaskellPath
writeConfigFilesTo profileDir (trace path $ path) writeConfigFilesTo profileDir path
-- | Write IPython configuration files to the profile directory. -- | Write IPython configuration files to the profile directory.
writeConfigFilesTo :: Text -- ^ Profile directory to write to. Must have a trailing slash. writeConfigFilesTo :: Text -- ^ Profile directory to write to. Must have a trailing slash.
...@@ -78,12 +78,26 @@ writeConfigFilesTo profileDir ihaskellPath = writeFile (fromText configFile) con ...@@ -78,12 +78,26 @@ writeConfigFilesTo profileDir ihaskellPath = writeFile (fromText configFile) con
] ]
getArgv0Absolute :: IO FS.FilePath -- | Get the absolute path. If this is using path reso
getArgv0Absolute = do getIHaskellPath :: Sh String
f <- getArgv0 getIHaskellPath = do
f' <- if FS.absolute f then return f -- Get the absolute filepath to the argument.
else do f <- liftIO getArgv0
cd <- getCurrentDirectory
return $ FS.decodeString cd FS.</> f -- If we have an absolute path, that's the IHaskell we're interested in.
print ("FS:" ++ FS.encodeString f') if FS.absolute f
return f' then return $ FS.encodeString f
else
-- Check whether this is a relative path, or just 'IHaskell' with $PATH
-- resolution done by the shell. If it's just 'IHaskell', use the $PATH
-- variable to find where IHaskell lives.
if FS.filename f == f
then do
ihaskellPath <- which "IHaskell"
case ihaskellPath of
Nothing -> error "IHaskell not on $PATH and not referenced relative to directory."
Just path -> return $ FS.encodeString path
else do
-- If it's actually a relative path, make it absolute.
cd <- liftIO getCurrentDirectory
return $ FS.encodeString $ FS.decodeString cd FS.</> f
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment