Portable mode for Zed #21103
adament
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the branch portable_mode on adament/zed I have made some small modifications to the paths crate to enable a portable mode for Zed. The portable mode, when active, means that Zed stores all config, support, temp, logs, and crashes in a user specified directory rather than the system default folders. This is useful in a couple of cases:
In the current implementation I have gone for simple and explicit behaviour. But this is meant as a basis for a discussion rather than the only true way. I have tried to lay out my rationale for the current design below, but I hope to hear whether other people consider such a feature useful and if we can come up with a better design.
Activating portable mode
Currently the implementation uses the environment variable
ZED_PORTABLE_DIR
to activate portable mode and specify the root folder to store everything in. This has the disadvantage that the user must set this environment variable to activate portable mode. Which means they need some wrapper script or executable to start Zed in use case 2. Similarly for package managers like Scoop on Windows which generally uses portable mode applications.As an alternative Visual Studio Code activates portable mode by detecting whether a folder
data
exists next to the executable. While this is a neat solution I think it has more steps which could fail and thus need to be considered: Determine the location of the executable, detect whether a folder exists next to it, and handle the case of Application Bundles on macos.A third option could be to simply make portable mode a compile time directive, but that means separate executables for portable mode and regular installation.
Temporary files
The current implementation also stores temporary files under the portable folder, this is in an attempt to make the portable version as self-contained as possible. However this might be considered surprising and come with performance impacts in the case the portable mode folder is a network drive or usb stick.
Visual Studio Code uses the system temp folder by default but detects if a
tmp
folder exists inside the portable mode folder, and if it does uses thedata\tmp
folder instead.Beta Was this translation helpful? Give feedback.
All reactions