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 sync fails without Pipfile present #2834

Closed
ulrikjohansson opened this issue Sep 8, 2018 · 12 comments
Closed

pipenv sync fails without Pipfile present #2834

ulrikjohansson opened this issue Sep 8, 2018 · 12 comments
Labels
good first issue Issues suitable as a newcomer to get familiar with Pipenv! help wanted

Comments

@ulrikjohansson
Copy link
Contributor

ulrikjohansson commented Sep 8, 2018

Issue description

Running pipenv sync without a Pipfile present (the Pipfile.lock is there) fails with the message

Error: Pipfile.lock is missing! You need to run $ pipenv lock first.
Expected result

I would expect the Pipfile not to be needed at all for sync since it should just install the pinned versions from the Pipfile.lock

Actual result

pipenv won't install anything because it either thinks it needs a Pipfile as well as a Pipfile.lock for some reason. It also complains about the wrong file (Pipenv.lock).

Steps to replicate
  • Create a new virtualenv, e.g with pipenv install requests
  • Remove the Pipfile (keeping only the Pipfile.lock)
  • Run pipenv sync

$ pipenv --support

Pipenv version: '2018.7.1'

Pipenv location: '/usr/local/Cellar/pipenv/2018.7.1/libexec/lib/python3.7/site-packages/pipenv'

Python location: '/usr/local/Cellar/pipenv/2018.7.1/libexec/bin/python3.7'

Other Python installations in PATH:

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.7: /usr/local/bin/python3.7m

  • 3.7: /usr/local/bin/python3.7

  • 3.7: /usr/local/bin/python3.7

  • 2.7.15: /usr/local/bin/python

  • 2.7.10: /usr/bin/python

  • 2.7.15: /usr/local/bin/python

  • 2.7.10: /usr/bin/python

  • 2.7.15: /usr/local/bin/python2

  • 2.7.15: /usr/local/bin/python2

  • 3.7.0: /usr/local/bin/python3

  • 3.7.0: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.5.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT '
                     '2018; root:xnu-4570.51.2~1/RELEASE_X86_64',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • PATH
  • TERM_PROGRAM
  • SHELL
  • TERM
  • TMPDIR
  • PIPENV_VENV_IN_PROJECT
  • Apple_PubSub_Socket_Render
  • TERM_PROGRAM_VERSION
  • TERM_SESSION_ID
  • LC_ALL
  • USER
  • SSH_AUTH_SOCK
  • __CF_USER_TEXT_ENCODING
  • LSCOLORS
  • _
  • PWD
  • LANG
  • ITERM_PROFILE
  • XPC_FLAGS
  • XPC_SERVICE_NAME
  • COLORFGBG
  • HOME
  • SHLVL
  • ITERM_SESSION_ID
  • LOGNAME
  • LC_CTYPE
  • GOPATH
  • DISPLAY
  • COLORTERM
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: 1

Debug–specific environment variables:

  • PATH: /usr/local/Cellar/pipenv/2018.7.1/libexec/tools:/Users/ulrjoh2/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/opt/go/libexec/bin:/Users/ulrjoh2/work/bin:/Users/ulrjoh2/.local/bin:/Users/ulrjoh2/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/opt/go/libexec/bin:/Users/ulrjoh2/work/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /tmp/test

@ulrikjohansson
Copy link
Contributor Author

From a quick look at the source, it seems that the reason for this behaviour is that pipenv figures out where Pipfile.lock is by first searching for Pipfile. When it can't find a Pipfile, it gives up and throws the error message about the missing lock file.

@techalchemy
Copy link
Member

Thanks for the debugging legwork here, we should do some cleanup with regard to the project construct

@ulrikjohansson
Copy link
Contributor Author

ulrikjohansson commented Sep 9, 2018

There is another possibly related weirdness here. When doing pipenv install --ignore-pipfile, it actually totally ignores the Pipfile for install purposes, and uses the lockfile to install dependencies, but if there is no Pipfile, pipenv will happily create a new empty Pipfile. Intuitively I would have thought --ignore-pipfile would completely ignore it, not create a new one (which is out of sync with the lockfile)

@uranusjr
Copy link
Member

uranusjr commented Sep 9, 2018

Honestly I am not sure install --ignore-pipfile should do after #1463 is fully implemented. There really should be a full-on review on various install commands and options. But from my understanding the original purpose of --ignore-pipfile is actually to ignore the process of checking whether lock is up-to-date to Pipfile, not Pipfile entirely (and no, it’s not named very intuitively), so it shouldn’t accept a missing Pipfile. The best behaviour is probably to error without one.

Review of the install command is far more involved than fixing the sync command. I would recommend creating a PEEP to fully discuss it. This thread would focus on fixing the sync command. The fix is not very difficult IMO, so I’ll slap a good first issue tag on it. Contribution are welcomed!

@uranusjr uranusjr added help wanted good first issue Issues suitable as a newcomer to get familiar with Pipenv! labels Sep 9, 2018
@ulrikjohansson
Copy link
Contributor Author

I just found #1977 which seems to also mention this exact behaviour, see comment #1977 (comment)
Should this be closed as a duplicate of that?

@ulrikjohansson
Copy link
Contributor Author

@uranusjr I'm not sure what the fix would be here, is it to stop looking for the Pipfile for the sync command, or is it to just make the error message more clear in the case of the missing Pipfile?

@uranusjr
Copy link
Member

I would say sync should stop looking for Pipfile.

@ulrikjohansson
Copy link
Contributor Author

I've tinkered a little with just copying the find() code from the patched pipfile module and using that for finding the lock-file in pipenv/project.py, and that seems to solve the problem of not finding the lockfile, but since do_sync() runs ensure_project(), an empty Pipfile is always created when running the sync command.
Getting rid of all the uses of Pipfile in all the functions called by do_sync() quickly grew to a much larger project, so I'm not sure that should be included in a fix for this issue. Perhaps that should go with solving #41 that you mentioned above.
Is it reasonable to post a PR just fixing the lockfile find problem? In that case I'll try and get one ready within the next day or two.

@dudil
Copy link

dudil commented Sep 29, 2020

Hi - Is that still open? I'll be happy to assist with that if help is still required

@uranusjr
Copy link
Member

This is open.

@ulrikjohansson
Copy link
Contributor Author

ulrikjohansson commented Nov 14, 2020

It looks like this issue is at least partly solved by #3386,
I no longer get an error about a missing Pipfile or lockfile when I do a pipenv sync with only the Pipfile.lock present.

There is still weirdness remaining tough, like the pipenv sync creates a new empty Pipfile just like when running pipenv install --ignore-pipfile , that I described in a comment further up: #2834 (comment)
So these two commands seem to behave the same way now.

The subject of this issue only mentions the sync failing, which is no longer the case. Should this issue be closed?

@frostming
Copy link
Contributor

Sure thing, thank you for following up

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! help wanted
Projects
None yet
Development

No branches or pull requests

5 participants