Commit f53c39d7 authored by Duncan Coutts's avatar Duncan Coutts

Disable cabal upgrade and add cabal install --upgrade-dependencies

cabal upgrade now gives an error message telling people to use install
or, if they know what they're doing, install --upgrade-dependencies
parent cd355cc1
......@@ -51,7 +51,6 @@ import Distribution.Client.Dependency
, PackageConstraint(..), dependencyConstraints, dependencyTargets
, PackagesPreference(..), PackagesPreferenceDefault(..)
, PackagePreference(..)
, upgradableDependencies
, Progress(..), foldProgress, )
import Distribution.Client.Fetch
( fetchPackage )
......@@ -188,27 +187,28 @@ install verbosity packageDB repos comp conf
| null targets = planLocalPackage verbosity
comp configFlags configExFlags
| otherwise = planRepoPackages PreferLatestForSelected
| otherwise = planRepoPackages defaultPref
comp globalFlags configFlags configExFlags
installFlags targets
defaultPref
| fromFlag (installUpgradeDeps installFlags) = PreferAllLatest
| otherwise = PreferLatestForSelected
upgrade verbosity packageDB repos comp conf
globalFlags configFlags configExFlags installFlags deps =
installWithPlanner verbosity context planner []
upgrade _ _ _ _ _ _ _ _ _ _ = die $
"Use the 'cabal install' command instead of 'cabal upgrade'.\n"
++ "You can install the latest version of a package using 'cabal install'. "
++ "The 'cabal upgrade' command has been removed because people found it "
++ "confusing and it often led to broken packages.\n"
++ "If you want the old upgrade behaviour then use the install command "
++ "with the --upgrade-dependencies flag (but check first with --dry-run "
++ "to see what would happen). This will try to pick the latest versions "
++ "of all dependencies, rather than the usual behaviour of trying to pick "
++ "installed versions of all dependencies. If you do use "
++ "--upgrade-dependencies, it is recommended that you do not upgrade core "
++ "packages (e.g. by using appropriate --constraint= flags)."
where
context :: InstallContext
context = (packageDB, repos, comp, conf,
globalFlags, configFlags, configExFlags, installFlags)
planner :: Planner
planner | null deps = planUpgradePackages
comp configFlags configExFlags
| otherwise = planRepoPackages PreferAllLatest
comp globalFlags configFlags configExFlags
installFlags deps
type Planner = PackageIndex InstalledPackage
-> AvailablePackageDb
......@@ -337,35 +337,6 @@ planRepoPackages defaultPref comp
worldFile = fromFlag $ globalWorldFile globalFlags
planUpgradePackages :: Compiler
-> ConfigFlags
-> ConfigExFlags
-> Planner
planUpgradePackages _comp _configFlags _configExFlags installed
(AvailablePackageDb available _availablePrefs) = die $
"the 'upgrade' command (when used without any package arguments) has "
++ "been disabled in this release. It has been disabled because it has "
++ "frequently led people to accidentally break their set of installed "
++ "packages. It will be re-enabled when it is safer to use.\n"
++ "Below is the list of packages that it would have tried to upgrade. You "
++ "can use the 'install' command to install the ones you want. Note that "
++ "it is generally not recommended to upgrade core packages.\n"
++ unlines [ display pkgid | Dependency pkgid _ <- deps ]
--TODO: improve upgrade so we can re-enable it
-- return $
-- resolveDependenciesWithProgress buildPlatform (compilerId comp)
-- (Just installed) available preferences constraints targets
where
deps = upgradableDependencies installed available
-- preferences = mergePackagePrefs PreferAllLatest availablePrefs configExFlags
-- constraints = [ PackageVersionConstraint name ver
-- | Dependency name ver <- deps ]
-- ++ [ PackageVersionConstraint name ver
-- | Dependency name ver <- configConstraints configFlags ]
-- targets = [ name | Dependency name _ <- deps ]
mergePackagePrefs :: PackagesPreferenceDefault
-> Map.Map PackageName VersionRange
-> ConfigExFlags
......
......@@ -345,7 +345,7 @@ updateCommand = CommandUI {
upgradeCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags)
upgradeCommand = configureCommand {
commandName = "upgrade",
commandSynopsis = "Upgrades installed packages to the latest available version",
commandSynopsis = "(command disabled, use install instead)",
commandDescription = Nothing,
commandUsage = usagePackages "upgrade",
commandDefaultFlags = (mempty, mempty, mempty),
......@@ -515,6 +515,7 @@ data InstallFlags = InstallFlags {
installHaddockIndex :: Flag PathTemplate,
installDryRun :: Flag Bool,
installReinstall :: Flag Bool,
installUpgradeDeps :: Flag Bool,
installOnly :: Flag Bool,
installRootCmd :: Flag String,
installSummaryFile :: [PathTemplate],
......@@ -530,6 +531,7 @@ defaultInstallFlags = InstallFlags {
installHaddockIndex = Flag docIndexFile,
installDryRun = Flag False,
installReinstall = Flag False,
installUpgradeDeps = Flag False,
installOnly = Flag False,
installRootCmd = mempty,
installSummaryFile = mempty,
......@@ -594,6 +596,11 @@ installOptions showOrParseArgs =
installReinstall (\v flags -> flags { installReinstall = v })
trueArg
, option [] ["upgrade-dependencies"]
"Pick the latest version for all dependencies, rather than trying to pick an installed version."
installUpgradeDeps (\v flags -> flags { installUpgradeDeps = v })
trueArg
, option [] ["root-cmd"]
"Command used to gain root privileges, when installing with --global."
installRootCmd (\v flags -> flags { installRootCmd = v })
......@@ -642,6 +649,7 @@ instance Monoid InstallFlags where
installHaddockIndex = mempty,
installDryRun = mempty,
installReinstall = mempty,
installUpgradeDeps = mempty,
installOnly = mempty,
installRootCmd = mempty,
installSummaryFile = mempty,
......@@ -655,6 +663,7 @@ instance Monoid InstallFlags where
installHaddockIndex = combine installHaddockIndex,
installDryRun = combine installDryRun,
installReinstall = combine installReinstall,
installUpgradeDeps = combine installUpgradeDeps,
installOnly = combine installOnly,
installRootCmd = combine installRootCmd,
installSummaryFile = combine installSummaryFile,
......
......@@ -126,7 +126,6 @@ mainWorker args = topHandler $
,updateCommand `commandAddAction` updateAction
,listCommand `commandAddAction` listAction
,infoCommand `commandAddAction` infoAction
,upgradeCommand `commandAddAction` upgradeAction
,fetchCommand `commandAddAction` fetchAction
,unpackCommand `commandAddAction` unpackAction
,checkCommand `commandAddAction` checkAction
......@@ -149,6 +148,7 @@ mainWorker args = topHandler $
regVerbosity regDistPref
,wrapperAction testCommand
testVerbosity testDistPref
,upgradeCommand `commandAddAction` upgradeAction
]
wrapperAction :: Monoid flags
......
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