Skip to content

settings: Fix incorrect worktree root for symlinked settings.json on Windows#51453

Merged
Veykril merged 1 commit intozed-industries:mainfrom
bryanpth:fix/symlinked-settings
Mar 24, 2026
Merged

settings: Fix incorrect worktree root for symlinked settings.json on Windows#51453
Veykril merged 1 commit intozed-industries:mainfrom
bryanpth:fix/symlinked-settings

Conversation

@bryanpth
Copy link
Copy Markdown
Contributor

@bryanpth bryanpth commented Mar 13, 2026

Closes #47007

After #50974, symlinked settings.json can be opened and saved, but the worktree ends up rooted at the file itself rather than its parent directory, which causes this error to be logged when changing settings via the settings GUI:

2026-03-18T22:24:05+01:00 ERROR [worktree] ignoring event
"C:\\Users\\Bryan\\dev\\bryanpth\\dotfiles\\config\\zed\\settings.json~RF1ab7ae0.TMP" outside of root path
"C:\\Users\\Bryan\\dev\\bryanpth\\dotfiles\\config\\zed\\settings.json"

Fixed by canonicalizing the symlink path before passing to open_paths.
Tested with a symlinked settings.json, both directly and through WSL.

Release Notes:

  • Fixed incorrect worktree root when settings.json is a symlink on Windows

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 13, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 13, 2026
@bryanpth bryanpth closed this Mar 15, 2026
@bryanpth bryanpth force-pushed the fix/symlinked-settings branch from 13634ef to cbc3966 Compare March 15, 2026 15:06
@bryanpth bryanpth reopened this Mar 15, 2026
@bryanpth bryanpth changed the title settings: fix symlinked settings file on windows settings: fix incorrect worktree root for symlinked settings.json on Windows Mar 15, 2026
@bryanpth bryanpth closed this Mar 18, 2026
@bryanpth bryanpth reopened this Mar 18, 2026
@maxdeviant maxdeviant changed the title settings: fix incorrect worktree root for symlinked settings.json on Windows settings: Fix incorrect worktree root for symlinked settings.json on Windows Mar 18, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 5d05f43

@bryanpth
Copy link
Copy Markdown
Contributor Author

Apologies for closing the PR earlier and re-opening it 6 minutes later, I thought the described error was no longer thrown but I was wrong!

@reflectronic reflectronic assigned Veykril and unassigned reflectronic Mar 23, 2026
@Veykril
Copy link
Copy Markdown
Member

Veykril commented Mar 24, 2026

Do you mind explaining why canonicalizing here fixes the issue? I lack the domain knowledge here to be able to tell

@bryanpth
Copy link
Copy Markdown
Contributor Author

Do you mind explaining why canonicalizing here fixes the issue? I lack the domain knowledge here to be able to tell

@Veykril

My apologies, I should've been more clear in the PR directly!

Canonicalizing the path basically makes sure that open_path gets the real resolved path directly so it can reuse the exisiting directory-level worktree.

Without it, open_path receives the symlink path (e.g: %APPDATA%\Zed\settings.json), it cannot find an exisiting worktree for it so it ends up creating a new one rooted at the file.

Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Thanks!

@Veykril Veykril enabled auto-merge (squash) March 24, 2026 15:57
@Veykril Veykril merged commit 2072471 into zed-industries:main Mar 24, 2026
26 checks passed
@bryanpth bryanpth deleted the fix/symlinked-settings branch March 24, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed fails to open symlinked settings file on Windows

4 participants