Pycharm + Doppler CLI = Error

Hey folks,

Today I appear to have an error using Pycharm and the Doppler CLI tool that I didn’t have yesterday. When I attempt to run my project, I get the following error:

Unable to download secrets
Doppler Error: You must specify a project
Error processing line 2 of C:\Users\username\.virtualenvs\project-yZPpvnK8\lib\site-packages\doppler_env.pth:

I double-checked my configuration. I have DOPPLER_ENV=1 set in both my debug configuration variable and the console environmental variable. I authenticated to the doppler dashboard just fine. I have tried running doppler setup from the Pycharm terminal and in the same folder using Powershell with no change in result.

I also created a new project using the same setup in Pycharm and using the same Doppler project, and I get secrets with no error.

If anyone has any suggestions, I’d appreciate the help.

Regards,
Bruce

And now the other test project that was working an hour ago is exhibiting the same behavior…

Hey @bp4151,

Does this happen outside of Pycharm too? Or only when you’re using a terminal inside of Pycharm? This is pretty odd since doppler setup writes to ~/.doppler/.doppler.yaml and the CLI will load the project and config specified based on path from there. It shouldn’t matter which terminal you’re using.

Does the CLI work if you manually specify a project and config using the -p and -c flags?

-Joel

Hi Joel,

The yaml file looks to be correct. I think I’ve narrowed the issue down to running in the PyCharm IDE. I can run the script using doppler run – python main.py. I just can’t debug anymore within PyCharm.

OS: Windows 10
PyCharm: 2022.1.2
Python: 3.10

Issue: When running a script in PyCharm using doppler-env, an error is thrown indicating the project has not been set despite doppler setup having been run and a project and config having been selected.

I found a workaround for this. In doppler_env/__init.py, there is the block of code

    DOPPLER_ENV_COMMAND = os.environ.get(
        'DOPPLER_ENV_COMMAND', 'doppler secrets download --no-file --format env'
    )

Seeing as how this is reading an environment variable that has a default value of ‘doppler secrets download --no-file --format env’, I added the following environment variable to my PyCharm run/debug configuration

DOPPLER_ENV_COMMAND=doppler secrets download --project <project goes here> --config <config goes here> --no-file --format env

Once I added that environment variable, the script ran as expected