2

Using xonsh as my shell and conda environments, I hit an error within the VSCode terminal when it attempts to activate an environment.

This is because VSCode issues the source activate environment command whenever the selected interpreter is a conda environment. That's correctly following the instructions from Anaconda and is discussed on https://github.com/Microsoft/vscode-python/issues/383

However, the Xonsh shell does things differently. It doesn't include a source command and instead has a plugin for managing conda environments (https://github.com/gforsyth/xonda). Within Xonsh, the correct command is conda activate environment

For the moment, I've created an alias for source as a workaround, but is there a better way? e.g. Is there some way to customise the command that's issued by VSCode?

meatballs
  • 3,917
  • 1
  • 15
  • 19
  • I don't use this environment so I'm not certain enough to post this as an answer, but my guess would be "not unless you fancy making an issue or PR to the VScode plugin to detect your shell and Do The Right Thing" – theheadofabroom Nov 28 '18 at 13:23
  • @theheadofabroom I suspect you may well be correct! – meatballs Nov 28 '18 at 13:25
  • I got curious, and it looks like it shouldn't actually be that difficult, it may be as simple as adding targetShell with a check to [condaActivationProvider.ts](https://github.com/Microsoft/vscode-python/blob/master/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts#L130) similar to [bash.ts](https://github.com/Microsoft/vscode-python/blob/master/src/client/common/terminal/environmentActivationProviders/bash.ts#L34). – theheadofabroom Nov 28 '18 at 13:38
  • I'm looking at exactly the same two files. I can feel a PR coming on... (probably also need a new entry in types.ts) – meatballs Nov 28 '18 at 13:40
  • https://github.com/Microsoft/vscode-python/pull/3488 – meatballs Nov 28 '18 at 14:14

1 Answers1

0

As shown in the question comments, the question asker has raised a Pull Request that will hopefully make this a non-issue in the future.

This answer is purely to highlight this information for future users and is marked community wiki to encourage future users to update this as and when more information comes to light.

Community
  • 1
  • 1
theheadofabroom
  • 20,639
  • 5
  • 33
  • 65