Skip to content

[update-checkout] Don't use env for portability. #23673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

drodriguez
Copy link
Contributor

env is not portable in systems that do not have env like, for example, Windows. However, passing the environment is supported by shell.run using the env parameter, which should be portable.

@drodriguez drodriguez requested a review from moiseev March 29, 2019 22:36
@jrose-apple
Copy link
Contributor

It looks like this will replace the environment rather than adding to it, which is not what we want.

@drodriguez
Copy link
Contributor Author

Funny thing. shell.call() and shell.capture() merge the environments, but shell.run() doesn’t. I was expecting all to do the same.

@jrose-apple
Copy link
Contributor

Hm, maybe that's a bug in shell.run, then. You'd have to talk to @Rostepher about what he wants to do with that, probably.

env is not portable in systems that do not have env, like for example Windows. However, passing the environment is supported by shell.run using the env parameter, which should be portable.

For some reason shell.run doesn't merge the environment with the current environment by default, so we do it externally to not modify other possible usages of the function.
@drodriguez drodriguez force-pushed the update-checkout-env-windows branch from c59d03e to 8c721de Compare March 29, 2019 23:31
@drodriguez
Copy link
Contributor Author

Well, for the time being, instead of modifying shell.run() (even if it looks only being used from update_checkout.py), I modifying the function that invokes shell.run() with an environment to merge the current with the new value.

I can fix shell.run() if people prefer that.

@Rostepher
Copy link
Contributor

Ultimately I'd planned to re-write the shell module in build_swift and have it mimic the subprocess module more closely. I think it's a lot more transparent if the caller needs to make a copy of the system environment and extend it at the call site than rely on the shell.call function to do that.

@drodriguez
Copy link
Contributor Author

I have to say that it feels natural that the environment gets merged, since that's what happen in the shell itself, but it is true that that approach do not allow removing pieces from the environment, or starting with a clean environement, so I understand the decision. Good thing I decided to not modify run.

@drodriguez
Copy link
Contributor Author

@moiseev: I will like to have this available for the future Windows CI. For the time being I’m cloning manually, but it would be great to use the official checkout script. Would you mind having a look at this? (hopefully you are not on vacation). Thanks! (If anyone else have any more feedback, that's also welcomed).

@moiseev
Copy link
Contributor

moiseev commented Apr 16, 2019

@swift-ci Please smoke test

@drodriguez drodriguez merged commit b3d6214 into swiftlang:master May 7, 2019
@drodriguez drodriguez deleted the update-checkout-env-windows branch July 16, 2019 23:36
@AnthonyLatsis AnthonyLatsis added the update-checkout Area → utils: the `update-checkout` script label Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
update-checkout Area → utils: the `update-checkout` script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants