View Issue Details

IDProjectCategoryView StatusLast Update
0003730OpenFOAMBugpublic2021-09-26 21:59
ReporternoZeroDays Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionsuspended 
Summary0003730: foamVersion constructs the wrong path
DescriptionOn Ubuntu, OpenFOAM is typically installed in /opt/ directory.
However, when you invoke the foamVersion function on bash with an argument, it tries to construct a path to that version but the path is wrong, e.g:

$ foamVersion 8
bash: /opt/OpenFOAM-8/etc/bashrc: No such file or directory
Changed to OpenFOAM-8

notice that the path should be: /opt/openfoam8/etc/bashrc
Moreover, if you try to run invoke foamVersion again after it fails you will get:

foamVersion: command not found

Thanks,

TagsNo tags attached.

Activities

henry

2021-09-17 15:33

manager   ~0012194

foamVersion wasn't designed for /opt installations and never tested for that purpose. Can you propose a version which works for the current purpose and also suits your requirements?

noZeroDays

2021-09-17 18:48

reporter   ~0012195

Should the following version be sufficient?

foamVersion ()
{
    if [ "$1" ]; then
        foamInstDir=$FOAM_INST_DIR;
        . $WM_PROJECT_DIR/etc/config.sh/unset;
        . ${WM_PROJECT_DIR//[0-9]*/$1}/etc/bashrc; # replace the previous version number with the argument
        cd $WM_PROJECT_DIR;
        echo "Changed to OpenFOAM-$1" 1>&2;
    else
        echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2;
    fi
}

henry

2021-09-17 19:21

manager   ~0012196

While that will work for you it won't work for anyone with an OpenFOAM installation built from sources, i.e. anyone with an installation for which the current foamVersion was created.

noZeroDays

2021-09-17 19:43

reporter   ~0012197

Should we check if the path is valid before sourcing its bashrc file?

henry

2021-09-26 21:59

manager   ~0012203

Pending a patch which does not break the current designed behaviour.

Issue History

Date Modified Username Field Change
2021-09-17 14:49 noZeroDays New Issue
2021-09-17 15:33 henry Note Added: 0012194
2021-09-17 18:48 noZeroDays Note Added: 0012195
2021-09-17 19:21 henry Note Added: 0012196
2021-09-17 19:43 noZeroDays Note Added: 0012197
2021-09-26 21:59 henry Assigned To => henry
2021-09-26 21:59 henry Status new => closed
2021-09-26 21:59 henry Resolution open => suspended
2021-09-26 21:59 henry Note Added: 0012203