From 8ae14a698340163a07b4ac15200f50c8bece98ef Mon Sep 17 00:00:00 2001 From: langaaegeskov Date: Sat, 5 Aug 2023 20:25:14 -0400 Subject: [PATCH] Address Issue #5129 Document how to rename (move) project directory - Added documentation in installation.md under 'Virtualenv' mapping caveat - Added documentation to the virtualenv.md --- docs/installation.md | 1 + docs/virtualenv.md | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index a35b557f65..e6fcec589a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -161,5 +161,6 @@ that ensures all commands have access to your installed packages with `$ pipenv - Pipenv automatically maps projects to their specific virtualenvs. - By default, the virtualenv is stored globally with the name of the project’s root directory plus the hash of the full path to the project's root (e.g., `my_project-a3de50`). - Should you change your project's path, you break such a default mapping and pipenv will no longer be able to find and to use the project's virtualenv. +- If you must move or rename a directory managed by pipenv, run 'pipenv --rm' before renaming or moving your project directory. Then, after renaming or moving the directory run 'pipenv install' to recreate the virtualenv. - Customize this behavior with `PIPENV_CUSTOM_VENV_NAME` environment variable. - You might also prefer to set `PIPENV_VENV_IN_PROJECT=1` in your .env or .bashrc/.zshrc (or other shell configuration file) for creating the virtualenv inside your project's directory. diff --git a/docs/virtualenv.md b/docs/virtualenv.md index 10fb867d8c..30c297f6d5 100644 --- a/docs/virtualenv.md +++ b/docs/virtualenv.md @@ -21,3 +21,10 @@ is unique. Pipenv supports a arbitrary custom name for the virtual environment set at `PIPENV_CUSTOM_VENV_NAME`. The logical place to specify this would be in a user's `.env` file in the root of the project, which gets loaded by pipenv when it is invoked. + +## Renaming or Moving a project folder managed by pipenv +By default pipenv creates a virtualenv for your project and gives it a name. The default name is how pipenv maps the individual project to the correct virtualenv. Pipenv names the virtualenv with the name of the project’s root directory plus the hash of the full path to the project's root (e.g., `my_project-a3de50`). + +If you rename or move the project folder this will change the project path. Then, pipenv will no longer be able to find your virtualenv and it will make a new virtualenv. This leaves you with the old virtualenv still lying around on you system. Luckily the fix is simple. +- Run 'pipenv --rm' *before* renaming or moving your project directory +- Then, after renaming or moving the directory run 'pipenv install' to recreate the virtualenv \ No newline at end of file