f64bfe8c1d
Some checks are pending
CI / check_docs_only (push) Waiting to run
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Blocked by required conditions
CI / (Linux) Run Clippy and tests (push) Blocked by required conditions
CI / (Linux) Build Remote Server (push) Blocked by required conditions
CI / (Windows) Run Clippy and tests (push) Blocked by required conditions
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
CI / Auto release preview (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Script / ShellCheck Scripts (push) Waiting to run
Closes #13585 Currently, saving files with `root` ownership or `root` as the group throws a `Permission denied (os error 13). Please try again.` error. This PR fixes the issue on Linux by prompting the user for a password and saving the file with elevated privileges. It uses `pkexec` (Polkit), which is by default available on GNOME, KDE, and most Linux systems. I haven't implemented this for macOS as I don't have a device to test it on. This implementation is similar to how Vscode handles it. Except, they don't show custom message. **Working**: When file saving fails due to a `PermissionDenied` error, we create a temporary file in the same directory as the target file and writes the data to this temporary file. After, the contents of this file are copied to the original file using the `tee` command instead of `cp` or `mv`. This ensures that the ownership and permissions of the original file are preserved. This command is executed using `pkexec` which will prompt user for their password. **Custom Message**: The message displayed to the user in the prompt is automatically retrieved from the `org.zed.app.policy` file, which is located at `/usr/share/polkit-1/actions/`. This file should be installed during the setup process. While the policy file is optional, omitting it will cause the user to see the underlying command being executed rather than a user-friendly message. Currently, VSCode does not display the user-friendly message. The policy file must specify a unique binary, ensuring that only that binary can use the policy file. It cannot be as generic as a `/bin/bash`, as any software using bash to prompt will end up showing Zed’s custom message. To address this, we will create a custom bash script, as simple as the following, placed in `/usr/bin/zed/elevate.sh`. The script should have root ownership and should not reside in the home directory, since the policy file cannot resolve `$HOME`. ```sh #!/bin/bash eval "$@" ``` *IMPORTANT NOTE* Since copying the policy file and our script requires sudo privileges, the installation script will now prompt for the password at very end. Only on Linux, if `pexec` is installed. Screenshots: KDE with policy file: ![Screenshot from 2024-12-15 22-13-06](https://github.com/user-attachments/assets/b8bb7565-85df-4c95-bb10-82e50acf9b56) Gnome with policy file: ![Screenshot from 2024-12-15 22-21-48](https://github.com/user-attachments/assets/83d15056-a2bd-41d9-a01d-9b8954260381) Gnome without policy file: ![image](https://github.com/user-attachments/assets/66c39d02-eed4-4f09-886f-621b6d37ff43) VSCode: ![image](https://github.com/user-attachments/assets/949dc470-c3df-4e2f-8cc6-31babaee1d18) User declines the permission request: ![image](https://github.com/user-attachments/assets/c5cbf056-f6f9-43a8-8d88-f2b0597e14d6) Release Notes: - Fixed file saving with root ownership on Linux. |
||
---|---|---|
.. | ||
src | ||
theme | ||
.gitignore | ||
.prettierignore | ||
book.toml | ||
README.md |
Zed Docs
Welcome to Zed's documentation.
This is built on push to main
and published automatically to https://zed.dev/docs.
To preview the docs locally you will need to install mdBook (cargo install mdbook
) and then run:
mdbook serve docs
Preprocessor
We have a custom mdbook preprocessor for interfacing with our crates (crates/docs_preprocessor
).
If for some reason you need to bypass the docs preprocessor, you can comment out [preprocessor.zed_docs_preprocessor]
from the book.toml
.:
Images and videos
To add images or videos to the docs, upload them to another location (e.g., zed.dev, GitHub's asset storage) and then link out to them from the docs.
Putting binary assets such as images in the Git repository will bloat the repository size over time.
Internal notes:
- We have a Cloudflare router called
docs-proxy
that intercepts requests tozed.dev/docs
and forwards them to the "docs" Cloudflare Pages project. - CI uploads a new version to the Pages project from
.github/workflows/deploy_docs.yml
on every push tomain
.
Table of Contents
The table of contents files (theme/page-toc.js
and theme/page-doc.css
) were initially generated by mdbook-pagetoc
.
Since all this preprocessor does does is generate the static assets, we don't need to keep it around once they have been generated.
Referencing Keybindings and Actions
When referencing keybindings or actions, use the following formats:
Keybindings:
{#kb scope::Action}
- e.g., {#kb zed::OpenSettings}
.
This will output a code element like: <code>Cmd+,|Ctrl+,</code>
. We then use a client-side plugin to show the actual keybinding based on the user's platform.
By using the action name, we can ensure that the keybinding is always up-to-date rather than hardcoding the keybinding.
Actions:
{#action scope::Action}
- e.g., {#action zed::OpenSettings}
.
This will render a human-readable version of the action name, e.g., "zed: open settings", and will allow us to implement things like additional context on hover, etc.
Creating New Templates
New templates can be created by implementing the Template
trait for your desired template in the docs_preprocessor
crate.
References
- Template Trait: crates/docs_preprocessor/src/templates.rs
- Example template: crates/docs_preprocessor/src/templates/keybinding.rs
- Client-side plugins: docs/theme/plugins.js