Checklist
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
|
same_device = os.lstat(source).st_dev == os.lstat(os.path.dirname(target_abspath)).st_dev |
|
if same_device: |
|
copy_func = partial(os.link, follow_symlinks=False) |
|
else: |
|
copy_func = partial(shutil.copy2, follow_symlinks=False) |
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
|
copy_func(source, target_abspath) |
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
Checklist
What happened?
While running command like this
Things break when copying
activatescript over into temp location, this happens whenrootWhen creating temp copy of the environment squashfs plugin prefers to use hard-links when copying files on Linux
conda-pack/conda_pack/formats.py
Lines 439 to 443 in fcba5e0
but this doesn't work when source file is not owned by the user running
conda pack. This is the case whenconda-packis installed byrootin base environment, while user running the packing is notrootconda-pack/conda_pack/formats.py
Line 458 in fcba5e0
in the above
copy_funcispartial(os.link, follow_symlinks=False).os.linkshould be used only when source and destination share:st_uid)Conda Info
No response
Conda Config
No response
Conda list
No response
Additional Context
No response