VS Code, Python and Fedora on WSL
Jan 27, 2022
When trying to set up my development environment for Python using WSL and VS Code, I found that I was unable to select an interpereter from the list in VS Code as the list was flickering at a rate that made such a selection impossible. I found that the following was being spammed into the VS Code terminal:
bash: which: line 1: syntax error: unexpected end of file
bash: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
/usr/bin/sh: which: line 1: syntax error: unexpected end of file
/usr/bin/sh: error importing function definition for `which'
On checking the Fedora rootfs for anything that redefines the which
command, I found /etc/profile.d/which2.sh
, which aliases which
to include aliases and functions defined in the shell. The VS Code Python plugin cannot parse the output of this aliased which
, causing the error. Deleting /etc/profile.d/which2.sh
solves the problem - until the next which
package update, at least.