View Issue Details

IDProjectCategoryView StatusLast Update
0004067OpenFOAMBugpublic2024-07-02 14:32
Reporterblackk100 Assigned Tochris  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/Linux WSL2OSUbuntuOS Version22.04
Product Version11 
Fixed in Versiondev 
Summary0004067: Cleaned PATH eats up valid paths
DescriptionfoamCleanPath considers whitespaces and colons as valid field separators, although Linux only specifies colons for splitting the actual paths (at least according to this https://www.linfo.org/path_env_var.html).

This is especially an issue on WSL 2 as Windows appends its own PATH when installing the OS (in the form of /mnt/c/Program Files/...). This results in the user being unable to call Windows executables from the WSL OS (such as VS Code or explorer.exe).
Steps To ReproduceSource etc/bashrc
Additional InformationThis can be fixed easily if a copy of the PATH variable is made before souring etc/bashrc:

win_path=$(sed "s|^$(sed "s|:/mnt.*$||g" <<< $PATH)||g" <<< $PATH)
. /opt/openfoam11/etc/bashrc
export PATH=$(sed "s|:/mnt.*$|$win_path|g" <<< $PATH)
unset win_path
TagsNo tags attached.

Activities

blackk100

2024-03-27 19:55

reporter   ~0013219

This is an update to the workaround to deal with regex metacharacters in the PATH. This also assumes that the first mount point in the PATH is located after any OpenFOAM paths, and is run in bash.

path_wsl=$(sed 's|:/mnt.*||' <<< $PATH)
path_wsl=$(sed -e 's|\^|\\\^|g' -e 's|\$|\\\$|g' -e 's|\*|\\\*|g' -e 's|\+|\\\+|g' -e 's|\?|\\\?|g' -e 's|\.|\\\.|g' <<< $path_wsl)
path_win=$(sed "s|^$path_wsl||" <<< $PATH)
. /opt/openfoam11/etc/bashrc
path_wsl=$(sed 's|:/mnt.*||' <<< $PATH)
export PATH="$path_wsl$path_win"
unset path_wsl path_win

chris

2024-07-01 17:05

manager   ~0013291

We have updated the foamCleanPath script in OpenFOAM-dev
https://github.com/OpenFOAM/OpenFOAM-dev/commit/d7d83a923ae7686807d5d2d1e5b9271f164e2093

chris

2024-07-01 17:11

manager   ~0013292

In our tests, the updated foamCleanPath script preserves spaces in directory names on the PATH
The openfoam-dev package for Ubuntu 24.04 and 22.04 includes this change, so you could also test it.

blackk100

2024-07-01 23:07

reporter   ~0013293

I just tested OpenFOAM-dev, and it's preserving spaces now. Thank you!

chris

2024-07-02 09:00

manager   ~0013294

Thanks for the feedback. Others have confirmed the same. I think this is fixed.

chris

2024-07-02 09:00

manager   ~0013295

Resolved

Issue History

Date Modified Username Field Change
2024-03-26 02:04 blackk100 New Issue
2024-03-27 19:55 blackk100 Note Added: 0013219
2024-07-01 17:05 chris Note Added: 0013291
2024-07-01 17:11 chris Note Added: 0013292
2024-07-01 23:07 blackk100 Note Added: 0013293
2024-07-02 09:00 chris Note Added: 0013294
2024-07-02 09:00 chris Assigned To => chris
2024-07-02 09:00 chris Status new => closed
2024-07-02 09:00 chris Resolution open => fixed
2024-07-02 09:00 chris Note Added: 0013295
2024-07-02 14:32 will Status closed => resolved
2024-07-02 14:32 will Fixed in Version => dev