CSCfi / hpc-container-wrapper

Tool to wrap installations into a container designed for use on HPC systems
MIT License
27 stars 8 forks source link

Fix bug in `generate_wrappers.sh` #13

Closed JMuff22 closed 1 year ago

JMuff22 commented 1 year ago

This bug was spotted running tests/tests.sh on LUMI. When creating a conda container common.sh cannot be sourced as there is a bash error in line 12 of generate_wrappers.sh: line 12: conditional binary operator expected.

Reproduce

conda_base.yml >>

channels:
  - conda-forge
dependencies:
  - numpy

req.txt >>

pyyaml

mkdir -p TEST_DIR/CONDA_INSTALL_DIR

conda-containerize new TEST_DIR/conda_base.yml -r TEST_DIR/req.txt --prefix TEST_DIR/CONDA_INSTALL_DIR

Opening a simple python shell e.g TEST_DIR/CONDA_INSTALL_DIR/bin/python :

hpc-container-wrapper/tests/TEST_DIR/CONDA_INSTALL_DIR/bin/../common.sh: line 12: conditional binary operator expected
hpc-container-wrapper/tests/TEST_DIR/CONDA_INSTALL_DIR/bin/../common.sh: line 12: syntax error near `singularity/mnt/session'
hpc-container-wrapper/tests/TEST_DIR/CONDA_INSTALL_DIR/bin/../common.sh: line 12: `if [[ grep singularity/mnt/session /proc/self/mountinfo ]];then'

It seems that sourcing common.sh is the problem

-bash: TEST_DIR/CONDA_INSTALL_DIR/common.sh: line 12: conditional binary operator expected
-bash: TEST_DIR/CONDA_INSTALL_DIR/common.sh: line 12: syntax error near `singularity/mnt/session'
-bash: TEST_DIR/CONDA_INSTALL_DIR/common.sh: line 12: `if [[ grep singularity/mnt/session /proc/self/mountinfo ]];then'

Suggested solution

Quick tests show that removing the [[...]] solves the problem. If you can think of a more elegant solution please contrib :).

The above shouldn't be a problem unless the bash versions are vastly different.

Nortamo commented 1 year ago

Fix was incorporated in separate PR, thanks for the contribution.