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

Confusing error - OSError: AF_UNIX path too long - when default temporary directory is too long #2105

Open
adamtheturtle opened this issue Apr 14, 2021 · 1 comment
Labels
C: configuration CLI and configuration T: bug Something isn't working

Comments

@adamtheturtle
Copy link

adamtheturtle commented Apr 14, 2021

Describe the bug A clear and concise description of what the bug is.

When black --diff is run with a long temporary directory, a confusing OSError is raised.

To Reproduce Steps to reproduce the behavior:

  1. Create a directory with >= 2 Python files
  2. Set the default temporary directory for tempfile.mkstemp() to something long (e.g. by using export TMPDIR=$TMPDIR$TMPDIR$TMPDIR; mkdir -p $TMPDIR).
  3. Run Black on it with the --diff option
  4. See error
Process SyncManager-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/managers.py", line 582, in _run_server
    server = cls._Server(registry, address, authkey, serializer)
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/managers.py", line 155, in __init__
    self.listener = Listener(address=address, backlog=16)
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/connection.py", line 453, in __init__
    self._listener = SocketListener(address, family, backlog)
  File "/opt/homebrew/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/connection.py", line 596, in __init__
    self._socket.bind(address)
OSError: AF_UNIX path too long

Aborted!

Expected behavior A clear and concise description of what you expected to happen.

I expected to see the diff suggested by Black.

Else, I would prefer to see a clear error.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: macOS and Linux. Python 3.9.4

Does this bug also happen on master? To answer this, you have two options:

Yes.

Additional context Add any other context about the problem here.

The reason for this bug is that multiprocessing.Manager() creates a socket.
The socket default address depends on the default temporary directory.
Sockets have a maximum address length.

In my use case I am running on CI where I do not control the temporary directory. I therefore have to omit --diff.

@adamtheturtle adamtheturtle added the T: bug Something isn't working label Apr 14, 2021
@JelleZijlstra JelleZijlstra added the C: configuration CLI and configuration label May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration CLI and configuration T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants