zed icon indicating copy to clipboard operation
zed copied to clipboard

Support 'shell.nix' environments seem not working anymore

Open palmamartin opened this issue 1 year ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Hi all, We use for managing our dependencies of projects a shell.nix for installing them and load them with direnv. Dose Zed respect this in its environment?

Some time ago it did, but now it seems broken, and I do not now how best to debug this issue.

For example we use prettier installed local to each project for formatting. It get's install inside <project_dir>/node_modules/.bin/prettier. In our editor config we set up formatting like this:

...
 "language_overrides": {
        "TSX": {
          "format_on_save": "on",
          "formatter": {
              "external": {
                  "command": "node_modules/.bin/prettier",
                  "arguments": [
                      "--stdin-filepath",
                      "{buffer_path}"
                  ]
              }
          }
        },
...

But on save nothing happens... Investigating the zed.log we see the following:

2024-01-29T07:48:54 [ERROR] crates/editor/src/editor.rs:7598: failed to format via external command "node_modules/.bin/prettier"

Caused by:
    command failed with exit code Some(127):
    stdout: 
    stderr: env: node: No such file or directory

Environment

Zed: v0.119.20 (Zed) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

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

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

2024-01-29T07:48:54 [INFO] set status on client 46673: ConnectionError 2024-01-29T07:48:54 [ERROR] failed to connect timed out trying to establish connection 2024-01-29T07:48:54 [INFO] set status on client 46673: ReconnectionError { next_reconnection: Instant { tv_sec: 372708, tv_nsec: 643002000 } } 2024-01-29T07:48:54 [ERROR] crates/editor/src/editor.rs:7598: failed to format via external command "node_modules/.bin/prettier"

Caused by: command failed with exit code Some(127): stdout: stderr: env: node: No such file or directory

2024-01-29T07:48:55 [INFO] reload git repository ".git" 2024-01-29T07:48:55 [INFO] reload git repository ".git" 2024-01-29T07:48:59 [INFO] set status on client 46673: Reauthenticating 2024-01-29T07:48:59 [INFO] set status on client 46673: Reconnecting 2024-01-29T07:49:00 [INFO] connected to rpc endpoint https://collab.zed.dev/rpc

palmamartin avatar Jan 29 '24 07:01 palmamartin

Browsing the repository I found this crate: https://github.com/zed-industries/zed/tree/main/crates/prettier. Does this mean Zed uses prettier as default formatter?

palmamartin avatar Jan 31 '24 09:01 palmamartin

Try setting "formatter": "prettier"?

use zed builtin prettier

d1y avatar Jan 31 '24 10:01 d1y

Zed has a prettier integration, enabled by default due to "formatter": "auto" default settings. When enabled, prettier integration is supposed to look up in the project (or parent dirs) for prettier definition & installation and use that; if no definition traces found, then fall back and use a "default" prettier set up by Zed itself.

"auto" setting does apply LSP server formatting if prettier is not available, "formatter": "prettier" disables such fallback.

SomeoneToIgnore avatar Jan 31 '24 10:01 SomeoneToIgnore