Skip to content

Support "terminal.integrated.automationShell" for environment activation #8575

Closed

Description

@TinyAtoms

Environment data

  • VS Code version: 1.39.2
  • Extension version (available under the Extensions sidebar): 2019.10.44104
  • OS and version: Manjaro Linux
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.4 /dependent
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): whatever the default is

Expected behaviour

When fish is the integrated automation shell, the following should be run to activate an environment:
source <python.venvpath>/bin/activate.fish

Actual behaviour

When opening up a new terminal, or when trying to debug, the following gets run:
source <python.venvpath>/bin/activate
which is for bash shells. This doesn't activate the environment.

Steps to reproduce:

  1. have this in your user settings json: "terminal.integrated.automationShell.linux": "fish",
  2. activate a virtualenv environment
  3. open up a terminal, or try to debug a script
  4. first command that's run is source <python.venvpath>/bin/activate, which is for bash/zsh/dash, and will fail for fish and zsh

Logs

Not sure what logs would be useful, but here's an example when I try to debug a script

 ~/D/studproject  source /home/massiveatoms/virtualenvs/studieproject-ML/bin/activate              wo 13 nov 2019 21:28:05 -03
~/virtualenvs/studieproject-ML/bin/activate (line 82): Missing end to balance this if statement
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
^
from sourcing file ~/virtualenvs/studieproject-ML/bin/activate
        called on standard input

source: Error while reading file “/home/massiveatoms/virtualenvs/studieproject-ML/bin/activate”

^ that's just fish complaining because fish scripts have different syntax compared to bash, I think.

Activity

  1. added
    triage-needed
    bug
    on Nov 14, 2019
  2. brettcannon commented on Nov 14, 2019

    @brettcannon
    Member

    Duplicate of #8341 (which has a workaround for this problem).

  3. ghost removed
    triage-needed
    on Nov 14, 2019
  4. TinyAtoms commented on Nov 16, 2019

    @TinyAtoms
    Author

    Hey, could you perhaps point out the workaround?
    Because I'm just not seeing it.
    Also, I don't think our problems are duplicates.

    In your "Actual behaviour" section, you can see that the first thing that's run is
    source /Users/brettcannon/Repositories/brettcannon/caniusepython3/.venv/bin/activate.fish
    The problem I'm having is that vscode is running source ~/ENV/bin/activate instead of source ~/ENV/bin/activate.fish.
    Furthermore, I can manually run source ~/ENV/bin/activate.fish and everything will work fine, while you said that's another way to reproduce the issue for you?

    Also, (take this with a grain of salt, I'm new to fish) it kind of appears that you have a misconfigured fish problem? I had a similar issue when I tried to get virtualfish (a virtualenv wrapper for fish) to work, and I ended up removing my fish configs and reinstalling it to get normal virtualenv to work.

  5. changed the title [-]when using virtualenv and fish as the default shell, the environment doesn't get activated correctly[/-] on Nov 18, 2019
  6. added
    area-environments
    feature-request
    and removed
    bug
    on Nov 18, 2019
  7. brettcannon commented on Nov 18, 2019

    @brettcannon
    Member

    TinyAtoms Sorry! You're right, I misread your issue and didn't pick up on the "automationShell" part. I have reopened this as a feature request to support "editor.integrated.automationShell" for environment activation.

    As for the config issue, if I you can find something wrong in https://github.com/brettcannon/dotconfig/tree/master/fish then please let me know, otherwise the I have had has bit enough people that I think it might be a subtle problem (it's even been reported to virtualenv with no solution yet).

  8. TinyAtoms commented on Nov 18, 2019

    @TinyAtoms
    Author

    Hmmm, I see nothing wrong (with my untrained eye) with your fish configs.
    What version of fish and virtualenv are you using, btw? Maybe an update from one of them fixed the issue? I'm using fish 3.0.2-2 and virtualenv 16.7.7 and my activate.fish activates without errors.

  9. brettcannon commented on Nov 19, 2019

    @brettcannon
    Member

    Latest fish and I'm using venv, not virtualenv (mainly because it's better integrated and I can fish things in the stdlib 😁 ).

  10. TinyAtoms commented on Nov 19, 2019

    @TinyAtoms
    Author

    Hmm, I just tried it (never hear of venv before), but it works fine for me

    https://i.imgur.com/gsoxznP.png in plain terminal
    https://i.imgur.com/cYPf8gJ.png in vscode

  11. added
    bug
    and removed
    feature-request
    on Jan 11, 2020
  12. karrtikr commented on Oct 20, 2021

    @karrtikr

    Is this issue still happening with the latest version of the extension? We use VSCode API to detect the currently opened shell, which potentially could take care of this setting automatically.

  13. added
    info-needed
    on Oct 20, 2021
  14. brettcannon commented on Dec 14, 2021

    @brettcannon
    Member

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

  15. locked as resolved and limited conversation to collaborators on Jan 14, 2022
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-environmentsbuginfo-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions