How to update the session environment on Windows runner? #6065
-
I am migrating my Windows CI build to Actions. I need to install some software not available in Chocolatey, e.g. the Vulkan SDK. The installers for these items set some environment variables in the registry and update the Path environment variable. In my previous CI I used Here is an extract.
The Install Dependencies step calls a script to download and run the Vulkan SDK installer. The installer sets the environment variable VULKAN_SDK into the Windows registry. After the script, I call Chocolatey's refreshenv to get the variable into the current session however it is not visible. The reg query shows it is set in the registry. It also does not appear in the Build Windows step. Isn't this a new instance of Powershell? If so it so should get whatever was added to registry during Install Dependencies. Again the reg query shows the env. var. is present. One strange thing is that the message Another is that according to this Chocolatey documentation How can I get the Build Windows step to see the environment variable? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @MarkCallow.
|
Beta Was this translation helpful? Give feedback.
-
I found the solution. To use Chocolatey's
The Chocolatey install instructions that I found do not mention the helpers. I do not know if having to import them is standard operating procedure. Although the runner creates a new PS for each step, those processes do not see the registry updates which means they must be launched from an existing PS instance and not the system. Therefore you need to add the above to any step that needs the environment variables. If you are using Java you also have to be aware that the registry contains a
I thought about creating something like |
Beta Was this translation helpful? Give feedback.
I found the solution. To use Chocolatey's
refreshenv
/Update-SesionEnvironment
in Powershell (PS) you have toimport
their helpers package to your PS.The Chocolatey install instructions that I found do not mention the helpers. I do not know if having to import them is standard operating procedure.
Although the runner creates a new PS for each step, those processes do not see the registry updates which means they must be launched from an existing PS instance and not the system. Therefore you need to add the above to any step that needs the environment variables.
If you are using Java you also have to be awa…