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 does not find pipfile in upper directory #1634

Closed
mattvend opened this Issue Mar 9, 2018 · 9 comments

Comments

Projects
None yet
4 participants
@mattvend
Copy link

mattvend commented Mar 9, 2018

Pipenv virtualenv created for a project, at the top of my project are a pipfile and pipfile.lock files.
When executing pipenv commands in sub directory (3 levels below), a new virtual env gets created.

I thought it would not be the case and pipenv would use the one at the top

Describe your environment
  1. OS Type: Windows 10
  2. Python version: $ python -V Python 3.6.1 :: Anaconda 4.4.0 (64-bit)
  3. Pipenv version: $ pipenv --version pipenv, version 11.1.6
Expected result

I expect no new environment to be created

Actual result

Passing the option --verbose to pipenv does not work

Steps to replicate
  • created a virtualenv with pipenv, and a pipfile
  • create some subdirs
  • in the subdir, execute pipenv --shell
    It creates a new env instead of using the one at the top.
    Please note that sometimes it works, sometimes not.

Top Pipfile
[[source]]

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

[packages]

"pyqt5" = ""
pyedflib = "
"
psutil = "*"

[dev-packages]

[requires]

python_version = "3.6"

@mattvend mattvend changed the title Pipenv does not pipfile in upper directory Pipenv does not find pipfile in upper directory Mar 9, 2018

@kennethreitz

This comment has been minimized.

Copy link
Contributor

kennethreitz commented Mar 9, 2018

We only check 2 or 3 levels above. This is configurable by setting the PIPENV_MAX_DEPTH environment variable.

@mattvend

This comment has been minimized.

Copy link

mattvend commented Mar 9, 2018

How can I pass it to pipenv then ?

@mattvend

This comment has been minimized.

Copy link

mattvend commented Mar 9, 2018

Ok, I defined the variable ang finally got pipenv finding the venv.

Nevertheless, while in my sub dir, while typing pipenv shell, the shell started correctly but 3 level above, next to the venv, not in the current directory. It is a bit annoying.

I cd back to my script, then tried to run it. The script complained about not being able to import packages as absolute import. It looks like something is not functioning correctly regarding absolute and relative paths in this situation.

@techalchemy

This comment has been minimized.

Copy link
Member

techalchemy commented Mar 9, 2018

set PIPENV_MAX_DEPTH=5 or whatever.

@techalchemy

This comment has been minimized.

Copy link
Member

techalchemy commented Mar 9, 2018

Pipenv will always drop you at your project root when you launch a subshell. As for absolute imports, you’ll want to consult the python docs on why you’re getting that error

@mattvend

This comment has been minimized.

Copy link

mattvend commented Mar 9, 2018

Thanks ! I already figured out the env variable.

Out of curiosity, PIPENV_MAX_DEPTH=2 or 3 by default, why such a low number by default ? what is the reasoning ?

Nevertheless, I would prefer that pipenv, by design, while in a shell and typing pipenv shell leaves you at your current location.

For the wrong absolute imports, this is probably something else.

@kennethreitz

This comment has been minimized.

Copy link
Contributor

kennethreitz commented Mar 9, 2018

you're the first person who's raised any concern over the default so far, so i think we've picked a good sane default :)

@kennethreitz

This comment has been minimized.

Copy link
Contributor

kennethreitz commented Mar 9, 2018

I'll see about adding an env var to not chdir when invoking shell

@rrthomas

This comment has been minimized.

Copy link

rrthomas commented Aug 31, 2018

That would be good; I've just run into this. It's nice to be able to use pipenv run without pipenv run sh -c "cd foo && actual-cmd"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment