Skip to content

Compare package paths with symlinks resolved - #154

Merged
mtorpey merged 3 commits into
gap-packages:masterfrom
lgoettgens:lg/realpath-userdir
Oct 23, 2026
Merged

mtorpey merged 3 commits into
gap-packages:masterfrom
lgoettgens:lg/realpath-userdir

Conversation

@lgoettgens

Copy link
Copy Markdown
Contributor

Once gap-system/gap#5930 is merged (expected in GAP 4.17), GAP stores root and package directories with symlinks resolved, while PKGMAN_CustomPackageDir holds whatever string the user gave. PKGMAN_UserPackageInfo and PKGMAN_RemoveDir compare the two by string prefix, so on macOS, where /var is a symlink to /private/var, packages installed into the user package directory are no longer recognised as such. See gap-system/gap#5930 (comment) for the analysis.

Resolve both sides via GAP_realpath (available since GAP 4.15) before comparing, and fall back to the raw strings on older GAP. Includes a test that reproduces the mismatch; it is excluded below GAP 4.15.

This should only be merged if we plan to proceed with gap-system/gap#5930.

🤖 Created with the help of Claude Code (Fable 5.1)

GAP 4.17 and newer store root and package directories with symlinks
resolved (gap-system/gap#5930), while `PKGMAN_CustomPackageDir` holds
the string the user gave. Resolve both sides via `GAP_realpath` before
the prefix comparisons in `PKGMAN_UserPackageInfo` and
`PKGMAN_RemoveDir`; on GAP before 4.15 the raw strings are compared as
before.

Assisted-by: Claude Code (Fable 5.1)
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.03%. Comparing base (c72c260) to head (da7193e).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
gap/directories.gi 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
- Coverage   86.79%   85.03%   -1.76%     
==========================================
  Files          22       22              
  Lines        1022     1036      +14     
==========================================
- Hits          887      881       -6     
- Misses        135      155      +20     
Files with missing lines Coverage Δ
gap/directories.gd 100.00% <100.00%> (ø)
gap/packageinfo.gi 93.05% <100.00%> (+0.09%) ⬆️
gap/directories.gi 82.56% <76.92%> (-15.37%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fingolfin

Copy link
Copy Markdown
Member

This fails CI tests in GAP 4.12 as that doesn't have GAP_realpath -- so this PR needs to increase the minimal GAP version in PackageInfo.g suitably

@fingolfin fingolfin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the failing test, this seems fine to me. @mtorpey ?

Comment thread gap/directories.gi
InstallGlobalFunction(PKGMAN_RealPath,
function(path)
local res;
if IsBound(GAP_realpath) then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line tries to limit this change to versions that have GAP_realpath. Maybe this doesn't work then as yi expect?

@mtorpey mtorpey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments with things I'm not sure about. The overall question is: when precisely do we need to pass paths through PKGMAN_RealPath and when don't we? Obviously there are hundreds of places we work with file paths in this package, and we only change a few of them here.

Comment thread gap/directories.gi
Comment thread gap/directories.gi
@lgoettgens

Copy link
Copy Markdown
Contributor Author

when precisely do we need to pass paths through PKGMAN_RealPath and when don't we?

You only need to use realpaths if you want to compare them for equality (or some kind of prefix-check). Everything else should be handled by the file system transparently.

@mtorpey

mtorpey commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks! I think I'm happy with the principle.

Comment thread gap/directories.gi Outdated
Comment thread gap/directories.gi Outdated
lgoettgens and others added 2 commits October 22, 2026 18:06
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
@lgoettgens

Copy link
Copy Markdown
Contributor Author

The failures with gap 4.12 seem to be due to the json 3.0.0 release a few weeks ago, and thus unrelated to this PR here.

@mtorpey

mtorpey commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

I think this is good! I should be able to merge tomorrow and then get it into 2.0 as well.

@mtorpey
mtorpey merged commit 8e5b2bf into gap-packages:master Oct 23, 2026
4 of 5 checks passed
@lgoettgens
lgoettgens deleted the lg/realpath-userdir branch October 23, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants