Repository: python-poetry/poetry

Issue:
poetry env list, can not output env path
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [ ] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [ ] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [ ] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: <!-- Replace with version + name -->
- **Poetry version**: <!-- Replace with version -->
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here -->

## poetry env list, can not output env path
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->

comand `poetry env list --full-path` output nothing on windows dos shell.
```
E:\FNTools>poetry env list --full-path

E:\FNTools>
```
but it works ok on bash shell, for example git bash shell.
```
lei@DESKTOP-AM65SOJ /E/FNTools (master)
$ poetry env list --full-path
C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs\fntools-gSpOuuiR-py3.6 (Activated)
```


Discussion:
Hello @leileigong,

which version of poetry are you using and which windows OS do you use?

I've tried with poetry 1.0.5 under windows 10 within cmd and powershell and both show me the full  path of the venv.

fin swimmer
Hello @finswimmer,
I also use poetry 1.0.5 , on windows 10.
I tried "cmd.exe" and powershell programs , these two shells got the same problem.

cmd.exe:
```sh
E:\FNTools>poetry config --list
cache-dir = "C:\\Users\\lei\\AppData\\Local\\pypoetry\\Cache"
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs

E:\FNTools>
```

powershell:
```sh
PS E:\FNTools> poetry config --list
cache-dir = "C:\\Users\\lei\\AppData\\Local\\pypoetry\\Cache"
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs
PS E:\FNTools>
```

Hm, strange.

How is python installed on your system? How have you installed poetry?
python is installed via binary executable file.

i install poetry as follow comand in powershell:
```sh
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
```
@finswimmer I find the problem, i do not sure it's a bug or not.

I create an virtual environment for my project via git bash shell.
My project directory is  `/E/FNTools` which is displayed on bash shell, 
and   `E:\FNTools` which is displayed on windows command shell.

so on bash shell,  i get an interpreter **fntools-gSpOuuiR-py3.6**:
```sh
lei@DESKTOP-AM65SOJ /E/FNTools (master)
$ poetry env list
fntools-gSpOuuiR-py3.6 (Activated)

lei@DESKTOP-AM65SOJ /E/FNTools (master)
$ poetry env list --full-path
C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs\fntools-gSpOuuiR-py3.6 (Activated)
```

but, when i can not see the env on windows command shell.
I get nothing.
```sh
E:\FNTools>poetry env list

E:\FNTools>
```

then I try command `poetry install`. poetry create another interpreter **fntools--CZiHDaJ-py3.6** for the again.
```sh

E:\FNTools>poetry env list

E:\FNTools>poetry install
Creating virtualenv fntools--CZiHDaJ-py3.6 in C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs
Installing dependencies from lock file


Package operations: 37 installs, 0 updates, 0 removals
.......

E:\FNTools>poetry env list
fntools--CZiHDaJ-py3.6 (Activated)

E:\FNTools>poetry env list --full-path
C:\Users\lei\AppData\Local\pypoetry\Cache\virtualenvs\fntools--CZiHDaJ-py3.6 (Activated)
```

But pipenv do not apper this problem on different command shell.
- windows cmd.exe shell
```sh
E:\FNTools>pipenv --venv
C:\Users\lei\.virtualenvs\FNTools-lKp0_7xw
E:\FNTools>
```
- unix bash shell:
```sh
lei@DESKTOP-AM65SOJ /E/FNTools (master)
$ pipenv --venv
c:\Users\lei\.virtualenvs\FNTools-lKp0_7xw
```

Maybe pipenv does better at this pointer.

thanks.


I also encountered this issue. `<Exec Command="poetry install"/>` in MsBuild was working as expected since `Exec` uses a `cmd.exe` subshell. However, using `execute_process(COMMAND poetry install)` with CMake created a virtual environment which was not visible from the Command Line Interface. As a workaround, since `cmd.exe` is hard to use directly with `execute_process` and a custom command, I had to `file(WRITE "${PROJECT_BINARY_DIR}/poetry.cmd" "${Poetry_EXECUTABLE} %*")` and use `poetry.cmd` instead than poetry. :disappointed: 
I have the same issue but in my case, it is opposite to what OP has. There's no output for `poetry env list` on Git Bash but it works fine in CMD.

~I don't know if it might be related but yesterday I had encountered issue #2681 while trying to update poetry. I ended up having to reinstall poetry via the recommended curl command on Git Bash. The `poetry env list` command was working just fine. Now, today after turning on the computer, I suddenly have this issue. I'm trying to investigate what might be the issue cause I didn't change any configurations yesterday.~ **UPDATE:** This was not related
I have figured it out. In my case it was because I was accessing the folder with a different case. Git Bash is case insensitive such that a folder named: `PROJECTS`, can be accessed with either `cd projects` or `cd PROJECTS`. The problem arises when you access one of the folders in the path with a different case from its actual one. 

Here's a photo to illustrate this:
![{489BB381-A5BF-4611-BFBA-E43DC53CDE0D} png](https://user-images.githubusercontent.com/10741084/99902388-84554d00-2cce-11eb-9d51-7aaedd91714f.jpg)

Probably related to #2419. Thus, may be fixed by #2421 (which has not yet been merged).

Resolving patch:
diff --git a/src/poetry/utils/env.py b/src/poetry/utils/env.py
--- a/src/poetry/utils/env.py
+++ b/src/poetry/utils/env.py
@@ -1072,7 +1072,8 @@ def get_base_prefix(cls) -> Path:
     def generate_env_name(cls, name: str, cwd: str) -> str:
         name = name.lower()
         sanitized_name = re.sub(r'[ $`!*@"\\\r\n\t]', "_", name)[:42]
-        h = hashlib.sha256(encode(cwd)).digest()
+        normalized_cwd = os.path.normcase(cwd)
+        h = hashlib.sha256(encode(normalized_cwd)).digest()
         h = base64.urlsafe_b64encode(h).decode()[:8]
 
         return f"{sanitized_name}-{h}"


Test patch:
diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py
--- a/tests/utils/test_env.py
+++ b/tests/utils/test_env.py
@@ -1120,3 +1120,12 @@ def test_create_venv_accepts_fallback_version_w_nonzero_patchlevel(
         with_setuptools=True,
         with_wheel=True,
     )
+
+
+def test_generate_env_name_ignores_case_for_case_insensitive_fs(tmp_dir):
+    venv_name1 = EnvManager.generate_env_name("simple-project", "MyDiR")
+    venv_name2 = EnvManager.generate_env_name("simple-project", "mYdIr")
+    if sys.platform == "win32":
+        assert venv_name1 == venv_name2
+    else:
+        assert venv_name1 != venv_name2