Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use direnv environment #4977

Open
1 task done
d12bb opened this issue Mar 8, 2023 · 3 comments
Open
1 task done

Use direnv environment #4977

d12bb opened this issue Mar 8, 2023 · 3 comments
Labels
enhancement [core label] priority request A request from a stakeholder or influential user

Comments

@d12bb
Copy link

d12bb commented Mar 8, 2023

Check for existing issues

  • Completed

Describe the feature

Zed should support direnv, to enable using a different environment (espeacially $PATH) for different projects. In combination with #4978 this would enable e.g. using different versions of language servers and tooling, or tooling just installed for the project instead of system-wide using Nix.

If applicable, add mockups / screenshots to help present your vision of the feature

Inspiration from other editors:

@d12bb d12bb added enhancement [core label] triage Maintainer needs to classify the issue labels Mar 8, 2023
@JosephTLyons JosephTLyons removed the triage Maintainer needs to classify the issue label Mar 8, 2023
@szlend
Copy link

szlend commented Oct 25, 2023

A few issues that almost every editor suffers from when implementing direnv support:

  • Direnv initializes too late, causing problems with certain extensions that rely on direnv to set the PATH (e.g. for utilities like language servers and linters). Ideally there was a way for the direnv extension to hook into some really early phase of initialization where it can set environmental variables before other extensions initialize.
  • When you already have a project open and you open another project in a new window, the environment in the new window gets inherited from the first window. Normally this isn't a problem because it's just global system environment variables. But with direnv it's annoying because the second project will inherit environmental variables from the first project, potentially loading incorrect versions of linters, language servers, etc. Ideally the editor would save the state of environmental variables before applying direnv. And any new window that you open would inherit from that saved state.

Just something worth considering when designing the extension API and implementing this feature.

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@misuzu
Copy link

misuzu commented Jan 31, 2024

  • Direnv initializes too late, causing problems with certain extensions that rely on direnv to set the PATH (e.g. for utilities like language servers and linters). Ideally there was a way for the direnv extension to hook into some really early phase of initialization where it can set environmental variables before other extensions initialize.

Yep, the extension API must have support for this usecase to properly implement direnv integration. This is the reason why https://github.com/misuzu/direnv-subl is flawed - ST just doesn't have the necessary API. The direnv integration that just works would be The Feature that can ease the pain of setting up any project for many people.

@szlend
Copy link

szlend commented Feb 14, 2024

Another useful feature that I think a direnv extension should have is to be able to re-load the environment so you don't have to restart your editor. The way this works in vscode for example is that it changes the process environment and then restarts the extension host (and all language servers as a result).

Also initializing direnv can take some time. For example if you use direnv to load a nix shell, it might actually start downloading packages or even compiling. So it might make sense to show some sort of indicator that direnv is still evaluating something. And a way to cancel it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] priority request A request from a stakeholder or influential user
Projects
None yet
Development

No branches or pull requests

4 participants