Skip to content

Support fish by sourcing activate.fish #13854

Description

@otisdog8

Environment data

  • VS Code version: 1.48.2
  • Extension version (available under the Extensions sidebar): Version: 1.48.2
  • OS and version: Arch Linux, 5.8.7-arch1-1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): poetry (virtualenv maybe)
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: ms-python.python
  • Value of the python.languageServer setting: Mircrosoft

Expected behaviour

Opening a terminal automatically activates the selected virtual environment, by running
source <python.venvpath>/bin/activate.fish

Actual behaviour

Fish errors because it runs:
source <python.venvpath>/bin/activate
This is for bash shells

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Setup Fish by adding this to the end of ~/.bashrc
    if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" ]]
    then
    exec fish
    fi
  2. Create and select a virtual enviornment
  3. Open a terminal
  4. first command that is run is source <python.venvpath>/bin/activate, which fails for fish.
    (Setting the terminal.integrated.automationShell.linux variable does not change the result, but changing "terminal.integrated.shell.linux" fixes the issue). However, this breaks other parts of my setup.

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'LocalZMQKernel - control'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - control'
User belongs to experiment group 'CustomEditorSupport - control'
User belongs to experiment group 'pythonaacf'

conda --version
conda info --json
pyenv root
python3.7 ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
python3.6 ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
python2 ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
python3 ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
python ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
~/.cache/pypoetry/virtualenvs/icons-egDUSKH7-py3.8/bin/python ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2020-09-09 13:32:10: Failed to check if file needs to be fixed EntryNotFound (FileSystemError): Unable to read file '/home/otis/.config/Code/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/home/otis/.config/Code/User/settings.json')
at _handleError (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:672:249)
at v.readText (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:1:495817)
at p.doesFileNeedToBeFixed (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:56:953520)
at /home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:56:952647
at async Promise.all (index 0)
at p.getFilesToBeFixed (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:56:952593)
at p.updateTestSettings (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:56:952220) {
code: 'FileNotFound',
name: 'EntryNotFound (FileSystemError)'
}
~/.cache/pypoetry/virtualenvs/icons-egDUSKH7-py3.8/bin/python ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
~/.cache/pypoetry/virtualenvs/icons-egDUSKH7-py3.8/bin/python ~/.vscode-oss/extensions/ms-python.python-2020.8.106424/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
Starting Microsoft Python language server.
Python interpreter path: ~/.cache/pypoetry/virtualenvs/icons-egDUSKH7-py3.8/bin/python
Error 2020-09-09 13:32:10: Failed to download and store experiments, Class name = b, completed in 2634ms, has a falsy return value, , Return Value: undefined Error: Failed with status 404, Not Found, Uri https://raw.githubusercontent.com/microsoft/vscode-python/master/experiments.json
at H._callback (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:54:713175)
at H.a._callback.a.callback.a.callback [as callback] (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:5442)
at H.emit (events.js:203:13)
at H. (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:18302)
at H.emit (events.js:203:13)
at IncomingMessage. (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:17134)
at Object.onceWrapper (events.js:291:20)
at IncomingMessage.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1168:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Error 2020-09-09 13:32:10: Failed to initialize experiments, Class name = b, completed in 2640ms, has a falsy return value, , Return Value: undefined Error: Failed with status 404, Not Found, Uri https://raw.githubusercontent.com/microsoft/vscode-python/master/experiments.json
at H._callback (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/extension.js:54:713175)
at H.a._callback.a.callback.a.callback [as callback] (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:5442)
at H.emit (events.js:203:13)
at H. (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:18302)
at H.emit (events.js:203:13)
at IncomingMessage. (/home/otis/.vscode-oss/extensions/ms-python.python-2020.8.106424/out/client/node_modules/request.js:189:17134)
at Object.onceWrapper (events.js:291:20)
at IncomingMessage.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1168:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
vslsStack: [
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {},
CallSite {}, CallSite {}
]
}
conda --version

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Sep 9, 2020
  2. changed the title [-]Support fish or chang[/-] [+]Support fish or changing of virtual enviornment activation script[/+] on Sep 9, 2020
  3. changed the title [-]Support fish or changing of virtual enviornment activation script[/-] [+]Support fish by sourcing activate.fish[/+] on Sep 10, 2020
  4. brettcannon commented on Sep 10, 2020

    @brettcannon
    Member

    I can verify that fish is choosing activate.sh when the .fish file extension is left off.

  5. karrtikr commented on Sep 10, 2020

    @karrtikr

    You can set custom activation commands with #8870. Please upvote the feature request.

  6. brettcannon commented on Sep 10, 2020

    @brettcannon
    Member

    Jacob Root (@otisdog8) I actually can't reproduce this under Ubuntu or macOS:

    image

    What version of the extension are you using?

  7. otisdog8 commented on Sep 10, 2020

    @otisdog8
    Author

    I was using 2020.8.106424. (must have made a mistake on the issue that I posted) How did you setup fish on those other operating systems? I have mine setup so that the default OS shell is bash, as well as the actual shell configured in vscode, but then I have bashrc open fish with
    if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" ]]
    then
    exec fish
    fi

  8. brettcannon commented on Sep 11, 2020

    @brettcannon
    Member

    Jacob Root (@otisdog8) ah, that would explain it then as fish is my login shell on my OSs (set by using chsh).

    So this is occurring because we can't detect what your shell is after you launch the terminal. At that point we have no clue what you have typed, and so to us this is the same as launching bash and then typing fish at the terminal.

    If you want to have fish be your shell in VS Code then you can set "terminal.integrated.shell.linux" to the path of your fish shell and then VS Code will use and launch that in the terminal.

  9. locked as resolved and limited conversation to collaborators on Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-terminalbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions