Environment variable not set when executing tests

In my unit tests (NUnit) I check DOTNET_ROOT environment  variable in order to find the folder in which dotnet binaries should be looked up. 

When executing these tests Environment.GetEnvironmentVariable("DOTNET_ROOT") returns null (which does not happen when I debug the same tests)

I wonder whether someone has seem similar behavior

 

Environment: Ubuntu 25.04, Rider 2025.2.1

0
2 comments

Hello Adriano,

Thank you for contacting JetBrains Support. I'm glad to work with you on this ticket.

This is currently by-design limitation that Rider does not read environment variables from .bashrc. See the issues below for more information:
RIDER-79551 Environment Variables (exported in ~/.bashrc) not anymore available when running/debugging a project

IJPL-1055 Load interactive shell environment variables on Linux

 

You may use the workarounds mentioned in the issues above, or add the environment variable in Run Configuration.  

Regards,

Tom

 

1

Hi Tom.

That makes sense. 

Setting the env var in `.profile` is good enough for me :)

0

Please sign in to leave a comment.