Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TinyAtoms opened this issue Nov 14, 2019 · 8 comments
Closed
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@TinyAtoms
Copy link

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.

@TinyAtoms TinyAtoms added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2019
@brettcannon
Copy link
Member

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

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Nov 14, 2019
@TinyAtoms
Copy link
Author

TinyAtoms commented Nov 16, 2019

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.

@brettcannon brettcannon changed the title when using virtualenv and fish as the default shell, the environment doesn't get activated correctly Support "terminal.integrated.automationShell" for environment activation Nov 18, 2019
@brettcannon brettcannon added area-environments Features relating to handling interpreter environments needs decision feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Nov 18, 2019
@brettcannon
Copy link
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).

@brettcannon brettcannon reopened this Nov 18, 2019
@TinyAtoms
Copy link
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.

@brettcannon
Copy link
Member

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

@TinyAtoms
Copy link
Author

TinyAtoms commented Nov 19, 2019

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

@luabud luabud added needs PR bug Issue identified by VS Code Team member as probable bug and removed needs decision feature-request Request for new features or functionality labels Jan 11, 2020
@karrtikr
Copy link

karrtikr commented Oct 20, 2021

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.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Oct 20, 2021
@brettcannon
Copy link
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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants