Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Running the "egg_info" command without proper rights results in a cryptic and unhelpful error message #3667

Closed
droodev opened this issue Nov 9, 2022 · 4 comments · Fixed by #3716
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@droodev
Copy link
Contributor

droodev commented Nov 9, 2022

setuptools version

setuptools == 65.5.1

Python version

Python 3.8, 3.9

OS

Ubuntu Mate

Additional environment information

I used setuptools via pip. However, the issue is not dependent on how exactly one runs the egg_info command.

Description

Develoiping a package, I tried to install it using pip with pyproject.toml specifying setuptools as a backend. After running
pip install -e .
I got an output with the following error:
running egg_info error: [Errno 13] Permission denied
The problem is that this error does not show to what the permission is denied.

I tracked it down, and the output comes from the utime function in this part (lines296-988) of setuptools/command/egg_info.py
(Click to see the file in the repo)

def run(self):
        self.mkpath(self.egg_info)
        os.utime(self.egg_info, None)

So os.utime raises an OSError which is then printed out. Unfortunately, for some weird reason, the raised error does not contain a properly filled field filename, hence one needs a workaround to really print the file out

Expected behavior

As usually with this kind of error, the expected output is something like:
error: [Errno 13] Permission denied: /foo/bar/package/src/package-egg.info

How to Reproduce

dist-err.zip
0. I assume that pip is installed.

  1. Unzip the above very simple package project
  2. Go to the main directory of the project (in which the pyproject.toml is)
  3. run sudo mkdir src/dist_err_pkg.egg-info (the quickest way of creating a directory inaccessible for a standard user in ubuntu)
  4. run pip install .

Output

  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      running egg_info
      error: [Errno 13] Permission denied
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
@droodev droodev added bug Needs Triage Issues that need to be evaluated for severity and status. labels Nov 9, 2022
@droodev
Copy link
Contributor Author

droodev commented Nov 9, 2022

One possible way of fixing it would be to slightly amend the beginning of run from setuptools/command/egg_info.py. As follows:

    def run(self):
        self.mkpath(self.egg_info)
        try: 
          os.utime(self.egg_info, None)
        except OSError as e:
          raise distutils.errors.DistutilsFileError(f"{self.egg_info}: {e}")

I am happy to help fixing this issue via something alike the above, if the maintainers agree that the solution is acceptable.

@abravalheri
Copy link
Contributor

Hi @droodev, thank you very much for reporting this.

The proposed solution sounds interesting and simple. Would you like to provide a PR? (Personally I would keep the traceback with raise ... from e)

@droodev
Copy link
Contributor Author

droodev commented Nov 21, 2022

Hi @abravalheri,

I will provide a PR soon. Thanks for the feedback!

droodev added a commit to droodev/setuptools that referenced this issue Nov 28, 2022
…e that was subject to the utime call; originally, the exception from utime does not point to this filepath. Ref pypa#3667.
droodev added a commit to droodev/setuptools that referenced this issue Nov 29, 2022
droodev added a commit to droodev/setuptools that referenced this issue Nov 29, 2022
droodev added a commit to droodev/setuptools that referenced this issue Nov 29, 2022
@droodev
Copy link
Contributor Author

droodev commented Nov 29, 2022

The PR is here ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants