Repository: multiscale/muscle3 (language: python)

Issue:
Integration test `test_start_all` fails when LD_LIBRARY_PATH is defined
# Pytest error:

```text
integration_test/test_start_all.py:65: AssertionError
-------------------------------------------------- Captured log call ---------------------------------------------------
INFO     libmuscle.manager.instance_manager:instance_manager.py:99 Planned macro on Resources(<redacted>: 0)
INFO     libmuscle.manager.instance_manager:instance_manager.py:99 Planned micro on Resources(<redacted>: 0)
INFO     libmuscle.manager.instance_manager:instance_manager.py:122 Instantiating macro on Resources(<redacted>: 0)
INFO     libmuscle.manager.instance_manager:instance_manager.py:122 Instantiating micro on Resources(<redacted>: 0)
ERROR    libmuscle.manager.instance_manager:instance_manager.py:144 Instance macro quit with error 127
ERROR    libmuscle.manager.instance_manager:instance_manager.py:147 Output may be found in /tmp/pytest-of-<user>/pytest-3/test_start_all0/run/instances/macro
ERROR    libmuscle.manager.instance_manager:instance_manager.py:144 Instance micro quit with error 127
ERROR    libmuscle.manager.instance_manager:instance_manager.py:147 Output may be found in /tmp/pytest-of-<user>/pytest-3/test_start_all0/run/instances/micro
```

Inspecting stderr.txt of either component gives:
```
<redacted>/muscle3/libmuscle/cpp/build/libmuscle/tests/component_test: error while loading shared libraries: libmsgpackc.so.2: cannot open shared object file: No such file or directory
```

# Root cause

The yMMSL configuration (taken from run directory) has the following implementations section:

```yaml
implementations:
  component:
    env:
      +LD_LIBRARY_PATH: <redacted>/muscle3/libmuscle/cpp/build/msgpack/msgpack/lib
    executable: <redacted>/muscle3/libmuscle/cpp/build/libmuscle/tests/component_test
```

Note that this adds the string `<redacted>/muscle3/libmuscle/cpp/build/msgpack/msgpack/lib` to the LD_LIBRARY_PATH env variable. However, when LD_LIBRARY_PATH is something (e.g `/path/A:/path/B`) when starting, the last two paths are concatenated without the `:`-separator. This results in the file-not-found error observed above.



Discussion / hints:

Fix patch:
diff --git a/docs/source/examples/rd_implementations.ymmsl.in b/docs/source/examples/rd_implementations.ymmsl.in
index c6cef229..4f2b0c7b 100644
--- a/docs/source/examples/rd_implementations.ymmsl.in
+++ b/docs/source/examples/rd_implementations.ymmsl.in
@@ -8,23 +8,23 @@ implementations:
 
   reaction_cpp:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/cpp/build/reaction
 
   reaction_cpp_mpi:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/cpp/build/reaction_mpi
     execution_model: openmpi
 
   reaction_fortran:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/fortran/build/reaction
 
   reaction_fortran_mpi:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/fortran/build/reaction_mpi
     execution_model: openmpi
 
@@ -35,30 +35,30 @@ implementations:
 
   diffusion_cpp:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/cpp/build/diffusion
 
   diffusion_fortran:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/fortran/build/diffusion
 
   mc_driver_cpp:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/cpp/build/mc_driver
 
   mc_driver_fortran:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/fortran/build/mc_driver
 
   load_balancer_cpp:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/cpp/build/load_balancer
 
   load_balancer_fortran:
     env:
-      +LD_LIBRARY_PATH: MUSCLE3_HOME/lib
+      +LD_LIBRARY_PATH: :MUSCLE3_HOME/lib
     executable: MUSCLE3_EXAMPLES/fortran/build/load_balancer


Test patch:
diff --git a/integration_test/test_start_all.py b/integration_test/test_start_all.py
index bb8d03b2..e2cb813b 100644
--- a/integration_test/test_start_all.py
+++ b/integration_test/test_start_all.py
@@ -42,7 +42,7 @@ def test_start_all(tmpdir):
             'implementations:\n'
             '  component:\n'
             '    env:\n'
-            '      +LD_LIBRARY_PATH: {}\n'
+            '      +LD_LIBRARY_PATH: :{}\n'
             '    executable: {}\n'
             'resources:\n'
             '  macro:\n'
diff --git a/integration_test/test_start_mpi.py b/integration_test/test_start_mpi.py
index 233cd210..dca5c9d2 100644
--- a/integration_test/test_start_mpi.py
+++ b/integration_test/test_start_mpi.py
@@ -49,11 +49,11 @@ def test_start_mpi(tmpdir):
             'implementations:\n'
             '  component:\n'
             '    env:\n'
-            '      +LD_LIBRARY_PATH: {}\n'
+            '      +LD_LIBRARY_PATH: :{}\n'
             '    executable: {}\n'
             '  mpi_component:\n'
             '    env:\n'
-            '      +LD_LIBRARY_PATH: {}\n'
+            '      +LD_LIBRARY_PATH: :{}\n'
             '    executable: {}\n'
             '    execution_model: openmpi\n'
             'resources:\n'