-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Summary
Zed do not remember previously selected python virtual environment across program restarts.
Description
Steps to reproduce:
- Open a python project
- Select a virtual environment other than the auto-detected one
- Restart Zed
Expected Behavior:
The previously selected environment is remembered. It seems clear to me that the PR introducing this intended it to be remembered. The selected environment is also written to the ~/.local/share/zed/db/0-global/db.sqlite DB.
Actual Behavior:
The virtual environment is just set back to the auto-detected environment on startup. If you set it again, the database accumulate entries for the workspace:
As far as I can see this is due to worktree_id not being an stable id, yet it is used as one:
zed/crates/workspace/src/persistence.rs
Line 478 in b01a6fb
| PRIMARY KEY (workspace_id, worktree_id, language_name, relative_worktree_path)) STRICT; |
| .set_toolchain(workspace_id, worktree_id, relative_path, toolchain.clone()) |
I'm not sure I've traced the code correct, but I think worktree_id originates from here which originates from here and ultimately here:
zed/crates/gpui/src/app/entity_map.rs
Line 89 in b01a6fb
| let id = self.ref_counts.write().counts.insert(1.into()); |
AFAIC there's nothing which makes this a stable identifier?
The whole thing is a bit perplexing to me though since it seems strange that this was not tested, and there's even been follow-up PRs on the feature related to persistence: #36035
This user claim it works. Though this other user says it's still an issue.
This comment indicates something is off.
I see that there's also a concept of a "remote worktree". Perhaps that id is stable?
(This issue is possibly/likely the same as this closed issue #21470)
I was planning to suggest a full fix, but I've since changed from conda to uv, and now the auto-detected venv is correct, so my motivation has wilted.
Zed Version and System Specs
Zed: v0.211.6 (Zed)
OS: Linux Wayland fedora 41
Memory: 62 GiB
Architecture: x86_64
GPU: AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO) || radv || Mesa 25.0.7
Metadata
Metadata
Labels
Type
Projects
Status