Skip to content

Fix test-at-point path for a symlinked project root - #2183

Merged
bbatsov merged 2 commits into
masterfrom
fix/test-at-point-symlinked-root
Aug 31, 2026
Merged

Fix test-at-point path for a symlinked project root#2183
bbatsov merged 2 commits into
masterfrom
fix/test-at-point-symlinked-root

Conversation

@bbatsov

@bbatsov bbatsov commented Aug 31, 2026

Copy link
Copy Markdown
Owner

projectile-compilation-dir resolves symlinks and buffer-file-name doesn't, so a project reached through a symlinked path made the two disagree about where the root is. The relative name then climbed out of the project and the test runner rejected it:

go test -run '^TestApplyDiscount$' ./../../../../../tmp/checkout/pricing
directory /tmp/checkout/pricing outside main module

Every rule builds its file argument the same way, so this isn't Go-specific. Anything under /tmp on macOS hits it, as does a symlinked ~/src.

The name is still taken as spelled first. That's what keeps a file under a symlinked subdirectory working, since resolving that one is what would send it out of the project. Only when the spelled name escapes are both sides resolved, and that result is used only if it stays inside.


  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the docs (when adding new project types, configuration options, commands, etc)

`projectile-compilation-dir` resolves symlinks and `buffer-file-name`
does not, so when a project is reached through a symlinked path the two
disagree about where the root is and the relative name climbs out of the
project:

  go test -run '^TestApplyDiscount$' ./../../../../../tmp/checkout/pricing
  directory /tmp/checkout/pricing outside main module

Every rule gets the same relative name, so this was not Go-specific.
Anything under /tmp on macOS hits it, as does a symlinked ~/src.

The name is still taken as spelled first, which is what keeps a file
under a symlinked subdirectory working - resolving that one is what
would send it out of the project. Only when the spelled name escapes do
both sides get resolved, and that result is used only if it stays inside.
@bbatsov
bbatsov merged commit 3a6a999 into master Aug 31, 2026
5 checks passed
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.

1 participant