From 773455027166d621438d6fc746069ccf439a34b5 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 22 Mar 2024 21:09:38 -0400 Subject: [PATCH] give Pkg repl tips when interactive --- base/loading.jl | 3 ++- stdlib/Artifacts/src/Artifacts.jl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 883e980b4000a..0061fab3ab9a0 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -2080,7 +2080,8 @@ function __require(into::Module, mod::Symbol) hint_message = hint ? ", maybe you meant `import/using $(dots)$(mod)`" : "" install_message = if mod != :Pkg start_sentence = hint ? "Otherwise, run" : "Run" - "\n- $start_sentence `import Pkg; Pkg.add($(repr(String(mod))))` to install the $mod package." + pkg_cmd = isinteractive() ? "pkg> add $mod" : "import Pkg; Pkg.add(\"$mod\")" + "\n- $start_sentence `$pkg_cmd` to install the $mod package." else # for some reason Pkg itself isn't availability so do not tell them to use Pkg to install it. "" end diff --git a/stdlib/Artifacts/src/Artifacts.jl b/stdlib/Artifacts/src/Artifacts.jl index 968d190c2b443..6b1cfcf10eaa7 100644 --- a/stdlib/Artifacts/src/Artifacts.jl +++ b/stdlib/Artifacts/src/Artifacts.jl @@ -579,7 +579,8 @@ function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dic suggestion_str = if query_override(hash) !== nothing "Check that your `Overrides.toml` file is correct (https://pkgdocs.julialang.org/v1/artifacts/#Overriding-artifact-locations)." else - "Try `using Pkg; Pkg.instantiate()` to re-install all missing resources if the artifact is part of a package \ + pkg_cmd = Base.isinteractive() ? "pkg> instantiate" : "import Pkg; Pkg.instantiate()" + "Try `$pkg_cmd` to re-install all missing resources if the artifact is part of a package \ or call `Pkg.ensure_artifact_installed` (https://pkgdocs.julialang.org/v1/api/#Pkg.Artifacts.ensure_artifact_installed) if not." end