diff --git a/stdlib/Pkg/src/Operations.jl b/stdlib/Pkg/src/Operations.jl index 547cebdc75842..c59ba70827507 100644 --- a/stdlib/Pkg/src/Operations.jl +++ b/stdlib/Pkg/src/Operations.jl @@ -9,7 +9,7 @@ import LibGit2 import REPL using REPL.TerminalMenus using ..Types, ..GraphType, ..Resolve, ..Pkg2, ..BinaryProvider, ..GitTools, ..Display -import ..depots, ..devdir, ..Types.uuid_julia +import ..depots, ..depots1, ..devdir, ..Types.uuid_julia function find_installed(name::String, uuid::UUID, sha1::SHA1) slug_default = Base.version_slug(uuid, sha1) @@ -20,7 +20,7 @@ function find_installed(name::String, uuid::UUID, sha1::SHA1) ispath(path) && return path end end - return abspath(depots()[1], "packages", name, slug_default) + return abspath(depots1(), "packages", name, slug_default) end function load_versions(path::String) @@ -480,7 +480,7 @@ function install_git( tree = nothing try repo, git_hash = Base.shred!(LibGit2.CachedCredentials()) do creds - clones_dir = joinpath(depots()[1], "clones") + clones_dir = joinpath(depots1(), "clones") ispath(clones_dir) || mkpath(clones_dir) repo_path = joinpath(clones_dir, string(uuid)) repo = ispath(repo_path) ? LibGit2.GitRepo(repo_path) : begin diff --git a/stdlib/Pkg/src/Pkg.jl b/stdlib/Pkg/src/Pkg.jl index 3efe4bc1b4619..fabbcf54698a0 100644 --- a/stdlib/Pkg/src/Pkg.jl +++ b/stdlib/Pkg/src/Pkg.jl @@ -12,8 +12,14 @@ export PackageMode, PKGMODE_MANIFEST, PKGMODE_PROJECT export UpgradeLevel, UPLEVEL_MAJOR, UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH depots() = Base.DEPOT_PATH -logdir() = joinpath(depots()[1], "logs") -devdir() = get(ENV, "JULIA_PKG_DEVDIR", joinpath(depots()[1], "dev")) +function depots1() + d = depots() + isempty(d) && cmderror("no depots found in DEPOT_PATH") + return d[1] +end + +logdir() = joinpath(depots1(), "logs") +devdir() = get(ENV, "JULIA_PKG_DEVDIR", joinpath(depots1(), "dev")) const UPDATED_REGISTRY_THIS_SESSION = Ref(false) # load snapshotted dependencies diff --git a/stdlib/Pkg/src/Types.jl b/stdlib/Pkg/src/Types.jl index a17d660f7b6cb..c47b4d9005b9d 100644 --- a/stdlib/Pkg/src/Types.jl +++ b/stdlib/Pkg/src/Types.jl @@ -11,7 +11,7 @@ using REPL.TerminalMenus using ..TOML import ..Pkg, ..UPDATED_REGISTRY_THIS_SESSION -import Pkg: GitTools, depots, logdir +import Pkg: GitTools, depots, depots1, logdir import Base: SHA1 using SHA @@ -519,7 +519,7 @@ function handle_repos_develop!(ctx::Context, pkgs::AbstractVector{PackageSpec}, # We save the repo in case another environement wants to # develop from the same repo, this avoids having to reclone it # from scratch. - clone_path = joinpath(depots()[1], "clones") + clone_path = joinpath(depots1(), "clones") mkpath(clone_path) repo_path = joinpath(clone_path, string(hash(pkg.repo.url), "_full")) repo = nothing @@ -595,7 +595,7 @@ function handle_repos_add!(ctx::Context, pkgs::AbstractVector{PackageSpec}; upgr pkg.repo == nothing && continue pkg.special_action = PKGSPEC_REPO_ADDED isempty(pkg.repo.url) && set_repo_for_pkg!(env, pkg) - clones_dir = joinpath(depots()[1], "clones") + clones_dir = joinpath(depots1(), "clones") mkpath(clones_dir) repo_path = joinpath(clones_dir, string(hash(pkg.repo.url))) repo = nothing @@ -895,7 +895,7 @@ end # Return paths of all registries in all depots function registries(; clone_default=true)::Vector{String} isempty(depots()) && return String[] - user_regs = abspath(depots()[1], "registries") + user_regs = abspath(depots1(), "registries") # TODO: delete the following let block in Julia 1.0 let uncurated = joinpath(user_regs, "Uncurated"), general = joinpath(user_regs, "General")