3

I am trying to sign onto the bash Windows Subsystem for Linux when I get this error:

-bash: /home/User1/.profile: line 28: syntax error near unexpected token `('

Before getting this error I was trying to permanently put a directory in my path using the export PATH:$PATH function.

my /.profile file

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
export PATH=/home/user1/.local/bin:/home/janeen/bin:/home/janeen/miniconda3/bin:/home/User1/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/c/ProgramData/DockerDesktop/version-bin:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath_target_34052312:/c/Windows/System32:/c/Windows:/c/Windows/System32/wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Users/User1/AppData/Local/Programs/Python/Python36:/c/Users/Janeen/AppData/Local/Programs/Python/Python36/Scripts:/c/Users/User1/AppData/Local/Programs/Python/Python37-32/Scripts:/c/Users/Janeen/AppData/Local/Programs/Python/Python37-32:/c/Users/User1/AppData/Local/Microsoft/WindowsApps:/e/Program Files (x86)/TBtools/bin:/snap/bin:/software/samtools
pa4080
  • 30,621

2 Answers2

1

First, you need to quote the directory paths that include white spaces and special characters, or escape each of these characters by back slash - reference.

Second, the canonical way to change the PATH is:

export PATH=/some/new/path:$PATH

Thus you are adding some new path in front to the existing value of PATH, otherwise you wont be able to execute fluently couple of commands that are located in the default path.

Third within WSL, by default, the Windows drives C:, D: and so on, are mounted under /mnt - i.e. /mnt/c, /mnt/d, etc. Here is example:

export PATH='/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath_':$PATH

Forth, there shouldn't be available file /.profile, it must be located in the users home directory ~/.profile ($HOME/.profile). Also your .profile file looks incomplete here is how the default one looks like: WSL .profile. In the profile file that is posted within the question the .bashrc file is not sourced.

pa4080
  • 30,621
0

When the Linux instance is setup the host machine PATH variable is cloned into the Linux machine .bashrc file (with conversions made to the paths to make them work from inside WSL).

source: https://lifesaver.codes/answer/problems-with-windows-path-variable-getting-imported-1890

When the PATH variable contains spaces you get this error, most likely wrapping the entire value of PATH in quotes will fix it. you can also remove the offending pathes if you don't need them.

If you need a more permanent solution, meaning a "fix once per host machine" instead of "once per guest machine creation" try going down this path:

https://github.com/microsoft/WSL/issues/1640#issuecomment-276408942