Repository navigation
[repo-assist] Fall back to User/Machine scoped environment variables in paket.dependencies - #4406
Merged
dsyme merged 1 commit intoAug 30, 2026
Conversation
…dencies Environment.GetEnvironmentVariable(name) only reads the current process's environment block, which doesn't reflect variables set at the User or Machine level via SetEnvironmentVariable until a new process is started. This caused '%VAR%' references in paket.dependencies to fail to resolve for such variables. Now falls back to explicitly reading the User and Machine scopes (Windows-only concept; PlatformNotSupportedException is caught on other platforms) when the process-level lookup misses. Closes #3562 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
approved these changes
Aug 30, 2026
74 tasks
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was authored by Repo Assist, an automated AI assistant.
Root cause
EnvironmentVariable.Create(used to resolve%VAR%references inpaket.dependencies, e.g. for credentials) calledEnvironment.GetEnvironmentVariable(name), which only reads the current process's environment block. Variables set at the User or Machine scope via[System.Environment]::SetEnvironmentVariable(name, value, 'User')are persisted (e.g. in the Windows registry) but are not reflected in an already-running process's environment — a new process must be started to see them. This caused Paket to warnenvironment variable '%VAR%' not foundeven though the variable was correctly set, as reported in #3562.Fix
EnvironmentVariable.Createnow falls back to explicitly querying theUserandMachineEnvironmentVariableTargetscopes when theProcessscope lookup misses, before giving up and warning.PlatformNotSupportedException(thrown on non-Windows platforms, where these scopes don't exist) is caught so the fallback is a safe no-op there.Trade-offs
GetEnvironmentVariablecalls) only in the miss case; negligible cost since credential resolution happens rarely (parse-time).Closes #3562
Test Status
PackageSourceSpecs.fs— resolving a process-level env var, and warning/empty-value for an unknown var.dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~PackageSourceSpecs": 16/16 passed onnet9.0. Thenet461target could not execute in this sandbox (monohost not installed) — this is an environment limitation, not a code failure; the same assembly built successfully for both target frameworks.Add this agentic workflow to your repo
To install this agentic workflow, run