question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[environment] can't update environment variables

See original GitHub issue

Steps to reproduce

Install powershell from microsoft store


[environment]::setEnvironmentVariable('TEST_URL','http:url','User')

Expected behavior

reopen shell

$env:TEST_URL 

output: http:url

Actual behavior

reopen shell

$env:TEST_URL

output is empty

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Vixb1122commented, Nov 15, 2020

@vexx32

There may still be an MSIX specific limitation in play here, but the steps in the issue description will not work as expected in any version of PowerShell.

The ‘reopen shell’ operation that I missed in the issue description

Now, i can understand MSIX specific limitation.

run command in powershell installed from msix, and reopen shell and see $env:TEST_URL Snipaste_2020-11-15_11-06-56

run command in windows powershell, and reopen shell and see $env:TEST_URL Snipaste_2020-11-15_11-08-50

0reactions
sdwheelercommented, Nov 16, 2020

@iSazonov This is MSIX specific. The MSIX sandbox virtualizes some registry access. [Environment]::SetEnvironmentVariable('TEST_URL', 'http:url', 'User') writes the value to the User registry, which is virtualized. So the change is not persistent across sessions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't edit environment variables in windows 10
I got around it by opening the System page in Control Panel (Win+X -> Y), going to "Advanced system settings", then clicking "Environment ......
Read more >
5 reasons why your .env environment variables don't work
1. Your framework doesn't automatically load .env files. · 2. You added or otherwise updated your .env file after starting your server. ·...
Read more >
Can't change environment variables in windows 10
In windows 10 whether I go to the control panel or through the start panel, nothing happen when I click to edit the...
Read more >
conda env update doesn't update environment variables
I've noticed that the conda_env cli option for updating conda environment from a yml file doesn't create/update environment variables.
Read more >
Python: Environment Variables not updating
I am trying to overwrite to environment variables in Python. I can read the value and then write the value and print the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found