tasks: Use environment variables from project (#15266)
This fixes #12125 and addresses what's described in here: - https://github.com/zed-industries/zed/issues/4977#issuecomment-2162094388 Before the changes in this PR, when running tasks, they inherited the Zed process environment, but that might not be the process environment that you'd get if you `cd` into a project directory. We already ran into that problem with language servers and we fixed it by loading the shell environment in the context of a projects root directory and then passing that to the language servers when starting them (or when looking for their binaries). What the change here does is to add the behavior for tasks too: we use the project-environment as the base environment with which to spawn tasks. Everything else still works the same, except that the base env is different. Release Notes: - Improved the environment-variable detection when running tasks so that tasks can now access environment variables as if the task had been spawned in a terminal that `cd`ed into a project directory. That means environment variables set by `direnv`/`asdf`/`mise` and other tools are now picked up. ([#12125](https://github.com/zed-industries/zed/issues/12125)). Demo: https://github.com/user-attachments/assets/8bfcc98f-0f9b-4439-b0d9-298aef1a3efe
This commit is contained in:
parent
5e04753d1c
commit
0360cda543
5 changed files with 205 additions and 34 deletions
|
@ -2257,6 +2257,7 @@ message TaskContextForLocation {
|
|||
message TaskContext {
|
||||
optional string cwd = 1;
|
||||
map<string, string> task_variables = 2;
|
||||
map<string, string> project_env = 3;
|
||||
}
|
||||
|
||||
message TaskTemplates {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue