jbrzozo24
jbrzozo24

Reputation: 1

Adding Windows Path back to WSL

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"

Upvotes: 0

Views: 8003

Answers (1)

Hebert Luiz
Hebert Luiz

Reputation: 66

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.

Upvotes: 4

Related Questions