When deploying with CDK, I started out of nowhere getting this error:

OSError: [Errno 18] Invalid cross-device link: '/tmp/pip-target-e_4qns87/lib/python/numpy' -> '/asset-output/numpy'

This seems to be caused by using gRPC FUSE for file sharing in Docker. To fix this, change the setting for file sharing implemnentations from gRPC FUSE to VirtioFS.

If this doesn’t work, it could imply a corrupted virtual environment. Build a new one and try again with that. This was what did the trick for me - but only for one deployment. Updating the few Python 3.8 lambda runtimes to 3.9 fixed it.

The root cause could be from doing a keyboard interrupt during a deploy. Deleting existing images from within VS Code seems to have worked.

Source#

Source note