ruby-lsp-rspec icon indicating copy to clipboard operation
ruby-lsp-rspec copied to clipboard

Missing environment context

Open jherdman opened this issue 1 year ago • 6 comments

The application I'm working on leverages direnv to seed the environment with necessary environment variables. When I attempt to run tests via this extension I can see that these environment variables aren't being populated.

jherdman avatar Oct 28 '24 14:10 jherdman

Has there been any progress or insight here?

jherdman avatar May 21 '25 14:05 jherdman

Why would you expect progress when you don't open a PR or even just do some research for possible solutions?

st0012 avatar May 21 '25 16:05 st0012

You know what, you're right. Thank you for calling me out on my crap attitude. I offer my apologies.

jherdman avatar May 21 '25 16:05 jherdman

I appreciate it 🙂 Injecting envs to test environment has always been tricky as there's no a blessed way to load those envs. I've never used direnv but I'd assume the envs is NOT loaded directly to the user shell profile but needs to be injected in some way?

st0012 avatar May 21 '25 16:05 st0012

Yes, exactly. Direnv basically dynamically loads environment variables provided an .envrc file when your shell boots.

I don't think this problem is unique to this plugin though. You can see Vitest has a terminal option for running tests: https://github.com/vitest-dev/vscode?tab=readme-ov-file#workspace-configurations

jherdman avatar May 22 '25 15:05 jherdman

@jherdman I believe using mise instead of direnv will fix your problem: https://mise.jdx.dev/dev-tools/shims.html 😉

sskirby avatar Jun 07 '25 22:06 sskirby