@@ -32,7 +32,10 @@ devdir(depot = depots1()) = get(ENV, "JULIA_PKG_DEVDIR", joinpath(depots1(), "de
3232envdir (depot = depots1 ()) = joinpath (depot, " environments" )
3333const UPDATED_REGISTRY_THIS_SESSION = Ref (false )
3434const OFFLINE_MODE = Ref (false )
35- const DEFAULT_IO = Ref {IO} ()
35+ # For globally overriding in e.g. tests
36+ const DEFAULT_IO = Ref {Union{IO,Nothing}} (nothing )
37+ stderr_f () = something (DEFAULT_IO[], stderr )
38+ stdout_f () = something (DEFAULT_IO[], stdout )
3639
3740can_fancyprint (io:: IO ) = (io isa Base. TTY) && (get (ENV , " CI" , nothing ) != " true" )
3841
@@ -216,7 +219,7 @@ by starting julia with `--inline=no`.
216219const test = API. test
217220
218221"""
219- Pkg.gc(; io::IO=DEFAULT_IO[] )
222+ Pkg.gc(; io::IO=stderr )
220223
221224Garbage collect packages that are no longer reachable from any project.
222225Only packages that are tracked by version are deleted, so no packages
@@ -226,9 +229,9 @@ const gc = API.gc
226229
227230
228231"""
229- Pkg.build(; verbose = false, io::IO=DEFAULT_IO[] )
230- Pkg.build(pkg::Union{String, Vector{String}}; verbose = false, io::IO=DEFAULT_IO[] )
231- Pkg.build(pkgs::Union{PackageSpec, Vector{PackageSpec}}; verbose = false, io::IO=DEFAULT_IO[] )
232+ Pkg.build(; verbose = false, io::IO=stderr )
233+ Pkg.build(pkg::Union{String, Vector{String}}; verbose = false, io::IO=stderr )
234+ Pkg.build(pkgs::Union{PackageSpec, Vector{PackageSpec}}; verbose = false, io::IO=stderr )
232235
233236Run the build script in `deps/build.jl` for `pkg` and all of its dependencies in
234237depth-first recursive order.
@@ -242,8 +245,8 @@ redirecting to the `build.log` file.
242245const build = API. build
243246
244247"""
245- Pkg.pin(pkg::Union{String, Vector{String}}; io::IO=DEFAULT_IO[] )
246- Pkg.pin(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=DEFAULT_IO[] )
248+ Pkg.pin(pkg::Union{String, Vector{String}}; io::IO=stderr )
249+ Pkg.pin(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr )
247250
248251Pin a package to the current version (or the one given in the `PackageSpec`) or to a certain
249252git revision. A pinned package is never updated.
@@ -257,8 +260,8 @@ Pkg.pin(name="Example", version="0.3.1")
257260const pin = API. pin
258261
259262"""
260- Pkg.free(pkg::Union{String, Vector{String}}; io::IO=DEFAULT_IO[] )
261- Pkg.free(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=DEFAULT_IO[] )
263+ Pkg.free(pkg::Union{String, Vector{String}}; io::IO=stderr )
264+ Pkg.free(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr )
262265
263266If `pkg` is pinned, remove the pin.
264267If `pkg` is tracking a path,
@@ -273,8 +276,8 @@ const free = API.free
273276
274277
275278"""
276- Pkg.develop(pkg::Union{String, Vector{String}}; io::IO=DEFAULT_IO[] )
277- Pkg.develop(pkgs::Union{Packagespec, Vector{Packagespec}}; io::IO=DEFAULT_IO[] )
279+ Pkg.develop(pkg::Union{String, Vector{String}}; io::IO=stderr )
280+ Pkg.develop(pkgs::Union{Packagespec, Vector{Packagespec}}; io::IO=stderr )
278281
279282Make a package available for development by tracking it by path.
280283If `pkg` is given with only a name or by a URL, the package will be downloaded
@@ -347,7 +350,7 @@ Request a `ProjectInfo` struct which contains information about the active proje
347350const project = API. project
348351
349352"""
350- Pkg.instantiate(; verbose = false, io::IO=DEFAULT_IO[] )
353+ Pkg.instantiate(; verbose = false, io::IO=stderr )
351354
352355If a `Manifest.toml` file exists in the active project, download all
353356the packages declared in that manifest.
@@ -361,7 +364,7 @@ dependencies in the manifest and instantiate the resulting project.
361364const instantiate = API. instantiate
362365
363366"""
364- Pkg.resolve(; io::IO=DEFAULT_IO[] )
367+ Pkg.resolve(; io::IO=stderr )
365368
366369Update the current manifest with potential changes to the dependency graph
367370from packages that are tracking a path.
@@ -390,7 +393,8 @@ const status = API.status
390393
391394
392395"""
393- Pkg.activate([s::String]; shared::Bool=false, io::IO=DEFAULT_IO[])
396+ Pkg.activate([s::String]; shared::Bool=false, io::IO=stderr)
397+ Pkg.activate(; temp::Bool=false, shared::Bool=false, io::IO=stderr)
394398
395399Activate the environment at `s`. The active environment is the environment
396400that is modified by executing package commands.
@@ -544,7 +548,6 @@ const RegistrySpec = Types.RegistrySpec
544548
545549
546550function __init__ ()
547- DEFAULT_IO[] = stderr
548551 if isdefined (Base, :active_repl )
549552 REPLMode. repl_init (Base. active_repl)
550553 else
0 commit comments