Skip to content

Set user environment variables permanently by using --permanent + deprecate --global#621

Merged
sbc100 merged 14 commits into
emscripten-core:masterfrom
aminya:env-user-system
Sep 30, 2020
Merged

Set user environment variables permanently by using --permanent + deprecate --global#621
sbc100 merged 14 commits into
emscripten-core:masterfrom
aminya:env-user-system

Conversation

@aminya
Copy link
Copy Markdown
Contributor

@aminya aminya commented Sep 18, 2020

Closes #468

Fixes #467

This makes ./emsdk activate --global to set user environment variables by default instead of previous system-wide-only activation.

Also removes some magic that implicitly nukes user envvars when system ones are shadowed, as a system admin should understand what's going on when setting envvars. Thus fixes #189 and closes #192.

@aminya aminya force-pushed the env-user-system branch 2 times, most recently from c6a230c to a6ef5ae Compare September 18, 2020 22:32
@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 18, 2020

According to the comments in #468 we decided it was best not to change existing meaning of --global.

I think the best option was to add two new options --persistent (meaning set in the registry for the current user) and --persistent-system meaning set in the registry for all users.

--global can the becomes a legacy alias for --persistent-system.

@aminya aminya force-pushed the env-user-system branch 2 times, most recently from 5e053e6 to 9f24f8e Compare September 19, 2020 00:11
@aminya
Copy link
Copy Markdown
Contributor Author

aminya commented Sep 19, 2020

I deprecated --global. Now, we have --permanent to set the environment variables permanently.

@aminya
Copy link
Copy Markdown
Contributor Author

aminya commented Sep 19, 2020

I added the tests, which shows that pywin32 code part of emsdk is broken.

#91

Nothing is wrong with this PR, so I suggest that you merge it and instead try to fix the tests (probably by merging #91). Emsdk did not have these tests and this has caused many issues on Windows.

Otherwise, you can comment this line to bypass the broken tests: https://github.com/emscripten-core/emsdk/pull/621/files#diff-1d37e48f9ceff6d8030570cd36286a61R93 or I can make the tests a separate PR.

@saschanaz
Copy link
Copy Markdown
Contributor

Yay, thanks for taking over!

Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not had a chance to look at the new test script but generally this change lgtm!

Comment thread emsdk.py
Comment thread emsdk.py Outdated
Comment thread emsdk.py
Comment thread scripts/test_permanent.ps1 Outdated
@kripken
Copy link
Copy Markdown
Member

kripken commented Sep 24, 2020

Is the CI error the last issue here? (maybe also the permanent/persistent naming question)

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 24, 2020

I think we need a tie breaker :) @kripken @juj how to do you feel about --persistent vs --permanent .

As a non-windows-user I don't care too much either way.

@aminya
Copy link
Copy Markdown
Contributor Author

aminya commented Sep 25, 2020

Is the CI error the last issue here?

This is not an issue of this PR. I added the tests, so we know that environment variables are not set on Windows (the behavior is broken). We need to fix the tests in other pull requests such as in #91.

If you run the same tests using the deprecated --global option on the master branch, they will still fail.

(maybe also the permanent/persistent naming question)

I don't feel strongly about this. I think --permanent is more descriptive. --persistent is a little fuzzy since it does not explicitly say persisting between what.

@aminya aminya changed the title Set user environment variables by default when giving --global in Windows Set user environment variables permanently by using --permanent + deprecate --global Sep 25, 2020
Comment thread scripts/test_permanent.ps1 Outdated
@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 25, 2020

Is the CI error the last issue here?

This is not an issue of this PR. I added the tests, so we know that environment variables are not set on Windows (the behavior is broken). We need to fix the tests in other pull requests such as in #91.

Can you remove the tests from this PR then? somehow disable them or mark them as currently known/expected to fail? We don't want to land a change with the CI being red.

aminya added a commit to aminya/emsdk that referenced this pull request Sep 26, 2020
@aminya
Copy link
Copy Markdown
Contributor Author

aminya commented Sep 26, 2020

Is the CI error the last issue here?

This is not an issue of this PR. I added the tests, so we know that environment variables are not set on Windows (the behavior is broken). We need to fix the tests in other pull requests such as in #91.

Can you remove the tests from this PR then? somehow disable them or mark them as currently known/expected to fail? We don't want to land a change with the CI being red.

I caught the failures in 2d7ccb2

This PR is ready to go.

@kripken
Copy link
Copy Markdown
Member

kripken commented Sep 29, 2020

I don't have a preference between --persistent vs --permanent .

I think if the code looks good to you @sbc100 , let's land it!

Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with a couple more comments. Ready to land once they are addressed.

Comment thread emsdk.py Outdated
Comment thread emsdk.py Outdated
Comment thread emsdk.py Outdated
Comment thread emsdk.py
Comment thread emsdk.py Outdated
Comment thread emsdk.py Outdated
Comment thread emsdk.py Outdated
Comment thread emsdk.py Outdated
@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Oct 6, 2020

Looks like the removal of the second call to causes the issue:

current_user_path = win_get_environment_variable('PATH', system=False)

Previously it was adding the user and system PATHs together I think.

I guess we should probably just ignore the registry when running in normal (non-persistent) mode and just look at the current os.environ['PATH']?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Way to set user environment variables emsdk construct_env on Windows nukes local paths

4 participants