# languages: Fix \`poetry\` environment discovery on Linux \(\#47100\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/5751aeb4a36d693ff4154fbcd1e95fc9cf049f6e)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 5751aeb4a36d693ff4154fbcd1e95fc9cf049f6e

Requested commit: 5751aeb4a36d693ff4154fbcd1e95fc9cf049f6e

Commit: 5751aeb4a36d693ff4154fbcd1e95fc9cf049f6e

Tree: 8ba276edc293e3b195cb5e327b26e4445a419641

Author: Xin Zhao

Committer: GitHub

## Message

```
languages: Fix `poetry` environment discovery on Linux (#47100)

Closes #47098 

The root cause of this issue is related to how `Poetry` (and the
upstream `pet-poetry` library) handles path hashing. While perhaps it's
an upstream behavior, we can easily fix it on the Zed side.

The related code are

https://github.com/zed-industries/zed/blob/7ce845210d3af82a57a7518e0abe8c167d60cc6a/crates/languages/src/python.rs#L1181-L1211

In my debugging, I found that `worktree_root` takes the form
`/home/user/project`, but `config.workspace_directories` often ends up
as `/home/user/project/`(with a trailing slash). Normally this wouldn't
be an issue, but `Poetry` generates environment names based on the hash
of the absolute path. Since the hashes for `/home/user/project` and
`/home/user/project/` are different, `pet-poetry` fails to find the
environment.

The fix is straightforward: we just need to ensure the trailing `/` is
removed so the hashes match.

Release Notes:

- Fixed poetry environment not discovered on linux
```

## Parents

- [ed29b4678388a8ebfc0e764dd32ed2ac206c987f](https://git.cafe/gitcafe/zed/commit/ed29b4678388a8ebfc0e764dd32ed2ac206c987f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/5751aeb4a36d693ff4154fbcd1e95fc9cf049f6e?format=markdown)
