Skip to content

Commit 4ef5a5d

Browse files
Add a tip when trying to upgrade a specific package that's possible to upgrade, just not optimal (#4266)
1 parent 115e303 commit 4ef5a5d

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Pkg v1.13 Release Notes
44
- Project.toml environments now support a `readonly` field to mark environments as read-only, preventing modifications. ([#4284])
55
- `Pkg.build` now supports an `allow_reresolve` keyword argument to control whether the build process can re-resolve package versions, similar to the existing option for `Pkg.test`. ([#3329])
66
- Packages are now automatically added to `[sources]` when they are added by url or devved.
7+
- `update` now shows a helpful tip when trying to upgrade a specific package that can be upgraded but is held back because it's part of a less optimal resolver solution ([#4266])
78

89
Pkg v1.12 Release Notes
910
=======================
@@ -14,7 +15,7 @@ Pkg v1.12 Release Notes
1415
- Pkg now supports "apps" which are Julia packages that can be run directly from the terminal after installation.
1516
Apps can be defined in a package's Project.toml and installed via Pkg. ([#3772])
1617
- `status` now shows when different versions/sources of dependencies are loaded than that which is expected by the manifest ([#4109])
17-
- When adding or developing a package that exists in the `[weakdeps]` section, it is now automatically removed from
18+
- When adding or developing a package that exists in the `[weakdeps]` section, it is now automatically removed from
1819
weak dependencies and added as a regular dependency. ([#3865])
1920
- Enhanced fuzzy matching algorithm for package name suggestions.
2021

src/Operations.jl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,9 @@ end
19221922

19231923
function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel;
19241924
skip_writing_project::Bool=false, preserve::Union{Nothing,PreserveLevel}=nothing)
1925+
1926+
requested_pkgs = pkgs
1927+
19251928
new_git = Set{UUID}()
19261929
# TODO check all pkg.version == VersionSpec()
19271930
# set version constraints according to `level`
@@ -1949,6 +1952,31 @@ function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel;
19491952
download_artifacts(ctx, julia_version=ctx.julia_version)
19501953
write_env(ctx.env; skip_writing_project) # write env before building
19511954
show_update(ctx.env, ctx.registries; io=ctx.io, hidden_upgrades_info = true)
1955+
1956+
if length(requested_pkgs) == 1
1957+
pkg = only(requested_pkgs)
1958+
entry = manifest_info(ctx.env.manifest, pkg.uuid)
1959+
if entry === nothing || (entry.path === nothing && entry.repo.source === nothing)
1960+
# Get current version after the update
1961+
current_version = entry !== nothing ? entry.version : nothing
1962+
original_entry = manifest_info(ctx.env.original_manifest, pkg.uuid)
1963+
original_version = original_entry !== nothing ? original_entry.version : nothing
1964+
1965+
# Check if version didn't change and there's a newer version available
1966+
if current_version == original_version && current_version !== nothing
1967+
temp_pkg = PackageSpec(name=pkg.name, uuid=pkg.uuid, version=current_version)
1968+
cinfo = status_compat_info(temp_pkg, ctx.env, ctx.registries)
1969+
if cinfo !== nothing
1970+
packages_holding_back, max_version, max_version_compat = cinfo
1971+
if current_version < max_version
1972+
printpkgstyle(ctx.io, :Info, "$(pkg.name) can be updated but at the cost of downgrading other packages. " *
1973+
"To force upgrade to the latest version, try `add $(pkg.name)@$(max_version)`", color=Base.info_color())
1974+
end
1975+
end
1976+
end
1977+
end
1978+
end
1979+
19521980
build_versions(ctx, union(new_apply, new_git))
19531981
end
19541982

@@ -2801,8 +2829,8 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie
28012829
pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.manifest_file, new)
28022830

28032831
new_ver_avail = !latest_version && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new)
2804-
pkg_upgradable = new_ver_avail && isempty(cinfo[1])
2805-
pkg_heldback = new_ver_avail && !isempty(cinfo[1])
2832+
pkg_upgradable = new_ver_avail && cinfo !== nothing && isempty(cinfo[1])
2833+
pkg_heldback = new_ver_avail && cinfo !== nothing && !isempty(cinfo[1])
28062834

28072835
if !pkg_downloaded && (pkg_upgradable || pkg_heldback)
28082836
# allow space in the gutter for two icons on a single line

0 commit comments

Comments
 (0)