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

**URL:** <https://precice.discourse.group/t/cant-find-the-openfoamv2006-enviroment-for-installing-precice-openfoam-adapter/343>\
**Category:** Official adapters and tutorials\
**Tags:** openfoam, adapters\
**Created:** [October 5, 2020, 4:23am UTC](https://precice.discourse.group/t/cant-find-the-openfoamv2006-enviroment-for-installing-precice-openfoam-adapter/343 "2020-10-05T04:23:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dolphin](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@Dolphin](https://precice.discourse.group/u/Dolphin)\
**Post date:** [October 5, 2020, 4:23am UTC](https://precice.discourse.group/t/cant-find-the-openfoamv2006-enviroment-for-installing-precice-openfoam-adapter/343/1 "2020-10-05T04:23:49Z")

</div>

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 [https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md](https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md). And I tried to install the OpenFOAM -adapters following [https://github.com/precice/openfoam-adapter/wiki/Building](https://github.com/precice/openfoam-adapter/wiki/Building). 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:
  WM_PROJECT = 
  WM_PROJECT_VERSION = 

=== 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?
  See https://github.com/precice/openfoam-adapter/wiki/Notes-on-OpenFOAM
(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ echo $WM_PROJECT
OpenFOAM
(base) afan@afan-XPS-8700:~/myProject/precice/openfoam-adapter$ echo $WM_PROJECT_VERSION
v2006

```

Best wishes!

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [October 5, 2020, 6:05am UTC](https://precice.discourse.group/t/cant-find-the-openfoamv2006-enviroment-for-installing-precice-openfoam-adapter/343/2 "2020-10-05T06:05:25Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Dolphin](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@Dolphin](https://precice.discourse.group/u/Dolphin)\
**Post date:** [October 5, 2020, 6:37am UTC](https://precice.discourse.group/t/cant-find-the-openfoamv2006-enviroment-for-installing-precice-openfoam-adapter/343/3 "2020-10-05T06:37:37Z")

</div>

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