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

Python: Create Terminal error command noise included when default shell is fish #4959

Closed
breathe opened this issue Mar 27, 2019 · 9 comments
Closed
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug

Comments

@breathe
Copy link

breathe commented Mar 27, 2019

Issue Type: Bug

Executing Python: Create terminal gives this output in the open terminal

Welcome to fish, the friendly interactive shell
ncohen@breathe-book ~/s/DefectCorrectionsNotebook> 
source /Users/ncohen/anaconda3/bin/activate
~/anaconda3/bin/activate (line 5): 'return' outside of function definition
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
                                            ^
from sourcing file ~/anaconda3/bin/activate
        called on standard input

source: Error while reading file '/Users/ncohen/anaconda3/bin/activate'
ncohen@breathe-book ~/s/DefectCorrectionsNotebook> conda activate DCN
ncohen@breathe-book ~/s/DefectCorrectionsNotebook>                                                                                                                                                                      (DCN) 

The line noise above comes from the fact that anaconda3/bin/activate is sh/bash syntax and not compatible with fish.

I think I see roughtly two possible approaches to fixing this:

Option 1

Assume that the user has already run the appropriate conda.fish script within their shell setup context in order to make conda available for use within their shell. For example in my ~/.config/fish/config.fish I have

source ~/anaconda3/etc/fish/conf.d/conda.fish

Which ensures (for conda 4.4 and greater) that 'conda` is in my PATH and that 'conda activate' will work correctly for use from the fish shell.

If this tact is used, then I would expect Python: Create Terminal to look like this

Welcome to fish, the friendly interactive shell
ncohen@breathe-book ~/s/DefectCorrectionsNotebook> conda activate DCN
ncohen@breathe-book ~/s/DefectCorrectionsNotebook>                                                                                                                                                                      (DCN) 

Option 2

If its not desirable to assume the user has setup their shell appropriately for conda -- then I think it would be needed to invoke the correct conda.{sh,fish,...} setup script for each shell. The activate script would work with bash shell I think but if the user's shell is fish the output should look like this

ncohen@breathe-book ~/s/DefectCorrectionsNotebook> source ~/anaconda3/etc/fish/conf.d/conda.fish
ncohen@breathe-book ~/s/DefectCorrectionsNotebook> conda activate DCN

I believe that last sequence will only work with anaconda 4.4 and greater -the pre-4.4 version of conda.fish assumed that the conda command had already been added to the user PATH -- whereas post 4.4 configures PATH to include the appropriate conda binary such that conda binary's conda activate command will work correctly with the fish shell. Conda notes on the 4.4 changes

Extension version: 2019.3.6139
VS Code version: Code 1.32.3 (a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4, 2019-03-14T22:46:48.547Z)
OS version: Darwin x64 18.2.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (3.02GB free)
Process Argv .
Screen Reader no
VM 0%
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Mar 27, 2019
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-terminal labels Mar 27, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Mar 27, 2019
@DonJayamanne DonJayamanne added needs PR triage-needed Needs assignment to the proper sub-team labels Mar 27, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Mar 27, 2019
@avarun42
Copy link

avarun42 commented Apr 6, 2019

Yes, this is quite annoying and happens every time I create a new terminal instance when working in a Python project. IMO there is no reason to be sourcing conda's bin/activate. The sane default is definitely for the user to setup their environment to already include conda's activate, and the python extension's only responsibility should be to activate the correct conda environment.

@caizixian
Copy link

I'm having the same issue and the path of conda can potentially be obtained from python.condaPath

@DonJayamanne DonJayamanne mentioned this issue Apr 17, 2019
24 tasks
@ion2014
Copy link

ion2014 commented Aug 14, 2019

As for today the bug persists, if you just want to get rid of the anooying error just uncheck the python > terminal: Activate Environment settings and activate the environment manually.

@gramster gramster added this to the FY20Q2 milestone Oct 30, 2019
@wayearn
Copy link

wayearn commented Jan 6, 2020

same bug

@RohanGautam
Copy link

Yes!!!!! This is so annoying

@lsorber
Copy link

lsorber commented Aug 13, 2020

See also this SO question, which was answered by @brettcannon. Unfortunately, even after conda init fish this still seems to be a problem.

Are there any workarounds (besides disabling automatic activation)?

@imyhxy
Copy link

imyhxy commented Oct 11, 2021

any update? can we just execute conda activate envname with the source xxx things?

@brettcannon
Copy link
Member

No specific update right now, but we do have plans to rework how we activate terminals via #11039 which will implicitly solve this.

And yes, you can do the activation manually. You can also launch VS Code from an activated environment and then turn off automatic activation as another work-around.

@karrtikr karrtikr self-assigned this Jun 7, 2022
@karrtikr karrtikr removed this from the FY20Q2 milestone Jun 7, 2022
@karrtikr
Copy link

karrtikr commented Jun 7, 2022

Unfortunately, even after conda init fish this still seems to be a problem.

With #18989 we now ensure source activate command is only sent if the shell is not initialized already (conda is not sourced), so this should no longer be an issue, closing this.

@karrtikr karrtikr closed this as completed Jun 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests