Multiple KIM installations or cannot find libkim-api.so

Dear KIM users,

A common issue people have with using OpenKIM potentials is being unable to find libkim-api.so, or having multiple installations of OpenKIM and the simulation program not using the correct one.

If your program cannot find libkim-api.so, it is an obvious error message, but more confusing is when you have multiple installations of the KIM API, and the program is happily using the incorrect one.

A symptom of this is if your simulations run successfully with the default potentials packaged with the API (such as ex_model_Ar_P_LJ), but when you try to use any additional potentials installed using kim-api-collections-management, the model cannot be found.

It is not possible to cover all cases, but I hope this message will make you aware of the potential issue and present some common solutions.

This most commonly happens because you both built the KIM API from source, as well as installing it in a Conda environment (possibly unknowingly as a dependency). It can also happen if you build LAMMPS with the DOWNLOAD_KIM option (which should not be used – it is only for debugging).

The fix to both of these issues may be as easy as setting your LD_LIBRARY_PATH environment variable to the correct installation of the KIM API. Find the path to the kim-api-collections-management executable you have been using to install your models:

which kim-api-collections-management

Let’s say it’s something like /path/to/your/conda/environment/bin/kim-api-collections-management. Then the fix may be as simple as setting

export LD_LIBRARY_PATH='/path/to/your/conda/environment/lib/'

before running your program, or you can add it to your .profile, .bashrc, your Conda environment settings, etc.

As long as the program you are using was compiled for the same version of the KIM API, this is generally all you need to do. If this does not solve your problem, please read the READMEs and documentation for your simulation program, and ask in this forum if it is still unclear. For example, if your code is having trouble finding the KIM API during build time, see the following resources:
https://docs.lammps.org/Build_extras.html#kim
GULP: Item (3) in the README file for GULP 6.2

@akohlmey @relliott @julian please feel free to weigh in if you have anything to add.