-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(macros-core): more consistent env loading and reading logic (alternate) #4039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I was only able to revisit my PR a few days ago in response to @abonander’s insightful review comments, so the timing for this follow-up PR is actually nice! 😄 While running some local experiments, I should confess I ended up going down into a bit of a rabbit hole trying to better understand the constrained environment proc macros may be run under, and exploring reliable ways to cache read environment variables within it. Overall, I think this PR is an interesting look at the problem from a fresh pair of eyes. That said, I'm unsure whether it's acceptable to scan for env files and re-read them every time the proc macro runs, especially since, under RA's execution model during completions, that can happen more frequently than when doing standard More importantly from a functional perspective, this PR still contains a call to |
Makes sense, but I think with this approach we can add caching on top more simply? For example, you could just slap a |
From the
And for the reasons stated on #4018 (comment), that's precisely the kind of caching we want to avoid, unless we take care of keying the cache in a way that changes can be reliably and cheaply detected, which is where the complications with the caching stem from and |
@AlexTMjugador I don't think that comment is relevant since the cache key here would be the manifest path. |
Yeah, if you pass the cache key as a parameter to that function |
I'm not sure I follow? You already need to pass the manifest path in order to load the dotenv file, so it's no more unergonomic than it is currently? |
Thanks @AlexTMjugador for doing the hard work on this. We ran into the same problem.
This PR is an alternative fix that is a bit simpler, but the dot-env finding logic is shamelessly lifted from the original PR.
The improvement here is that we don't need to keep a global cache of env vars, and we don't need to specify in advance which env vars will be needed.