Can't find the OpenFOAMv2006 enviroment for installing PreCICE OpenFOAM-adapter

I tried to install the PreCICE OpenFOAM-adapter. The system I use is Linux-mint 19.1. Firstly I successfully installed PreCICE v2.1 and I runned the dummy example successfully. Then I tried to install a new version of OpenFOAM. I can’t install the OpenFOAM-v2006 using the binary. And I successfully built the OpenFOAM-v2006 from source following the instructions of And I tried to install the OpenFOAM -adapters following But when I typed ./Allwmake , it alwasys returned no OpenFOAM enviroment is available. I sourced the /etc/bashrc of OpenFOAM-v2006. And as you can see, I can echo $WM_PROJECT and $WM_PROJECT_VERSION with the output of “OpenFOAM” and “v2006”. I don’t know how to solve this problem. And I would like your help.

(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ sudo ./Allwmake [sudo] 
Current OpenFOAM environment:

=== ERROR: It looks like no OpenFOAM environment is available. ===
Possible reasons:
- Have you loaded the OpenFOAM etc/bashrc file?
- Are you using a compatible OpenFOAM version?
(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ echo $WM_PROJECT
(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ echo $WM_PROJECT_VERSION

Best wishes!

The problem here is the sudo:

(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ sudo ./Allwmake [sudo] 

Why did you add this? In general, I would recommend that you don’t run anything with sudo, unless you know why you want to do that. The most common reaon is that you want to edit some system file (e.g. under /usr/, /etc/ and similar paths). You don’t need this here, as you are doing everything in your home: ~/myProject/....

When you run a command with sudo, it runs it as the user root. This starts a separate shell (this [sudo] you see) with a different environment than afan (you can change this behavior, look at man sudo).

OpenFOAM works by setting environment variables (e.g. $WM_PROJECT and many more), which are not available when you run as root. Therefore, even though you loaded OpenFOAM before, it is not discoverable under sudo.

Simply running ./Allwmake shoud work (and it does work with v2006).

Thank you very much. It is the problem of using “sudo”. Now I successfully build it.

1 Like