Skip to content

Set user environment variables by default when giving --global in Windows#468

Closed
saschanaz wants to merge 2 commits into
emscripten-core:masterfrom
saschanaz:user-envvars
Closed

Set user environment variables by default when giving --global in Windows#468
saschanaz wants to merge 2 commits into
emscripten-core:masterfrom
saschanaz:user-envvars

Conversation

@saschanaz
Copy link
Copy Markdown
Contributor

@saschanaz saschanaz commented Apr 12, 2020

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.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Apr 12, 2020

This change looks great!

The only slight concern I have is changing the default. Do you know that history here? Why would setting system-wide have been desirable? Under what circumstances would it still be desirable? Do we need the option at all? Maybe we simply remove the option and always set user settings?

@juj do you remember why this was done this way in the first place?

Comment thread emsdk.py Outdated
# Looks at the current PATH and adds and removes entries so that the PATH reflects
# the set of given active tools.
def adjusted_path(tools_to_activate, log_additions=False, system_path_only=False):
def adjusted_path(tools_to_activate, log_additions=False, system=False):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like the log_additions param is never uses, or passed. Unrelated to this PR but since your are changing that line maybe delete it?

@juj
Copy link
Copy Markdown
Collaborator

juj commented Apr 14, 2020

The intent of calling emsdk activate has been to only enable the env. vars for current/calling user prompt, not do any permanent modifications to the system.

Then, emsdk activate --global is intended to apply permanent modifications to "All users" section of the registry.

(The doc piece at emsdk --help looks like up to date with this respect:

    if WINDOWS:
      print('''
   emsdk activate [--global] [--embedded] [--build=type] [--vs2013/--vs2015/--vs2017] <tool/sdk>

                                - Activates the given tool or SDK in the
                                  environment of the current shell. If the
                                  --global option is passed, the registration
                                  is done globally to all users in the system

There has never existed an option to perform "Current user" only registry activation. If that is desirable, perhaps it would be good to have that as a new option emsdk activate --local or emsdk activate --local_user, instead of changing the existing emsdk activate from "current prompt only" to "permanent local user"?

@saschanaz saschanaz changed the title Set user environment variables by default in Windows Set user environment variables by default when giving --global in Windows Apr 14, 2020
@saschanaz
Copy link
Copy Markdown
Contributor Author

saschanaz commented Apr 14, 2020

If that is desirable, perhaps it would be good to have that as a new option emsdk activate --local or emsdk activate --local_user, instead of changing the existing emsdk activate from "current prompt only" to "permanent local user"?

Sorry for misleading description, but no, this doesn't change emsdk activate to set the permanent user global environment, instead it modifies emsdk activate --global to be user scope by default.

I think defaulting to user global environment with --global is better as it does not require admin privilege.

@juj
Copy link
Copy Markdown
Collaborator

juj commented Apr 16, 2020

I think defaulting to user global environment with --global is better as it does not require admin privilege.

It feels like changing --global from meaning global to user local would be counterintuitive? A new option --local would be a better name?

@saschanaz
Copy link
Copy Markdown
Contributor Author

saschanaz commented Apr 16, 2020

IMO it's global user variables and global system variables, not "local", which sounds like non-permanent local shell variable. (Like in this page for example)

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Apr 16, 2020

I also feel like changing the meaning of an existing flag I a little confusing/misleading. How about simply removing the old --global flag which is ambiguous to something more specific such as --persistent or --registry?

Any users of the old --global flag could be asked to be more specific and switch to either --persistent or --persistent + --system.

@saschanaz
Copy link
Copy Markdown
Contributor Author

--persistent sounds good to me, as --global can be an alias for --persistent --system then.

@juj
Copy link
Copy Markdown
Collaborator

juj commented Apr 17, 2020

--persistent sounds good, although I would recommend instead of --persistent --global to have --persistent_global, since the flags are not orthogonal: passing --global on its own would not be meaningful.

@saschanaz
Copy link
Copy Markdown
Contributor Author

saschanaz commented Apr 17, 2020

Does --persistent and --persistent-global --persistent-system sound good? Those should be mutually exclusive.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Apr 17, 2020

I like --persistent-system and you could even keep the old --global flag as an alias to that or while/

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented May 7, 2020

Any update on this? I think it would be good change overall.

@saschanaz
Copy link
Copy Markdown
Contributor Author

I'll try get some time this weekend.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Jun 23, 2020

Any update?

Copy link
Copy Markdown
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

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

This is a very good change. What is blocking this from merging?

Can someone with write access update this branch?

Comment thread emsdk.py
arg_old = extract_bool_arg('--old')
arg_uses = extract_bool_arg('--uses')
arg_global = extract_bool_arg('--global')
arg_system = extract_bool_arg('--system')
Copy link
Copy Markdown
Contributor

@aminya aminya Sep 15, 2020

Choose a reason for hiding this comment

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

If arg_system is provided but arg_global is not, it should automatically set that. In other words, system means permanent too!

Suggested change
arg_system = extract_bool_arg('--system')
arg_system = extract_bool_arg('--system')
if arg_system
arg_global=True

Copy link
Copy Markdown
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

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

If there is anywhere to document the meanings of these options, we should.

global: set the environment variables permanently.
system: set the environment variables for all users of the system.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 15, 2020

emsdk --help is the main place we document this stuff.

@saschanaz
Copy link
Copy Markdown
Contributor Author

I have to admit that I'm not actively using emsdk nowadays. I still intend to work on it but if anyone wants to take this over, please do.

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 17, 2020

No problem. Hopefully someone can pick this up and get it landed.

@aminya
Copy link
Copy Markdown
Contributor

aminya commented Sep 18, 2020

@sbc100 this is almost ready. If you have write-access why don't you just finish it? Remember the more we wait, there will be more work to fix the conflicts

@sbc100
Copy link
Copy Markdown
Collaborator

sbc100 commented Sep 18, 2020

I will get around to it at some point sure, but I've got a lot of other things I'm working so if anyone else want to pick this up in the mean time feel free.

@aminya
Copy link
Copy Markdown
Contributor

aminya commented Sep 18, 2020

Well, this is a critical bug on Windows, and we should fix it as soon as possible. I don't want emsdk to remove all the programs from my PATH!

@sbc100 sbc100 closed this in #621 Sep 30, 2020
@saschanaz saschanaz deleted the user-envvars branch December 28, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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