pivoshenko / poetry-plugin-dotenv

poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run
MIT License
74 stars 4 forks source link

Failure when trying to install #180

Closed arnaudgelas closed 7 months ago

arnaudgelas commented 7 months ago

System (please complete the following information):

When trying to install, I get the following error:

$ poetry self add poetry-plugin-dotenv
Using version ^0.6.4 for poetry-plugin-dotenv

Updating dependencies
Resolving dependencies... (2.6s)

Package operations: 3 installs, 41 updates, 0 removals

  • Installing pycparser (2.21): Failed

  PermissionError

  [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/pycparser'

  at /usr/lib/python3.10/pathlib.py:1175 in mkdir
      1171│         """
      1172│         Create a new directory at this given path.
      1173│         """
      1174│         try:
    → 1175│             self._accessor.mkdir(self, mode)
      1176│         except FileNotFoundError:
      1177│             if not parents or self.parent == self:
      1178│                 raise
      1179│             self.parent.mkdir(parents=True, exist_ok=True)
pivoshenko commented 7 months ago

Hi, @arnaudgelas 👋🏻 Thanks for submitting the issue. Are you able to install any other plugins/dependencies (e.g. poetry-plugin-up)? Because poetry-plugin-dotenv has no dependencies apart from poetry. So most likely error relates to poetry itself

e.g. I found this https://forum.garudalinux.org/t/poetry-fails-with-permission-denied-pip/17466

arnaudgelas commented 7 months ago

Hi @volopivoshenko I have just tried installing poetry-plugin-up and I have not encountered any issues...

$ poetry self add poetry-plugin-up
Using version ^0.7.1 for poetry-plugin-up

Updating dependencies
Resolving dependencies... (8.7s)

Package operations: 1 install, 3 updates, 0 removals

  • Updating certifi (2023.11.17 -> 2024.2.2)
  • Updating urllib3 (2.1.0 -> 2.2.0)
  • Updating trove-classifiers (2024.1.8 -> 2024.1.31)
  • Installing poetry-plugin-up (0.7.1)

Writing lock file
arnaudgelas commented 7 months ago

Hey @volopivoshenko, If I do the following, it seems to work

cd $my_project
poetry install
poetry shell
poetry self poetry-plugin-dotenv

Is it the way it is intended to be installed?

pivoshenko commented 7 months ago

[poetry-plugin-dotenv] Закрити issue

pivoshenko commented 7 months ago

@arnaudgelas hi! yes, it's another way of installing it (will add it to README)!

poetry install
poetry shell
poetry self add poetry-plugin-dotenv
# poetry self add poetry-plugin-dotenv@latest

I just double check it, and it works 🙂

pivoshenko commented 7 months ago

Let me know if you have any other issues, otherwise I will close this ticket 🙂

arnaudgelas commented 7 months ago

Although it seems to be added

$ poetry self add poetry-plugin-dotenv
The following packages are already present in the pyproject.toml and will be skipped:

  • poetry-plugin-dotenv

If you want to update it to the latest compatible version, you can use `poetry self update`.
If you prefer to upgrade it to the latest available version, you can use `poetry self add package@latest`.

Nothing to add.

I can't see any reference of it in pyproject.toml nor in poetry.lock AND environment variables are not loaded (with or without using POETRY_DOTENV_LOCATION)

pivoshenko commented 7 months ago

Regarding references in poetry.lock and pyproject.toml it's fine, poetry plugins are stored not in the same way as standard project dependencies. Weird, I just ran it on my machine and it works perfectly (hah like a meme). Can you please try to run next?

  1. Create sample project:
    
    mkdir sandbox
    cd sandbox

touch .env touch pyproject.toml touch main.py


2. Edit files:

.env content

TEST_ENV_VAR="hello world!"


```toml
# pyproject content
[tool.poetry]
name = "sandbox"
version = "0.1.0"
description = ""
authors = ["STUB"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# main.py content
import os

print(os.environ["TEST_ENV_VAR"])
  1. Run commands:
    poetry install
    poetry shell
    poetry run -vvv python main.py

jic my output:

Using virtualenv: /Users/volodymyr.pivoshenko/Library/Caches/pypoetry/virtualenvs/sandbox-Sno8Evn0-py3.10
Loading environment variables from '/Users/volodymyr.pivoshenko/Development/personal/sandbox/.env'.
hello world!
arnaudgelas commented 7 months ago

Here is what I get

05:49:11 arnaud@gorilla sandbox → poetry install
Installing dependencies from lock file
05:49:41 arnaud@gorilla sandbox → poetry shell
Spawning shell within /home/arnaud/dev/sandbox/.venv
. /home/arnaud/dev/sandbox/.venv/bin/activate
05:49:47 arnaud@gorilla sandbox → . /home/arnaud/dev/sandbox/.venv/bin/activate
05:49:47 (.venv) arnaud@gorilla sandbox → poetry run -vvv python main.py 
Loading configuration file /home/arnaud/.config/pypoetry/config.toml
Using virtualenv: /home/arnaud/dev/sandbox/.venv
Traceback (most recent call last):
  File "/home/arnaud/dev/sandbox/main.py", line 5, in <module>
    print(os.environ["TEST_ENV_VAR"])
  File "/usr/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'TEST_ENV_VAR'
05:49:51 (.venv) arnaud@gorilla sandbox → cat .env
TEST_ENV_VAR="hello world!"
pivoshenko commented 7 months ago

hmm very weird, can you please run within sandbox:

poetry shell
poetry self show plugins
arnaudgelas commented 7 months ago
05:51:43 (.venv) arnaud@gorilla sandbox → poetry self show plugins

  • poetry-plugin-export (1.5.0) Poetry plugin to export the dependencies to various formats
      1 application plugin

      Dependencies
        - poetry (>=1.5.0,<2.0.0)
        - poetry-core (>=1.6.0,<2.0.0)
arnaudgelas commented 7 months ago
06:56:57 (.venv) arnaud@gorilla sandbox → poetry self show --addons
build                1.0.3     A simple, correct Python build frontend
cachecontrol         0.13.1    httplib2 caching for requests
certifi              2024.2.2  Python package for providing Mozilla's CA Bundle.
cffi                 1.16.0    Foreign Function Interface for Python calling C code.
charset-normalizer   3.3.2     The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet.
cleo                 2.1.0     Cleo allows you to create beautiful and testable command-line interfaces.
crashtest            0.4.1     Manage Python errors with ease
cryptography         42.0.2    cryptography is a package which provides cryptographic recipes and primitives to Python developers.
distlib              0.3.8     Distribution utilities
dulwich              0.21.7    Python Git Library
fastjsonschema       2.19.1    Fastest Python implementation of JSON schema
filelock             3.13.1    A platform independent file lock.
idna                 3.6       Internationalized Domain Names in Applications (IDNA)
importlib-metadata   7.0.1     Read metadata from Python packages
installer            0.7.0     A library for installing Python wheels.
jaraco-classes       3.3.0     Utility functions for Python class constructs
jeepney              0.8.0     Low-level, pure Python DBus protocol wrapper.
keyring              24.3.0    Store and access your passwords safely.
more-itertools       10.2.0    More routines for operating on iterables, beyond itertools
msgpack              1.0.7     MessagePack serializer
packaging            23.2      Core utilities for Python packages
pexpect              4.9.0     Pexpect allows easy control of interactive console applications.
pkginfo              1.9.6     Query metadata from sdists / bdists / installed packages.
platformdirs         3.11.0    A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir".
poetry               1.7.1     Python dependency management and packaging made easy.
poetry-core          1.8.1     Poetry PEP 517 Build Backend
poetry-plugin-dotenv 0.6.5     poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run.
poetry-plugin-export 1.6.0     Poetry plugin to export the dependencies to various formats
ptyprocess           0.7.0     Run a subprocess in a pseudo terminal
pycparser            2.21      C parser in Python
pyproject-hooks      1.0.0     Wrappers to call pyproject.toml-based build backend hooks.
rapidfuzz            3.6.1     rapid fuzzy string matching
requests             2.31.0    Python HTTP for Humans.
requests-toolbelt    1.0.0     A utility belt for advanced users of python-requests
secretstorage        3.3.3     Python bindings to FreeDesktop.org Secret Service API
shellingham          1.5.4     Tool to Detect Surrounding Shell
tomli                2.0.1     A lil' TOML parser
tomlkit              0.12.3    Style preserving TOML library
trove-classifiers    2024.1.31 Canonical source for classifiers on PyPI (pypi.org).
urllib3              2.2.0     HTTP library with thread-safe connection pooling, file post, and more.
virtualenv           20.25.0   Virtual Python Environment builder
zipp                 3.17.0    Backport of pathlib-compatible object wrapper for zip files
arnaudgelas commented 7 months ago
06:58:12 (.venv) arnaud@gorilla sandbox → poetry self show -t
poetry 1.7.1 Python dependency management and packaging made easy.
├── build >=1.0.3,<2.0.0
│   ├── colorama * 
│   ├── packaging >=19.0 
│   ├── pyproject-hooks * 
│   │   └── tomli >=1.1.0 
│   └── tomli >=1.1.0 (circular dependency aborted here)
├── cachecontrol >=0.13.0,<0.14.0
│   ├── filelock >=3.8.0 
│   ├── msgpack >=0.5.2 
│   └── requests >=2.16.0 
│       ├── certifi >=2017.4.17 
│       ├── charset-normalizer >=2,<4 
│       ├── idna >=2.5,<4 
│       └── urllib3 >=1.21.1,<3 
├── cleo >=2.1.0,<3.0.0
│   ├── crashtest >=0.4.1,<0.5.0 
│   └── rapidfuzz >=3.0.0,<4.0.0 
├── crashtest >=0.4.1,<0.5.0
├── dulwich >=0.21.2,<0.22.0
│   └── urllib3 >=1.25 
├── fastjsonschema >=2.18.0,<3.0.0
├── installer >=0.7.0,<0.8.0
├── keyring >=24.0.0,<25.0.0
│   ├── importlib-metadata >=4.11.4 
│   │   └── zipp >=0.5 
│   ├── jaraco-classes * 
│   │   └── more-itertools * 
│   ├── jeepney >=0.4.2 
│   ├── pywin32-ctypes >=0.2.0 
│   └── secretstorage >=3.2 
│       ├── cryptography >=2.0 
│       │   └── cffi >=1.12 
│       │       └── pycparser * 
│       └── jeepney >=0.6 (circular dependency aborted here)
├── packaging >=20.5
├── pexpect >=4.7.0,<5.0.0
│   └── ptyprocess >=0.5 
├── pkginfo >=1.9.4,<2.0.0
├── platformdirs >=3.0.0,<4.0.0
├── poetry-core 1.8.1
├── poetry-plugin-export >=1.6.0,<2.0.0
│   ├── poetry >=1.6.0,<2.0.0 (circular dependency aborted here)
│   └── poetry-core >=1.7.0,<2.0.0 
├── pyproject-hooks >=1.0.0,<2.0.0
│   └── tomli >=1.1.0 
├── requests >=2.26,<3.0
│   ├── certifi >=2017.4.17 
│   ├── charset-normalizer >=2,<4 
│   ├── idna >=2.5,<4 
│   └── urllib3 >=1.21.1,<3 
├── requests-toolbelt >=0.9.1,<2
│   └── requests >=2.0.1,<3.0.0 
│       ├── certifi >=2017.4.17 
│       ├── charset-normalizer >=2,<4 
│       ├── idna >=2.5,<4 
│       └── urllib3 >=1.21.1,<3 
├── shellingham >=1.5,<2.0
├── tomli >=2.0.1,<3.0.0
├── tomlkit >=0.11.4,<1.0.0
├── trove-classifiers >=2022.5.19
├── virtualenv >=20.23.0,<21.0.0
│   ├── distlib >=0.3.7,<1 
│   ├── filelock >=3.12.2,<4 
│   └── platformdirs >=3.9.1,<5 
└── xattr >=0.10.0,<0.11.0
    └── cffi >=1.0 
        └── pycparser * 
poetry-plugin-dotenv 0.6.5 poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run.
└── poetry >=1.5.1,<2.0.0
    ├── build >=1.0.3,<2.0.0 
    │   ├── colorama * 
    │   ├── packaging >=19.0 
    │   ├── pyproject-hooks * 
    │   │   └── tomli >=1.1.0 
    │   └── tomli >=1.1.0 (circular dependency aborted here)
    ├── cachecontrol >=0.13.0,<0.14.0 
    │   ├── filelock >=3.8.0 
    │   ├── msgpack >=0.5.2 
    │   └── requests >=2.16.0 
    │       ├── certifi >=2017.4.17 
    │       ├── charset-normalizer >=2,<4 
    │       ├── idna >=2.5,<4 
    │       └── urllib3 >=1.21.1,<3 
    ├── cleo >=2.1.0,<3.0.0 
    │   ├── crashtest >=0.4.1,<0.5.0 
    │   └── rapidfuzz >=3.0.0,<4.0.0 
    ├── crashtest >=0.4.1,<0.5.0 (circular dependency aborted here)
    ├── dulwich >=0.21.2,<0.22.0 
    │   └── urllib3 >=1.25 (circular dependency aborted here)
    ├── fastjsonschema >=2.18.0,<3.0.0 
    ├── installer >=0.7.0,<0.8.0 
    ├── keyring >=24.0.0,<25.0.0 
    │   ├── importlib-metadata >=4.11.4 
    │   │   └── zipp >=0.5 
    │   ├── jaraco-classes * 
    │   │   └── more-itertools * 
    │   ├── jeepney >=0.4.2 
    │   ├── pywin32-ctypes >=0.2.0 
    │   └── secretstorage >=3.2 
    │       ├── cryptography >=2.0 
    │       │   └── cffi >=1.12 
    │       │       └── pycparser * 
    │       └── jeepney >=0.6 (circular dependency aborted here)
    ├── packaging >=20.5 (circular dependency aborted here)
    ├── pexpect >=4.7.0,<5.0.0 
    │   └── ptyprocess >=0.5 
    ├── pkginfo >=1.9.4,<2.0.0 
    ├── platformdirs >=3.0.0,<4.0.0 
    ├── poetry-core 1.8.1 
    ├── poetry-plugin-export >=1.6.0,<2.0.0 
    │   ├── poetry >=1.6.0,<2.0.0 (circular dependency aborted here)
    │   └── poetry-core >=1.7.0,<2.0.0 (circular dependency aborted here)
    ├── pyproject-hooks >=1.0.0,<2.0.0 (circular dependency aborted here)
    ├── requests >=2.26,<3.0 (circular dependency aborted here)
    ├── requests-toolbelt >=0.9.1,<2 
    │   └── requests >=2.0.1,<3.0.0 (circular dependency aborted here)
    ├── shellingham >=1.5,<2.0 
    ├── tomli >=2.0.1,<3.0.0 (circular dependency aborted here)
    ├── tomlkit >=0.11.4,<1.0.0 
    ├── trove-classifiers >=2022.5.19 
    ├── virtualenv >=20.23.0,<21.0.0 
    │   ├── distlib >=0.3.7,<1 
    │   ├── filelock >=3.12.2,<4 (circular dependency aborted here)
    │   └── platformdirs >=3.9.1,<5 (circular dependency aborted here)
    └── xattr >=0.10.0,<0.11.0 
        └── cffi >=1.0 (circular dependency aborted here)
pivoshenko commented 7 months ago

Thanks, I will have a look, probably will try to run it using your OS in Docker, trying to reproduce the error. Might be a bit slow, so sorry in advance!

pivoshenko commented 7 months ago

In meantime, can you please try to install older version?

poetry self add poetry-plugin-dotenv@<version>
pivoshenko commented 7 months ago

Hi @arnaudgelas! Sorry, but unfortunately I was not able to reproduce the error. I believe this issue occurs because of the poetry itself because the plugin doesn't have any dependencies apart from poetry I am suggesting you open an issue in poetry's repo https://github.com/python-poetry/poetry/issues and please link it here (post a comment to the issue)

Thanks 😊

arnaudgelas commented 6 months ago

Hi @volopivoshenko It took me some time to figure out and fix this issue. I just wanted to let you know that with a clean installation of poetry, it works like a charm.

pivoshenko commented 6 months ago

hah got it @arnaudgelas! Thanks for your feedback!

github-actions[bot] commented 2 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed.