Skip to content

Commit

Permalink
Merge pull request #5637 from JuliaLang/kms/versioned_cachedir_update
Browse files Browse the repository at this point in the history
Fix cache dir creation to allow relative paths for JULIA_PKGDIR
  • Loading branch information
kmsquire committed Feb 3, 2014
2 parents 39c3269 + 9fb0dde commit 2810d0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions base/pkg/cache.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module Cache

import ..Git
import ..Git, ..Dir
using ..Types

import ..Dir: pkgroot

path(pkg::String) = abspath(".cache", pkg)

function mkcachedir()
Expand All @@ -15,13 +13,15 @@ function mkcachedir()

@windows_only mkdir(cache)
@unix_only begin
rootcache = joinpath(realpath(pkgroot()), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
if rootcache != cache
if Dir.isversioned(pwd())
rootcache = joinpath(realpath(".."), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
run(`ln -s $rootcache $cache`)
return
end
mkdir(cache)
end
end

Expand Down
5 changes: 3 additions & 2 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import ..Git

const DIR_NAME = ".julia"

pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))
_pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))
isversioned(p::String) = ((x,y) = (VERSION.major, VERSION.minor); basename(p) == "v$x.$y")

function path()
b = pkgroot()
b = _pkgroot()
x, y = VERSION.major, VERSION.minor
d = joinpath(b,"v$x.$y")
if isdir(d) || !isdir(b) || !isdir(joinpath(b, "METADATA"))
Expand Down
2 changes: 1 addition & 1 deletion test/pkg.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV["JULIA_PKGDIR"] = abspath(string("tmp.",randstring()))
ENV["JULIA_PKGDIR"] = string("tmp.",randstring())
@test !isdir(Pkg.dir())
try # ensure directory removal
Pkg.init()
Expand Down

0 comments on commit 2810d0f

Please sign in to comment.