Commit 735467e5 authored by Matt Renaud's avatar Matt Renaud

Use the default install directory (installdir) if not specified.

This change updates the `cabal install` command to use the default install
directory for executables if one was not specified in either Cabal's config file
or on the command line with the --installdir flag.

Previously this would error out, now it warns that it used the default and
continues.

PR #6624, resolves #5973.
parent 762805a9
......@@ -64,7 +64,7 @@ import Distribution.Simple.BuildPaths
import Distribution.Simple.Program.Find
( ProgramSearchPathEntry(..) )
import Distribution.Client.Config
( getCabalDir, loadConfig, SavedConfig(..) )
( defaultInstallPath, getCabalDir, loadConfig, SavedConfig(..) )
import qualified Distribution.Simple.PackageIndex as PI
import Distribution.Solver.Types.PackageIndex
( lookupPackageName, searchByName )
......@@ -642,6 +642,7 @@ installExes
-> IO ()
installExes verbosity baseCtx buildCtx platform compiler
configFlags clientInstallFlags = do
installPath <- defaultInstallPath
let storeDirLayout = cabalStoreDirLayout $ cabalDirLayout baseCtx
prefix = fromFlagOrDefault "" (fmap InstallDirs.fromPathTemplate (configProgPrefix configFlags))
......@@ -659,9 +660,10 @@ installExes verbosity baseCtx buildCtx platform compiler
mkFinalExeName exe = prefix <> unUnqualComponentName exe <> suffix <.> exeExtension platform
installdirUnknown =
"installdir is not defined. Set it in your cabal config file "
++ "or use --installdir=<path>"
++ "or use --installdir=<path>. Using default installdir: " ++ show installPath
installdir <- fromFlagOrDefault (die' verbosity installdirUnknown) $
installdir <- fromFlagOrDefault
(warn verbosity installdirUnknown >> pure installPath) $
pure <$> cinstInstalldir clientInstallFlags
createDirectoryIfMissingVerbose verbosity False installdir
warnIfNoExes verbosity buildCtx
......
......@@ -26,6 +26,7 @@ module Distribution.Client.Config (
defaultConfigFile,
defaultCacheDir,
defaultCompiler,
defaultInstallPath,
defaultLogsDir,
defaultUserInstall,
......
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