Failing to link between temp_dir_root and cache_dir

Issue #35 new
Former user created an issue

When the temp_dir_root and cache_dir are not in the same file system, for example temp_dir_root=/tmp and cache_dir=$HOME/.cache where the former is a tmpfs and the later is a mounted volume, the following error happens:

Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "/usr/lib/python3.6/shutil.py", line 550, in move
    os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmp2gfqbiq_/libdijitso-ffc_element_aa01f259b9735d7f8da7cf165de8b751779ae1f5.so' -> '/home/fenics/.cache/fenics/dijitso/lib/libdijitso-ffc_element_aa01f259b9735d7f8da7cf165de8b751779ae1f5.so.priv.182290022808748869710493385709191841998'

This failure happens because dijitso.system.move_file(src, dst) is using shutil.move(src, dst) which isn't capable of cross file system. Using shutil.copy(src, dst) in conjunction with os.remove(src) fixes this issue, ie changing

def move_file(srcfilename, dstfilename):
    """Move or copy a file."""
    assert os.path.exists(srcfilename)
    shutil.move(srcfilename, dstfilename)
    assert not os.path.exists(srcfilename)
    assert os.path.exists(dstfilename)

to

def move_file(srcfilename, dstfilename):
    """Move or copy a file."""
    assert os.path.exists(srcfilename)
    shutil.copy(srcfilename, dstfilename)
    os.remove(srcfilename)
    assert not os.path.exists(srcfilename)
    assert os.path.exists(dstfilename)

Host OS: Fedora 33 Host Filesystem BTRFT Image: quay.io/fenicsproject/stable Engine: podman Command: podman run --rm --userns keep-id -v fenics-instant-cache-stable:/home/fenics/.cache/fenics -v $HOME/fenics_shared:/home/fenics/shared:z -w /home/fenics/shared --env INSTANT_CACHE_DIR=/home/fenics/.cache/fenics/instant --env DIJITSO_CACHE_DIR=/home/fenics/.cache/fenics/dijitso -ti quay.io/fenicsproject/stable

Comments (0)

  1. Log in to comment