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

Pipenv install does not provide a good error message for no Pipfile. #2846

Closed
fossum opened this issue Sep 12, 2018 · 10 comments
Closed

Pipenv install does not provide a good error message for no Pipfile. #2846

fossum opened this issue Sep 12, 2018 · 10 comments
Labels
good first issue Issues suitable as a newcomer to get familiar with Pipenv! Type: Enhancement 💡 This is a feature or enhancement request.

Comments

@fossum
Copy link

fossum commented Sep 12, 2018

Issue description

When attempting to run pipenv install --dev in the wrong spot I got this error below (not a bug I assume).

~ # pipenv install --dev
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.4/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/usr/local/lib/python3.4/site-packages/pipenv/core.py", line 1759, in do_install
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.4/site-packages/pipenv/core.py", line 639, in ensure_project
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system)
  File "/usr/local/lib/python3.4/site-packages/pipenv/core.py", line 288, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/usr/local/lib/python3.4/site-packages/pipenv/project.py", line 576, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/usr/local/lib/python3.4/site-packages/pipenv/patched/notpip/_internal/baseparser.py", line 141, in __init__
    assert self.name
AssertionError
~ #
Expected result

I would expect something about missing a Pipfile or some such. Probaly something along these lines.

AssertionError("Could not find Pipfile.")
Actual result

Instead I just got AssertionError().

Steps to replicate
mkdir foo
cd foo
pipenv install --dev

$ pipenv --support

Pipenv version: '2018.7.1'

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

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

Other Python installations in PATH:

  • 3.4: /usr/local/bin/python3.4m

  • 3.4: /usr/local/bin/python3.4

  • 3.4: /usr/local/bin/python3.4

  • 3.4.9: /usr/local/bin/python

  • 3.4.9: /usr/local/bin/python

  • 3.4.9: /usr/local/bin/python3

  • 3.4.9: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.4.9',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.15.0-33-generic',
 'platform_system': 'Linux',
 'platform_version': '#36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018',
 'python_full_version': '3.4.9',
 'python_version': '3.4',
 'sys_platform': 'linux'}

System environment variables:

  • PYTHONDONTWRITEBYTECODE
  • https_proxy
  • http_proxy
  • HOME
  • HTTPS_PROXY
  • LANG
  • PWD
  • no_proxy
  • PATH
  • HOSTNAME
  • PIP_PYTHON_PATH
  • OLDPWD
  • NO_PROXY
  • GPG_KEY
  • HTTP_PROXY
  • TERM
  • PYTHON_PIP_VERSION
  • SHLVL
  • PYTHON_VERSION

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: /

Contents of Pipfile ('/Pipfile'):

@uranusjr
Copy link
Member

Contributions are welcomed. Just change the line in the traceback.

@uranusjr uranusjr added Type: Enhancement 💡 This is a feature or enhancement request. good first issue Issues suitable as a newcomer to get familiar with Pipenv! labels Sep 13, 2018
@decentral1se
Copy link

Oh yeah, just got bitten by this. Will attempt a fix!

@fossum
Copy link
Author

fossum commented Sep 19, 2018

I see the referenced PR #2853 isn't merged yet, but is the issue fixed already? Here is master:latest(19cc731)

➜  pipenv git:(master) ✗ mkdir ../pip-test
➜  pipenv git:(master) ✗ cd ../pip-test
➜  pip-test pipenv install --dev
Creating a virtualenv for this project…
Pipfile: /home/ericfoss/Development/pip-test/Pipfile
Using /usr/bin/python3 (3.6.5) to create virtualenv…
⠸Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/ericfoss/.local/share/virtualenvs/pip-test-1fL-zKVG/bin/python3
Also creating executable in /home/ericfoss/.local/share/virtualenvs/pip-test-1fL-zKVG/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/ericfoss/.local/share/virtualenvs/pip-test-1fL-zKVG
Creating a Pipfile for this project…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (ca72e7)!
Installing dependencies from Pipfile.lock (ca72e7)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
➜  pip-test

@jr7square
Copy link

I'll pick this up since the previous PR isn't merged.

@jr7square
Copy link

uh actually....yeah I don't see this issue is latest version as well, or at least I can't manage to replicate the error.

@techalchemy
Copy link
Member

ah this is merged now, thanks for reporting

@frostming
Copy link
Contributor

When reviewing this issue. I found that the fix was not suitable because it didn't catch the real devil in the shadow. What is worse is that it introduced an API change which however didn't include a PEEP nor a changelog entry.

pipenv install is designed to create the Pipfile if it isn't present, but people are surprised by the error thrown #3260 now.

Looking at the stacktrace of this issue, the error occurs when pipenv attempts to create a Pipfile. The file was desired to be created successfully but something went wrong.

I will spend some time revisiting the errored codes and prepare a revert to this change.

@techalchemy
Copy link
Member

@frostming-- don't "revert" the change, as in the git operation, simply fix the conditional logic

Also, don't hold your PR back for a full review, fix the known issue so we can move ahead. The specific behavior change is annoying, but is only going to affect manual installation processes and can be corrected or worked around by simply installing a package.

The error message is detailed, the change is minor, all that needs to happen is a minor adjustment in logic. It is not an intentional API change, it is a conditional logic issue.

@techalchemy
Copy link
Member

Hm note that there actually is no problem with the exception logic and it is accurately raising an exception about a missing pipfile, which just failed to generate due to a completely separate issue. So the error occurs downstream of the creation, and is completely unrelated to and separate from it.

@andb0t
Copy link

andb0t commented Sep 3, 2019

Any update on this? I'm encountering the same error when installing pipenv in a fresh alpine dockerfile:

FROM alpine:latest

# install python3 and pipenv
RUN apk add --no-cache --virtual .build-deps g++ python3-dev libffi-dev openssl-dev \
    && apk add --no-cache --update python3 \
    && pip3 install --upgrade pip setuptools pipenv

Running this causes the error:

docker build -t pipenv-test .
docker run -it pipenv-test sh
pipenv shell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues suitable as a newcomer to get familiar with Pipenv! Type: Enhancement 💡 This is a feature or enhancement request.
Projects
None yet
Development

No branches or pull requests

7 participants