Should netlify dev functions have access to env variables?

I have an environment variable set in the UI that is not being picked up by netlify dev. In my previous tests with the CLI, I saw it “reach out” to the server to get the values, but I can’t seem to get it working again. I did noticed that my local netlify.toml file did not have a Settings/ID value. I set that myself manually - but it didn’t help.

hey Raymond! just saw your blogpost. great post :slight_smile:

yes, it should be picking up env variables. if it doesn’t, its a bug. but i also have no reason to believe it’s a bug yet. I don’t know what you mean by Settings/ID value, thats not a field we read. maybe you mean /.netlify/state.json? that controls how your local project is linked to the netlify site instance, and that is required for this env var pulldown to work. if you run netlify status, you should see the linked instance, and if you don’t, that will be the cause. run netlify link to fix.

as a last note, i think we are both on twitter, feel free to reach out to me directly if you need anything realtime. love your blogging. and yes we do need to think about the number of function templates we offer. but for now i am biasing towards more as it is a teaching opportunity.

1 Like

Thanks for the response.

Settings/ID: In an earlier project, my toml file had a Settings section and an ID value that matched the remote site, so I assumed it was required. In fact, it is documented here: https://www.netlify.com/docs/netlify-toml-reference/. Is that not a valid way to “connect” a site?

I just ran netlify status and it is NOT linked. Running link now and it worked, saving to .netlify/state.

I’ll test my env values in a second, but I guess that was the issue - but can you see how I got confused thinking I could make the link via the toml file?

And just 100% confirming, when I ran netlify dev I see my env variables come in.

yes, i can. because that documentation is out of date :frowning:

i’ll fix the docs. for the record the one and only source of truth for site linking is /.netlify/state.json.

Out of date docs I can understand - just happy it wasn’t my fault. Thanks!