Skip to content

Commit

Permalink
Replace depots()[1] with depots1() where depots1 throws (#563)
Browse files Browse the repository at this point in the history
a more descriptive error, instead of a BoundsError, in
the case where DEPOT_PATH is empty.
  • Loading branch information
fredrikekre authored and KristofferC committed Aug 4, 2018
1 parent 85d2a7e commit 0ecaf2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions stdlib/Pkg/src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions stdlib/Pkg/src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions stdlib/Pkg/src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0ecaf2d

Please sign in to comment.