0

I'm running Ubuntu20.04 using WSL2, and I'm rather new to linux. While setting up my environment, I messed up my $PATH, as it no longer includes all of the directories in my windows path. Whenever I open Ubuntu, the terminal spews a bunch of errors of this nature:

-bash: export: `Files/Intel/Intel(R)': not a valid identifier

This is one of many errors, one for each component of my windows path. I'm not sure where Windows appends to the linux PATH, so I'm not sure where to look to make the fix.

Edit: Per some of the comments and answers, I do modify the $PATH in my .bashrc, using the code below. Commenting out this code fixes my issue, but I'm not sure what's wrong with this:

function append_to_pathlist
{
  # get pathlist into local pathlist (add : at end)
  eval "temp_pathlist=\$$1:"
 
  # remove new path from local pathlist if exists
  temp_pathlist=${temp_pathlist//"$2:"}
 
  # append new path to front of local pathlist
  if [[ "${temp_pathlist}" == ":" ]]; then
    temp_pathlist="$2"
  else
    temp_pathlist="$2:${temp_pathlist}"
  fi
 
  # set pathlist to local pathlist (remove : at end)
  export $1=${temp_pathlist%":"}
}


# Set the ARCH environment variable
export ARCH="x86_64-ubuntu20_04"

append_to_pathlist PATH "/home/jbrzozo24/.local/bin"

#Add stow pkgs environment variable, and add it to path
export STOW_PKGS_GLOBAL_ROOT="/classes/ece4750/install/stow-pkgs"
export STOW_PKGS_GLOBAL_PREFIX="${STOW_PKGS_GLOBAL_ROOT}/${ARCH}"

append_to_pathlist PATH "${STOW_PKGS_GLOBAL_PREFIX}/bin"
#append_to_pathlist PATH "$/classes/ece4750/install/venv-pkgs/x86_64-ubuntu20_04/python2.7.12/bin"


#PKG CONFIG stu
append_to_pathlist PKG_CONFIG_PATH "${STOW_PKGS_GLOBAL_PREFIX}/share/pkgconfig"
append_to_pathlist PKG_CONFIG_PATH "${STOW_PKGS_GLOBAL_PREFIX}/lib/pkgconfig"
NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
jbrzozo24
  • 1
  • 1
  • 3
  • If there's any additional detail you can remember about what you did when setting up your environment (that could have contributed to this), it would be helpful to add that to the question. For instance, is there any PATH manipulation that you do in the startup files (.e.g `.bash_profile`, `.bashrc`, `.profile`, etc.)? – NotTheDr01ds Dec 31 '20 at 01:02
  • 1
    I do some path manipulation in my .bashrc, I append a few paths to $PATH. I use a helper function append_to_pathlist to do this. – jbrzozo24 Jan 01 '21 at 16:48
  • 1
    Commenting this code out fixes my issue. Where should I paste this code so you can take a look and perhaps find a mistake? – jbrzozo24 Jan 01 '21 at 16:54

1 Answers1

4

Windows passes environment variables internally when you start a new WSL process as shown in this article. Probably some profile script is overwriting the initial PATH variable. This documentation explains how to use Win32 variables inside WSL and the options available:

-bash: export: `Files/Intel/Intel(R)': not a valid identifier

Other possibility part of your path variable containing a non-escaped space or especial characters. You can print your path at the beginning of your ~/.bashrc or ~/.profile to see where is the problem.

Oliver Salzburg
  • 21,652
  • 20
  • 93
  • 138
  • Writing echo $PATH at the beginning of my .bashrc file shows that the Windows path is intact at the beginning of execution – jbrzozo24 Jan 01 '21 at 16:47
  • 2
    Technically this *answered* your original question (based on the edit you made to the question), and I believe should be accepted as the answer. It may not have completely *solved* your problem, but you did ask "where to look to make the fix." The edits to the question probably should have been a new question, IMHO. – NotTheDr01ds Jan 01 '21 at 18:40