Skip to content

Commit

Permalink
Use the default install directory (installdir) if not specified.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
m-renaud committed Apr 2, 2020
1 parent 762805a commit 735467e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cabal-install/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Distribution.Client.Config (
defaultConfigFile,
defaultCacheDir,
defaultCompiler,
defaultInstallPath,
defaultLogsDir,
defaultUserInstall,

Expand Down

0 comments on commit 735467e

Please sign in to comment.