Skip to content

Commit

Permalink
give interactive mode tips when interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Mar 23, 2024
1 parent 9c6356f commit 54bdda6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1321,14 +1321,14 @@ function assert_can_add(ctx::Context, pkgs::Vector{PackageSpec})
existing_uuid == pkg.uuid ||
pkgerror("""Refusing to add package $(err_rep(pkg)).
Package `$(pkg.name)=$(existing_uuid)` with the same name already exists as a direct dependency.
To remove the existing package, use `import Pkg; Pkg.rm("$(pkg.name)")`.
To remove the existing package, use `$(Base.isinteractive() ? """pkg> rm $(pkg.name)""" : """import Pkg; Pkg.rm("$(pkg.name)")""")`.
""")
# package with the same uuid exist in the project: assert they have the same name
name = findfirst(==(pkg.uuid), ctx.env.project.deps)
name === nothing || name == pkg.name ||
pkgerror("""Refusing to add package $(err_rep(pkg)).
Package `$name=$(pkg.uuid)` with the same UUID already exists as a direct dependency.
To remove the existing package, use `import Pkg; Pkg.rm("$name")`.
To remove the existing package, use `$(Base.isinteractive() ? """pkg> rm $name""" : """import Pkg; Pkg.rm("$name")""")`.
""")
# package with the same uuid exist in the manifest: assert they have the same name
entry = get(ctx.env.manifest, pkg.uuid, nothing)
Expand Down
3 changes: 2 additions & 1 deletion src/Registry/Registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ function check_registry_state(reg)
reg_currently_uses_pkg_server = reg.tree_info !== nothing
reg_should_use_pkg_server = registry_use_pkg_server()
if reg_currently_uses_pkg_server && !reg_should_use_pkg_server
pkg_cmd = Base.isinteractive() ? "pkg> rm $(reg.name); add $(reg.name)" : "using Pkg; Pkg.Registry.rm(\"$(reg.name)\"); Pkg.Registry.add(\"$(reg.name)\")"
msg = string(
"Your registry may be outdated. We recommend that you run the ",
"following command: ",
"using Pkg; Pkg.Registry.rm(\"$(reg.name)\"); Pkg.Registry.add(\"$(reg.name)\")",
pkg_cmd,
)
@warn(msg)
end
Expand Down

0 comments on commit 54bdda6

Please sign in to comment.