conda-pack
conda-pack copied to clipboard
Permission error when packing to squashfs file on Linux
Checklist
- [X] I added a descriptive title
- [X] I searched open reports and couldn't find a duplicate
What happened?
While running command like this
conda pack --format=squashfs -n test-env
Things break when copying activate
script over into temp location, this happens when
- Conda is installed by
root
- Temp folder is on the same disk as conda
When creating temp copy of the environment squashfs plugin prefers to use hard-links when copying files on Linux
https://github.com/conda/conda-pack/blob/fcba5e0d21a5c0926e4f5c97c1d6d638ddaa8ca0/conda_pack/formats.py#L439-L443
but this doesn't work when source file is not owned by the user running conda pack
. This is the case when conda-pack
is installed by root
in base environment, while user running the packing is not root
https://github.com/conda/conda-pack/blob/fcba5e0d21a5c0926e4f5c97c1d6d638ddaa8ca0/conda_pack/formats.py#L458
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/conda_pack/cli.py", line 157, in main
pack(name=args.name,
File "/opt/conda/lib/python3.10/site-packages/conda_pack/core.py", line 542, in pack
return env.pack(output=output, format=format,
File "/opt/conda/lib/python3.10/site-packages/conda_pack/core.py", line 386, in pack
packer.finish()
File "/opt/conda/lib/python3.10/site-packages/conda_pack/core.py", line 1142, in finish
self.archive.add(source, target)
File "/opt/conda/lib/python3.10/site-packages/conda_pack/formats.py", line 247, in add
self._add(source, target)
File "/opt/conda/lib/python3.10/site-packages/conda_pack/formats.py", line 487, in _add
copy_func(source, target_abspath)
PermissionError: [Errno 1] Operation not permitted: '/opt/conda/lib/python3.10/site-packages/conda_pack/scripts/posix/activate' -> '/tmp/tmp9x4imir_/bin/activate'
in the above copy_func
is partial(os.link, follow_symlinks=False)
. os.link
should be used only when source and destination share:
- same device
- same owner (
st_uid
)
Conda Info
No response
Conda Config
No response
Conda list
No response
Additional Context
No response