Skip to content
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

Pass env parameter to os.SubProcess.env in MillMain #3437

Merged
merged 2 commits into from
Aug 31, 2024

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Aug 30, 2024

Fixes #2881 since now correct env is used all the time.

Also updates os-lib to 0.10.5

Reproduction

// build.sc
import mill._
import mill.scalalib._

object root extends RootModule with ScalaModule {
  def scalaVersion = "3.3.1"
}
// src/main.scala
@main
def run =
  println(s"[app] MY_ENV=${sys.env.get("MY_ENV")}")

Run the following command:

rm -rf out; MY_ENV=hello mill run; mill run

Before this PR it outputs:

rm -rf out; MY_ENV=hello mill run; mill run
[build.sc] [48/52] compile 
Compiling compiler interface...
[info] compiling 1 Scala source to /Users/lorenzo/scala/repro/out/mill-build/compile.dest/classes ...
[info] done compiling
[35/48] compile 
[info] compiling 1 Scala source to /Users/lorenzo/scala/repro/out/compile.dest/classes ...
[info] done compiling
[48/48] run 
[app] MY_ENV=Some(hello)
[48/48] run 
[app] MY_ENV=Some(hello)

After this PR it outputs:

rm -rf out; MY_ENV=hello mill run; mill run
[build.sc] [48/52] compile 
Compiling compiler interface...
[info] compiling 1 Scala source to /Users/lorenzo/scala/repro/out/mill-build/compile.dest/classes ...
[info] done compiling
[35/48] compile 
[info] compiling 1 Scala source to /Users/lorenzo/scala/repro/out/compile.dest/classes ...
[info] done compiling
[48/48] run 
[app] MY_ENV=Some(hello)
[48/48] run 
[app] MY_ENV=None

@lolgab lolgab changed the title Pass env parameter to os.SubProcess.env in MillMain [WIP] Pass env parameter to os.SubProcess.env in MillMain Aug 30, 2024
Fixes com-lihaoyi#2881 since now correct
env is used all the time.
@lolgab lolgab changed the title [WIP] Pass env parameter to os.SubProcess.env in MillMain Pass env parameter to os.SubProcess.env in MillMain Aug 31, 2024
@lolgab lolgab marked this pull request as ready for review August 31, 2024 07:29
@lolgab lolgab requested review from lihaoyi and lefou August 31, 2024 11:16
Copy link
Member

@lihaoyi lihaoyi left a comment

Choose a reason for hiding this comment

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

Looks good to me. @lolgab could you update the PR description with how this was tested? Manual testing is fine, just need to write down how you did it in case we need to reproduce the tests later

@lolgab lolgab merged commit accb103 into com-lihaoyi:main Aug 31, 2024
33 checks passed
@lolgab lolgab deleted the pass-env-os-SubProcess branch August 31, 2024 13:42
@lihaoyi lihaoyi added this to the 0.12.0 milestone Aug 31, 2024
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.

Stale server environment is propagated when running processes with run
2 participants