Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26751 Discussions

compilervars.sh error for spaces within $PATH in windows subsystem for linux 2

ml_1
Beginner
199 Views

When I run 

source /opt/intel/bin/compilervars.sh intel64

there are bash errors pop up due to the spaces in $PATH.

For example, I have path 

/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common

in the $PATH and it will not be preserved correctly when passed through the remove_duplicate_paths() function in comilervars.sh.

 

0 Kudos
6 Replies
Ron_Green
Moderator
186 Views

Windows subsystem for linux is not a supported OS/environment.  You will have to fix this issue on your own.

ml_1
Beginner
181 Views

Got it. Thank you for clarifying!

Ron_Green
Moderator
170 Views

I apologize, my response is a bit off tone.  What I meant to say is WSL is not an officially tested nor supported environment.  There are, however, a few users on this Forum using WSL.  Perhaps one of them has encountered this and will have a solution or workaround.

One thought I had - since this is Linux perhaps use the 'env2' solution HERE .  Since the compilervars script invokes so many other sub-scripts, it's a rat's nest to unwind to find all the right env vars and their settings.  env2 has to -to and -from, nothing saying you can't -from bash -to bash just to unravel all the spaghetti in the compilervars nest of sourcing.  Then once you have that -from script THEN perhaps backslash-escape the spaces "\ " for each place where you see Windows paths.

Steve_Lionel
Black Belt Retired Employee
167 Views

WSL purports to be Ubuntu. I'm wondering if the Intel scripts would work on Linux if path contained spaces, which is not typical on Linux.

ml_1
Beginner
158 Views

Hi Steve, I wonder the same. From what I can tell, it comes from the function

remove_duplicate_paths() {
  local arg=$1

  if [ "${INTEL_HOST_PLATFORM}" = "Darwin" ]; then
    local arr=(`echo ${!arg} | sed 's/:/\'$'\n/g'`)
  else
    local arr=(`echo ${!arg} | sed 's/:/\n/g'`)
  fi
  local fixarr=()
  local found=
  local i=0
  for var in ${arr[*]}; do
    found=0
    for dup in ${fixarr[*]}; do
      if [ "${dup}" = "${var}" ]; then
        found=1
        break
      fi
    done
    if [ "${found}" = "0" ]; then
      if [ "${#fixarr[*]}" = "0" ]; then
        fixarr=("${var}")
      else
        fixarr=("${fixarr[*]} ${var}")
      fi
    fi
  done
  echo $fixarg
  local fixarg=`echo ${fixarr[*]} | sed 's/ /:/g'`
  eval export \$arg="${fixarg}"
}

which uses spaces as a natural delimiter to make the different paths in $PATH as different strings to look for duplicates and substitute at the end with ":". It works cleverly for most traditional linux environments and I never had a problem with it until I start to use WSL2 on a new laptop yesterday. But from the look of it, it will fail if there is a space in any path in a regular linux environment as well. I wonder if it's better to write the remove duplicate function in perl or even awk to be bullet proof.

ml_1
Beginner
160 Views

Hi Ronald, No need to apologize and I appreciate your new input here. I think it's a valid way to manually fix the issue.  - Ming

Reply