question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing wheel with different users

See original GitHub issue

When attempting to install a wheel pip install package.whl with user user2, when the package had previously been installed with user1, I am seeing a OSError: [Errno 1] Operation not permitted: 'filname'.

This is on Ubuntu 14.10, user1 and user2 are both in group group, and the file which fails has permissions -rw-rw-r--, owned by user1 and group, so I would expect this to not fail.

This appears to be caused by shutil.copy2 in clobber() in wheel.py. Specifically, I am seeing the following behaviour (file is owned by user2 and group, running python as user1).

os.utime("file", None) -> Succeeds os.utime("file", (1415962103.9824536, 1415962103.9384534)) -> Fails

Exception:
Traceback (most recent call last):
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/req.py", line 671, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/req.py", line 901, in move_wheel_files
    pycompile=self.pycompile,
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/wheel.py", line 141, in move_wheel_files
    if not scheme:
  File "/home/user2/env/local/lib/python2.7/site-packages/pip/wheel.py", line 210, in clobber
    shutil.copy2(srcfile, destfile)
  File "/usr/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 98, in copystat
    os.utime(dst, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/home/user2/env/lib/python2.7/site-packages/package/extensions.py'

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:1
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
hamsolodevcommented, Apr 11, 2017

I do not think pip should be trying to set atime and mtime to arbitrary values when installing wheels, at least not when file owners do not match, as it would seem that this is something UNIX (or Linux at least) expressly forbids when operating on files owned by someone other than the current user (a common scenario in shared virtualenv environments.)

$ ls -l
total 4.0K
-rw-rw-r-- 1 mch mch   0 Apr 11 11:47 file_1
-rw-rw-r-- 1 mpd mch   0 Apr 11 11:39 file_2

Setting atime/mtime to current time of files you do not own is allowed (as long as you have write permission on the containing dir)

$ touch file_2
$ ls -l file_2
-rw-rw-r-- 1 mpd mch 0 Apr 11 13:04 file_2

Setting atime/mtime to an arbitrary value (here taken from file_1) is not allowed (more or less permissive permissions have no effect)

$ touch -r file_1 file_2
touch: setting times of 'file_2': Operation not permitted
2reactions
pfmoorecommented, Apr 28, 2020

I agree, I’d say this isn’t supported usage. We expect the user to have permission to install files in the target directory, this is just a manifestation of that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to install, download and build Python wheels - ActiveState
How to Download Wheels. Most packages provide multiple wheels – one for each version of Python and operating system the author supports. If...
Read more >
Is it possible to embed a wheel inside another Python wheel
I want users of my package to just pip install my-package and have openbabel installed as well. If they use Python 3.7 on...
Read more >
User Guide — wheel 0.38.4 documentation
To build a wheel for your project: python -m pip install build python -m build --wheel. This will build any C extensions in...
Read more >
Wheel group in permissions for an app ins… - Apple Community
Download and Install are combined into one operation. macOS create a group permission entry for the app with the Name 'wheel'; Privilege 'Read ......
Read more >
What Are Python Wheels and Why Should You Care?
This metadata helps with building and installing the package, but user's don't ... Another example of the compatibility check used for wheel installation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found