Can't setup Doppler for my monorepo

Hello everyone!

I’m trying to integrate Doppler into my monorepo (TurboRepo) for the first time, but unfortunately, I can’t manage to get it to work…

When launching it from the root of the monorepo, and even when I launch it directly from each app, I get this message:

❯ doppler run -- pnpm dev 
Unable to fetch secrets from the Doppler API
Doppler Error: This token does not have access to requested project 'cli'
Reading secrets from fallback file
Doppler Error: The fallback file does not exist

Output of the setup command :

❯ doppler setup
? Use settings from repo config file (doppler.yaml) for /Users/gaetandrt/Documents/Projects/AltabCorp/altab? Yes
Auto-selecting project from repo config file
Auto-selecting config from repo config file
┌─────────┬───────┬─────────────────────────────────────────────────────┐
│ NAME    │ VALUE │ SCOPE                                               │
├─────────┼───────┼─────────────────────────────────────────────────────┤
│ config  │ stg   │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab │
│ project │ cli   │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab │
└─────────┴───────┴─────────────────────────────────────────────────────┘
? Use settings from repo config file (doppler.yaml) for /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/frontend? Yes
Auto-selecting project from repo config file
Auto-selecting config from repo config file
┌─────────┬──────────┬───────────────────────────────────────────────────────────────────┐
│ NAME    │ VALUE    │ SCOPE                                                             │
├─────────┼──────────┼───────────────────────────────────────────────────────────────────┤
│ config  │ stg      │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/frontend │
│ project │ frontend │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/frontend │
└─────────┴──────────┴───────────────────────────────────────────────────────────────────┘
? Use settings from repo config file (doppler.yaml) for /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/backend? Yes
Auto-selecting project from repo config file
Auto-selecting config from repo config file
┌─────────┬─────────┬──────────────────────────────────────────────────────────────────┐
│ NAME    │ VALUE   │ SCOPE                                                            │
├─────────┼─────────┼──────────────────────────────────────────────────────────────────┤
│ config  │ stg     │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/backend │
│ project │ backend │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab/apps/backend │
└─────────┴─────────┴──────────────────────────────────────────────────────────────────┘

My doppler.yml at the root :

setup:
  - project: cli
    config: stg
    path: .
  - project: frontend
    config: stg
    path: apps/frontend/
  - project: backend
    config: stg
    path: apps/backend/

Doppler configure at the root :

❯ doppler configure
┌────────────────┬───────────────────────────────┬─────────────────────────────────────────────────────┐
│ NAME           │ VALUE                         │ SCOPE                                               │
├────────────────┼───────────────────────────────┼─────────────────────────────────────────────────────┤
│ api-host       │ https://api.doppler.com       │ /                                                   │
│ config         │ stg                           │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab │
│ dashboard-host │ https://dashboard.doppler.com │ /                                                   │
│ project        │ cli                           │ /Users/gaetandrt/Documents/Projects/AltabCorp/altab │
│ token          │ dp.ct.….                      │ /                                                   │
└────────────────┴───────────────────────────────┴─────────────────────────────────────────────────────┘

Thanks for your help !

I’m not sure if it’s a right way to do it, but I switched to doppler per package.

Essentially in apps/frontend/package.json and in apps/backend/package.json dev scripts are prefixed with doppler run. Because they might have different values for the same variable, it feels safer to not run globally.

Secondly, make sure you allow variables in your turbo.json.

If we prefix each subpackage with doppler run and have turbo dev/build in the top-level package.json, doesn’t env caching not work anymore since secrets are injected after turbo invocation?

Did you have a workaround for this? (or did you just disable turbo caching entirely?)

Good catch, I have not thought about it. I’m curious what turbo team suggests, as it’s so common to have .env with dotenv/load. Which will lead to the same problem. Although, I have a lot of cache hits, maybe it’s specifics of my apps that not much of it is a part of compilation and mostly pass through.