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

vistir assumes it has chmod permissions, preventing pipenv lock from completing #4195

Closed
GPHemsley opened this issue Apr 16, 2020 · 3 comments
Labels
Category: Error Handling Issue relates to error handling Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.

Comments

@GPHemsley
Copy link
Contributor

Issue description

We are running pipenv on a shared drive that has permissions set at the share/mount level, not at the file level, which means that chmod will always fail.

When running pipenv lock, a temporary file is created within the current directory. Near the end of the process, an unprotected chmod is attempted on that file, which results in an exception being thrown, Pipfile.lock not being updated, and the temporary file not being deleted.

The trouble is here:

os.chmod(f.name, stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

Expected result

Pipfile.lock updates without issue.

Actual result

$ pipenv lock
Locking [dev-packages] dependencies…
✔ Success!
Locking [packages] dependencies…
✔ Success!
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 332, in lock
    pypi_mirror=state.pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1088, in do_lock
    project.write_lockfile(lockfile)
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 840, in write_lockfile
    self.lockfile_location, **open_kwargs
  File "/usr/lib64/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/contextmanagers.py", line 224, in atomic_open_for_write
    os.chmod(f.name, stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
PermissionError: [Errno 1] Operation not permitted: '/.../.__atomic-writeed7p1955'
$ chmod 0644 .__atomic-writeed7p1955
chmod: changing permissions of ‘.__atomic-writeed7p1955’: Operation not permitted

Steps to replicate

  • Prevent chmod from succeeding in the current directory.
  • Run pipenv lock.
  • Wait until the end.
  • Notice that an exception is thrown, Pipfile.lock has not been updated, and a temporary file is left behind.

Pipenv version: '2018.11.26'

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.8',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '3.10.0-1062.18.1.el7.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Tue Mar 17 23:49:17 UTC 2020',
 'python_full_version': '3.6.8',
 'python_version': '3.6',
 'sys_platform': 'linux'}
@GPHemsley
Copy link
Contributor Author

Also filed sarugaku/vistir#110 upstream.

@techalchemy
Copy link
Member

Thanks for the report! I'll follow up over there as we may need to try a few things before we arrive at a decent resolution.

@techalchemy techalchemy added Category: Error Handling Issue relates to error handling Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv. and removed triage labels Apr 24, 2020
@techalchemy
Copy link
Member

This was resolved in #4255 due to vendored updates. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Error Handling Issue relates to error handling Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.
Projects
None yet
Development

No branches or pull requests

2 participants