Skip to content

Commit b7579b2

Browse files
authored
fix GAP.Packages.versioninfo (#1246)
It may happen that a GAP package is loaded but its directory does not exist. For example, our test that installs/loads/removes a package creates such a GAP session. Calling `GAP.Packages.versioninfo` afterwards ran into an error up to now.
1 parent e50e02d commit b7579b2

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/packages.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,20 @@ function versioninfo(io::IO = stdout; GAP::Bool = false, jll::Bool = false, full
560560
name = String(key)
561561
push!(names, name)
562562
vals = dict[key]
563-
path = replace(realpath(vals[1]), default_artifacts_path => "ARTIFACTS")
564-
if startswith(path, "ARTIFACTS")
565-
pos = findall("/", path)
566-
if length(pos) > 1 && pos[2][1]-pos[1][1] > 10
567-
path = path[1:(pos[1][1]+7)] * "..." * path[pos[2][1]:end]
563+
if ispath(vals[1])
564+
path = replace(realpath(vals[1]), default_artifacts_path => "ARTIFACTS")
565+
if startswith(path, "ARTIFACTS")
566+
pos = findall("/", path)
567+
if length(pos) > 1 && pos[2][1]-pos[1][1] > 10
568+
path = path[1:(pos[1][1]+7)] * "..." * path[pos[2][1]:end]
569+
end
568570
end
571+
push!(paths, path)
572+
push!(versions, vals[2])
573+
else
574+
push!(paths, "($(vals[1])) -- loaded but not existing")
575+
push!(versions, "")
569576
end
570-
push!(paths, path)
571-
push!(versions, vals[2])
572577
end
573578
namewidth = maximum(length.(names)) + 2
574579
verswidth = maximum(length.(versions)) + 2

test/packages.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@test GAP.Packages.install("https://github.com/gap-packages/RegisterPackageTNUMDemo/releases/download/v0.4/RegisterPackageTNUMDemo-0.4.tar.gz", interactive = false)
2727
@test GAP.Packages.load("RegisterPackageTNUMDemo")
2828
@test GAP.Packages.remove("RegisterPackageTNUMDemo", interactive = false)
29+
GAP.Packages.versioninfo(IOBuffer(); full = true) # test that this does not error, see #1246
2930

3031
# pkgdir = mktempdir()
3132
# @test GAP.Packages.install("fga", interactive = false, pkgdir = pkgdir)

0 commit comments

Comments
 (0)