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

Running pipenv in / causes a stacktrace AssertionError on assert self.name #3434

Closed
asottile opened this issue Jan 9, 2019 · 2 comments
Closed

Comments

@asottile
Copy link

asottile commented Jan 9, 2019

Issue description

A stacktrace is produced when running in /, this same stacktrace appears in #2306 but there was no resolution/fix there.

Expected result

No stacktrace, perhaps a useful error message, or perhaps when in / it could use a name of 'root' and "just work".

Actual result

$ docker run --rm -ti python:3.5-slim bash -c 'pip install pipenv && pipenv install pytest'
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
    100% |████████████████████████████████| 5.2MB 6.9MB/s 
Collecting virtualenv-clone>=0.2.5 (from pipenv)
  Downloading https://files.pythonhosted.org/packages/16/9d/6419a4f0fe4350db7fdc01e9d22e949779b6f2d2650e4884aa8aededc5ae/virtualenv_clone-0.4.0-py2.py3-none-any.whl
Collecting certifi (from pipenv)
  Downloading https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl (154kB)
    100% |████████████████████████████████| 163kB 16.2MB/s 
Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.5/site-packages (from pipenv) (18.1)
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.5/site-packages (from pipenv) (40.6.3)
Collecting virtualenv (from pipenv)
  Downloading https://files.pythonhosted.org/packages/6a/d1/e0d142ce7b8a5c76adbfad01d853bca84c7c0240e35577498e20bc2ade7d/virtualenv-16.2.0-py2.py3-none-any.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 13.6MB/s 
Installing collected packages: virtualenv-clone, certifi, virtualenv, pipenv
Successfully installed certifi-2018.11.29 pipenv-2018.11.26 virtualenv-16.2.0 virtualenv-clone-0.4.0
Creating a virtualenv for this project…
Pipfile: /Pipfile
Using /usr/local/bin/python (3.5.6) to create virtualenv…
⠸ Creating virtual environment...Already using interpreter /usr/local/bin/python
Using base prefix '/usr/local'
New python executable in /root/.local/share/virtualenvs/-x-v5uFv0/bin/python
Installing setuptools, pip, wheel...
done.

✔ Successfully created virtual environment! 
Virtualenv location: /root/.local/share/virtualenvs/-x-v5uFv0
Creating a Pipfile for this project…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/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.5/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/usr/local/lib/python3.5/site-packages/pipenv/core.py", line 1741, in do_install
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.5/site-packages/pipenv/core.py", line 609, in ensure_project
    validate=validate, skip_requirements=skip_requirements, system=system
  File "/usr/local/lib/python3.5/site-packages/pipenv/core.py", line 320, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/usr/local/lib/python3.5/site-packages/pipenv/project.py", line 697, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/usr/local/lib/python3.5/site-packages/pipenv/patched/notpip/_internal/cli/parser.py", line 142, in __init__
    assert self.name
AssertionError

Steps to replicate

The actual result above contains a single command which replicates this issue


$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: '/usr/local/lib/python3.5/site-packages/pipenv'

Python location: '/usr/local/bin/python'

Python installations found:

  • 3.5.6: /usr/local/bin/python3.5m
  • 3.5.6: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.5.6',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.9.125-linuxkit',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Fri Sep 7 08:20:28 UTC 2018',
 'python_full_version': '3.5.6',
 'python_version': '3.5',
 'sys_platform': 'linux'}

System environment variables:

  • PYTHON_VERSION
  • TERM
  • _
  • PYTHONFINDER_IGNORE_UNSUPPORTED
  • PYTHON_PIP_VERSION
  • PIP_SHIMS_BASE_MODULE
  • PYTHONDONTWRITEBYTECODE
  • PWD
  • PIP_PYTHON_PATH
  • HOSTNAME
  • HOME
  • PIP_DISABLE_PIP_VERSION_CHECK
  • SHLVL
  • PATH
  • GPG_KEY
  • LANG

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • LANG: C.UTF-8
  • PWD: /

@hroncok
Copy link
Contributor

hroncok commented Jan 16, 2019

This is where it comes from:

pipenv/pipenv/project.py

Lines 217 to 221 in c4341a7

@property
def name(self):
if self._name is None:
self._name = self.pipfile_location.split(os.sep)[-2]
return self._name

@Marviel
Copy link

Marviel commented Feb 4, 2019

I ran into this when running in a docker container for #3504 -- had to specify a working directory via docker's -w flag to make it work (i.e. docker run -w '/root/' -it python:3 ..... Just recording the information for any strugglers in the same boat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants