zed icon indicating copy to clipboard operation
zed copied to clipboard

tasks: relative 'cwd' paths break commands

Open xezrunner opened this issue 1 year ago • 5 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Specifying a relative path as cwd in a task causes the command to not execute and an error is seen in the log.

Specifying a full path does work as expected.

Environment

Zed: v0.133.2 (Zed Preview)
OS: macOS 14.5.0
Memory: 8 GiB
Architecture: aarch64

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

Screen recording:

https://github.com/zed-industries/zed/assets/8061077/29bf217d-ccfd-4b8b-91cc-17cb36163829

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

2024-04-25T18:48:34+02:00 [ERROR] crates/terminal_view/src/terminal_panel.rs:510: Working directory: src Shell command: `/bin/zsh -i -c echo test`, IOError: Failed to spawn command '/bin/zsh': No such file or directory (os error 2)

Caused by:
    Failed to spawn command '/bin/zsh': No such file or directory (os error 2)

xezrunner avatar Apr 25 '24 17:04 xezrunner

Bumping this. Having same issue with same error. I'm not able to run specs in another directory in my workspace.

Korywon avatar Oct 16 '24 15:10 Korywon

I have a monorepo, with a backend folder where my Rails app lives. The workaround I'm using is to just cd into the directory.

[
  {
    "label": "rspec $ZED_FILENAME:$ZED_ROW",
    "command": "cd backend; bundle exec rspec test",
    "args": ["\"$ZED_FILE:$ZED_ROW\""],
    "tags": ["ruby-test"]
  }
]

It works, but not ideal.

Korywon avatar Oct 17 '24 19:10 Korywon

I think I'm seeing this behaviour without any relative paths being involved. In my case, I have a task as follows:

  {
    "label": "Cargo Check",
    "command": "cargo check",
    "args": ["--workspace", "--all-targets"],

    "shell": "system",
    "use_new_terminal": true,
    "allow_concurrent_runs": false,
    "reveal": "no_focus",
    "hide": "never"
  }

Running the task should use my default shell which is zsh. Zed detects that but tries to run /bin/zsh which does not exist. zsh is at /usr/bin/zsh which is in PATH and returned – correctly – by command -v zsh.

stephenmartindale avatar Dec 20 '24 17:12 stephenmartindale

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!

github-actions[bot] avatar Apr 23 '25 07:04 github-actions[bot]

If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open.

Relative paths for cwd flat-out don't appear to work. At this point, I'm not sure if this is even supposed to work at all.

Setting the command to pwd, and cwd to be a relative path, the output is simply the default path:

Image

Setting an absolute path does work:

Image

xezrunner avatar Apr 23 '25 12:04 xezrunner

I found a workaround:

[
  {
    "label": "Run",
    "command": "make -j",
    "cwd": "${ZED_WORKTREE_ROOT}/build/"
  }
]

Using ZED_WORKTREE_ROOT seems Okay, a little tedious but at least portable.

SuperKenVery avatar May 21 '25 03:05 SuperKenVery

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!

github-actions[bot] avatar Sep 24 '25 07:09 github-actions[bot]

We still see ZED_WORKTREE_ROOT everywhere in docs...

SuperKenVery avatar Sep 24 '25 10:09 SuperKenVery