diff --git a/stdlib/Pkg/src/API.jl b/stdlib/Pkg/src/API.jl index e2cd8fb3f60ba..89f1002134e34 100644 --- a/stdlib/Pkg/src/API.jl +++ b/stdlib/Pkg/src/API.jl @@ -547,29 +547,27 @@ function status(ctx::Context, mode=PKGMODE_PROJECT) return end -function activate(path::Union{String,Nothing}=nothing) - if path !== nothing - devpath = nothing - env = Base.active_project() === nothing ? nothing : EnvCache() - if env !== nothing && haskey(env.project["deps"], path) - uuid = UUID(env.project["deps"][path]) - info = manifest_info(env, uuid) - devpath = haskey(info, "path") ? joinpath(dirname(env.project_file), info["path"]) : nothing - end - # `pkg> activate path`/`Pkg.activate(path)` does the following - # 1. if path exists, activate that - # 2. if path exists in deps, and the dep is deved, activate that path (`devpath` above) - # 3. activate the non-existing directory (e.g. as in `pkg> activate .` for initing a new env) - if Types.isdir_windows_workaround(path) - path = abspath(path) - elseif devpath !== nothing - path = abspath(devpath) - else - path = abspath(path) - end +activate() = (Base.ACTIVE_PROJECT[] = Base.load_path_expand(nothing)) +function activate(path::String) + devpath = nothing + env = Base.active_project() === nothing ? nothing : EnvCache() + if env !== nothing && haskey(env.project["deps"], path) + uuid = UUID(env.project["deps"][path]) + info = manifest_info(env, uuid) + devpath = haskey(info, "path") ? joinpath(dirname(env.project_file), info["path"]) : nothing + end + # `pkg> activate path`/`Pkg.activate(path)` does the following + # 1. if path exists, activate that + # 2. if path exists in deps, and the dep is deved, activate that path (`devpath` above) + # 3. activate the non-existing directory (e.g. as in `pkg> activate .` for initing a new env) + if Types.isdir_windows_workaround(path) + path = abspath(path) + elseif devpath !== nothing + path = abspath(devpath) + else + path = abspath(path) end Base.ACTIVE_PROJECT[] = Base.load_path_expand(path) - return end """ diff --git a/stdlib/Pkg/src/REPLMode.jl b/stdlib/Pkg/src/REPLMode.jl index 443f7f2a3017b..6510d4bf66f95 100644 --- a/stdlib/Pkg/src/REPLMode.jl +++ b/stdlib/Pkg/src/REPLMode.jl @@ -603,7 +603,7 @@ do_up!(ctx::APIOptions, args::PkgArguments, api_opts::APIOptions) = function do_activate!(args::PkgArguments, api_opts::APIOptions) if isempty(args) - return API.activate(nothing) + return API.activate() else return API.activate(args[1]) end