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 creates empty Pipfile in some folders #3908

Closed
charlax opened this issue Aug 26, 2019 · 9 comments
Closed

pipenv creates empty Pipfile in some folders #3908

charlax opened this issue Aug 26, 2019 · 9 comments
Labels
Type: Question ❔ This is a question or a request for support.

Comments

@charlax
Copy link
Contributor

charlax commented Aug 26, 2019

Issue description

Empty Pipfile are created from time to time in some folders of my app. They always appear in the same folders, and it seems that they appear when I have opened a file in the same directory in Vim. They can appear in 9 different locations at time of writing.

Expected result

pipenv should not create those empty files.

Actual result

Example paths:

api/repo/column/Pipfile
api/lib/sqs_task/Pipfile
api/tests/factory/Pipfile

The only thing they seem to have in common is that they are 3 layers deep.

Steps to replicate

Actually, I really don't know how to replicate this and would appreciate some guidance. Since it seems to happen only when I'm working on the files, could it be related to my editing setup? I'm using:


$ pipenv --support

NOTE: I have redacted the areas I assume are irrelevant.

Pipenv version: '2018.11.26'

Pipenv location: '/Users/ca/Library/Python/3.7/lib/python/site-packages/pipenv'

Python location: '/usr/local/opt/python/bin/python3.7'

Python installations found:

  • 3.7.4: /usr/local/bin/python3
  • 3.7.4: /usr/local/bin/python3.7m
  • 2.7.16: /usr/local/bin/python
  • 2.7.16: /usr/local/bin/pythonw
  • 2.7.10: /usr/bin/python
  • 2.7.10: /usr/bin/pythonw
  • 2.7.10: /usr/bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.4',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '18.7.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT '
                     '2019; root:xnu-4903.270.47~4/RELEASE_X86_64',
 'python_full_version': '3.7.4',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • TERM_SESSION_ID
  • LC_TERMINAL_VERSION
  • COLORFGBG
  • XPC_FLAGS
  • PWD
  • SHELL
  • LC_CTYPE
  • TERM_PROGRAM_VERSION
  • TERM_PROGRAM
  • PATH
  • LC_TERMINAL
  • COLORTERM
  • TERM
  • HOME
  • TMPDIR
  • USER
  • LOGNAME
  • SHLVL
  • OLDPWD
  • ZSH
  • EDITOR
  • EDITOR_GUI
  • CODE_PATH
  • FORK_PATH
  • GOPATH
  • VIM_DOTFILES
  • PYENV_ROOT
  • MANPATH
  • DOTFILES
  • VIRTUAL_ENV_DISABLE_PROMPT
  • PROMPT
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/ca/.pyenv/bin:/usr/local/opt/gettext/bin:/usr/local/bin:/usr/local/sbin:/Users/ca/.dotfiles/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Users/ca/bin:/Users/ca/Library/Python/3.7/bin:/Users/ca/.local/bin
  • SHELL: /usr/local/bin/zsh
  • EDITOR: nvim
  • LANG: en_US.UTF-8
  • PWD: [redacted]/api

Contents of Pipfile ('[redacted]/api/Pipfile'):

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
[redacted]

[dev-packages]
[redacted]

[requires]
python_version = "3.6"

Contents of Pipfile.lock ('[redacted]/api/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "558646c3fe87a703b88b2e80732264a2e1c4b93854d79f2cd969b26f88dc180e"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.6"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.python.org/simple",
                "verify_ssl": true
            }
        ]
    },
   [redacted]
}
@ionling
Copy link
Contributor

ionling commented Aug 26, 2019

Same with Emacs pipenv.el

@frostming
Copy link
Contributor

It is likely due to some auto-execution of pipenv commands.

Pipenv looks for Pipfile up to 3 layers deep by default. And if not found, one Pipfile will be created in the current directory. The max searching depth is controlled by PIPENV_MAX_DEPTH.

@charlax
Copy link
Contributor Author

charlax commented Aug 27, 2019

Indeed, I have verified that I can reproduce the issue consistently with vim and my plugins. I just need to edit a file that is 3 subfolders deep to see an extra Pipfile created alongside it.

Why would Pipfile create an empty file though?

@frostming
Copy link
Contributor

@charlax Yes, it is the current design, Pipenv needs Pipfile to locate its project root. Does PIPENV_MAX_DEPTH work for your case?

@frostming frostming added the Type: Question ❔ This is a question or a request for support. label Aug 27, 2019
@frostming
Copy link
Contributor

Plus, I recommend filing an issue to ale or pipenv.el to see what the project author says.

@charlax
Copy link
Contributor Author

charlax commented Aug 28, 2019

Indeed, it looks like ALE executes pipenv, :ALEInfo yields:

(finished - exit code 0) ['/usr/local/bin/zsh', '-c', 'cd ''[redacted]/api/api/task'' && ''pipenv'' run flake8 --format=default --stdin-display-name ''[redacted]/api/api/task/
connection.py'' - < ''/var/folders/ss/2cch6pjs7fqf55xztqstklh40000gn/T/vBtf28V/25/connection.py'''] 

And I have let g:ale_python_auto_pipenv = 1 in my vim config.

I'll open a ticket with ALE. I guess a proper solution would be to use PIPENV_PIPFILE to specify the Pipfile path?

@ghost
Copy link

ghost commented Sep 10, 2019

Hi @frostming,

I'm interested what the Use case is for where pipenv by design will create a new Pipfile where depth exceeds PIPENV_MAX_DEPTH?

Perhaps you can have a Pipfile under a Pipfile? something like:

Project/
 Pipfile
 models.py
 tests/
    testproject1/
        tests.py
        settings.py
        Pipfile

thanks

@frostming
Copy link
Contributor

@richyfish Yes, why not?

@ghost
Copy link

ghost commented Sep 10, 2019

That's fine. I was trying to understand the design decisions behind why pipenv only searches within 3 depth. thanks.

@matteius matteius closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question ❔ This is a question or a request for support.
Projects
None yet
Development

No branches or pull requests

4 participants