Skip to content

Preserve environment for script subprocesses - #73

Draft
jkramer5103 wants to merge 1 commit into
maxuser0:mainfrom
jkramer5103:agent/preserve-subprocess-environment
Draft

Preserve environment for script subprocesses#73
jkramer5103 wants to merge 1 commit into
maxuser0:mainfrom
jkramer5103:agent/preserve-subprocess-environment

Conversation

@jkramer5103

Copy link
Copy Markdown
Contributor

What changed

  • launch script subprocesses with ProcessBuilder so they inherit Minecraft's environment
  • overlay Minescript's configured PYTHONPATH, MINESCRIPT_COMMAND_PATH, and custom command environment values
  • add a regression test covering inherited variables, overrides, and values containing =

Root cause

Runtime.exec(command, envp) treats a non-null envp as the subprocess's complete environment. Minescript passed only its custom variables, so standard Windows variables such as LOCALAPPDATA were removed.

The Windows Python Install Manager uses LOCALAPPDATA while scanning unmanaged installations. When Minescript launched the default WindowsApps\\python3.exe alias without that variable, Python Manager tried to construct a path from None and printed:

[WARNING] Failed to read unmanaged installs: expected str, bytes or os.PathLike object, not NoneType

Python Manager catches that exception and continues, which is why scripts still worked while the warning appeared for every invocation.

Fixes #69.

Validation

  • ./gradlew --configure-on-demand :common:test — passes
  • :common:compileJava — passes as part of the test task
  • git diff --check — passes

The repository's unrestricted Gradle configuration currently fails before task execution because ForgeGradle rejects the repository's Gradle 9.2 wrapper. Configuration-on-demand isolates and validates the affected common module.

@jkramer5103

Copy link
Copy Markdown
Contributor Author

Currently don't have a windows machine to test this issue, im pretty sure this fixes it, but I asked the person that submitted the issue to test it out, we'll see.

@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: © 2026 jkramer5103 <info@jkramertech.com>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

See this recent commit about copyright attribution going forward:

8e5e798

Existing sources still have the old copyright notices, but I'll update those over time.

@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: © 2026 jkramer5103 <info@jkramertech.com>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same here.

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.

[WARNING] Failed to read unmanaged installs: expected str, bytes or os.PathLike object, not NoneType

2 participants