zed icon indicating copy to clipboard operation
zed copied to clipboard

Unable to evaluate "pwd" in task args

Open ODudek opened this issue 1 year ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

  1. Create task with definition like:
    {
        "label": "Run te.py",
        "command": "python3",
        "args": ["$(pwd)/te.py"]
    }
  1. run using command task: spawn
  2. Got en error can't open file '//$(pwd)/te.py': [Errno 2] No such file or directory

Environment

Zed: v0.124.8 (Zed) OS: macOS 13.5.2 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.

I can see error in logs like below:

2024-03-01T12:05:28+01:00 [ERROR] crates/tasks_ui/src/lib.rs:38: Cannot determine task cwd for multiple worktrees

ODudek avatar Mar 01 '24 11:03 ODudek

Hey, Thanks for reporting this issue. Currently we spawn static tasks (== tasks from tasks.json) without going through shell, which means that $(pwd) is interpreted literally. To work around that, you can spawn shell first:

  {
    "label": "Run te.py",
    "command": "bash",
    "args": ["-c", "python3 $(pwd)/te.py"]
  }

osiewicz avatar Mar 01 '24 15:03 osiewicz

For what it's worth, it seems like we'll have to spawn static tasks through shell, so your original example should work in the near future.

osiewicz avatar Mar 01 '24 16:03 osiewicz