Skip to content

Support for Fish shell for debugging Python Functions #3172

Open
@drewsilcock

Description

@drewsilcock

When trying to run Python functions where my user shell is set to Fish, I am unable to debug functions using VS Code.

The error produced is:

> Executing task: . .venv/bin/activate && func host start <

.venv/bin/activate (line 40): Unsupported use of '='. In fish, please use 'set VIRTUAL_ENV "/Users/drew.silcock/Dev/vv/vv-functions/.venv"'.
from sourcing file .venv/bin/activate
.: Error while reading file '.venv/bin/activate'
The terminal process "/opt/homebrew/bin/fish '-c', '. .venv/bin/activate && func host start'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

For bash/zsh, activating a virtual environment meaning doing . .venv/bin/activate but for Fish it is . .venv/bin/activate.fish.

Looking at src/utils/venvUtils.ts, it looks like:

  • The extension assumes that the user is using bash (from getTerminal()) if they're not on Windows.
  • The extension (on non-Windows) only supports the activate command .venv/bin/activate, not .venv/bin/activate.fish.

This would be fine if there were some way to customise which shell to run the task with, but adding:

  "options": {
    "shell": {
      "executable": "/bin/bash",
      "args": ["-c"]
    }
  },

doesn't seem to work as VS Code still uses my default shell for running the task, presumably because this only applies to tasks of type "shell" whereas this is a task of type "func". I'm using the default task generated by the extension here.

Possible solutions:

  • Detect whether user shell is fish and adjust venv activate command accordingly.
  • Ensure that task is run with bash when on non-Windows platform instead of assuming that user shell is bash.
  • Allow user to customise which shell the func task should run in via some configuration parameter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions