Skip to content

Provide Zed Data Dir as a TaskVariable#59564

Open
playdohface wants to merge 1 commit into
zed-industries:mainfrom
playdohface:provide-data-dir-to-tasks
Open

Provide Zed Data Dir as a TaskVariable#59564
playdohface wants to merge 1 commit into
zed-industries:mainfrom
playdohface:provide-data-dir-to-tasks

Conversation

@playdohface

@playdohface playdohface commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

For extensions providing tasks (like the ones that are exposed as the little play buttons next to e.g. test methods) it is extremely difficult to impossible to do non-trivial things in a platform-agnostic way, because the programming model is polyglot-shell-script-in-a-json-string.

Solution

The primary goal of this PR is to give extension-provided tasks access to the extension working directory ($ZED_EXTENSION_WORK_DIR/my_extension) so they can dispatch the logic to provided scripts/binaries, which allows for a much more reasonable programming model.

It does so by providing the resolved extension work dir (paths::extensions_dir()/work) as a TaskVariable, so scripts don't have to make guesses and/or duplicate code in above mentioned polyglot-shell-scripts-in-json-string kind of ways in order to dispatch their tasks correctly.

Context

I work primarily on the Java extension.
zed-extensions/java#94 is the issue that this would solve specifically for me
zed-extensions/java#274 contains some of our discussions on the subject
#45932 is a much more general approach at this, that would unlock more things to be done with extensions but means changes to the extension api, which comes with dangers and problems

Release Notes:

  • Added $ZED_EXTENSION_WORK_DIR Task Variable

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 18, 2026
@zed-community-bot zed-community-bot Bot added the community champion Issues filed by our amazing community champions! 🫶 label Jun 18, 2026
@maxdeviant

Copy link
Copy Markdown
Member

The primary goal of this PR is to give extension-provided tasks access to the extension working directory ($ZED_DATA_DIR/extensions/work/my_extension) so they can dispatch the logic to provided scripts/binaries, which allows for a much more reasonable programming model.

If this is about the extension case, then wouldn't it be better to include the path to the extension's working directory instead?

We don't want extensions having to have knowledge of where exactly on the system we store them.

@tartarughina

Copy link
Copy Markdown
Contributor

Having direct access to the extension working directory would be probably better. Less things to consider

@playdohface playdohface force-pushed the provide-data-dir-to-tasks branch from f433217 to 1bb236c Compare June 18, 2026 16:47
@playdohface

playdohface commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@maxdeviant Changed it. I was using the most generally useful value here on the chance there is a use case for it - but I can't see one myself tbh. To cater to our specific use case the extension work dir directly makes things slightly easier.
We can trivially traverse up to the data_dir, and we have to traverse down to the specific extension anyway, so realistically there is little difference which one we actually provide.

@MrSubidubi MrSubidubi added area:extensions/infrastructure Feedback for extensions APIs, creation, management, etc area:tasks Feedback for Zed's task support labels Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:extensions/infrastructure Feedback for extensions APIs, creation, management, etc area:tasks Feedback for Zed's task support cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants