Skip to content

Compare package paths with symlinks resolved - #154

Open
lgoettgens wants to merge 1 commit into
gap-packages:masterfrom
lgoettgens:lg/realpath-userdir
Open

lgoettgens wants to merge 1 commit 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 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.20%. Comparing base (c72c260) to head (1128712).

Files with missing lines Patch % Lines
gap/directories.gi 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
- Coverage   86.79%   85.20%   -1.59%     
==========================================
  Files          22       22              
  Lines        1022     1034      +12     
==========================================
- Hits          887      881       -6     
- Misses        135      153      +18     
Files with missing lines Coverage Δ
gap/directories.gd 100.00% <100.00%> (ø)
gap/packageinfo.gi 93.05% <100.00%> (+0.09%) ⬆️
gap/directories.gi 84.11% <90.90%> (-13.83%) ⬇️

... 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.

This branch has not been deployed

No deployments
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