Skip to content

[repo-assist] Fix crash when HOME/USERPROFILE environment variable is unset (#3791) - #4433

Open
github-actions[bot] wants to merge 3 commits into
masterfrom
repo-assist/fix-issue-3791-home-env-var-36acb08a563b1602
Open

github-actions[bot] wants to merge 3 commits into
masterfrom
repo-assist/fix-issue-3791-home-env-var-36acb08a563b1602

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant.

Closes #3791

Root cause

On .NET Core builds, Constants.Environment.GetFolderPath (used for locating ApplicationData, UserProfile, etc.) reads the HOME (or USERPROFILE on Windows) environment variable and passes it straight into Path.Combine. When neither variable is set — as reported when running as root in some CI containers (e.g. Azure DevOps Pipelines) — homePath is null, and Path.Combine(null, ...) throws an unhelpful ArgumentNullException deep in static initialization, which a maintainer noted (comment) is hard to diagnose.

Fix

Constants.fs now checks whether the resolved home path is null/empty before calling Path.Combine, and raises a clear, actionable exception telling the user which environment variable to set, instead of crashing with an opaque null-reference-style error. This matches the maintainer's suggestion in the issue thread ("at least check homePath for null and throw a better exception").

This doesn't change behavior for the common case where HOME/USERPROFILE are set; it only improves the failure mode when they are missing.

Trade-offs

A true fix that makes Paket work without HOME/USERPROFILE at all was discussed but no viable alternative path-discovery mechanism was identified in the issue thread. This PR focuses on the maintainer-endorsed, incremental improvement: fail fast with a clear message.

Test Status

  • Added GetFolderPath raises helpful error when HOME and USERPROFILE are unset in tests/Paket.Tests/UtilsSpecs.fs (guarded by TESTSUITE_RUNS_ON_DOTNETCORE, since the affected code path only exists under #if DOTNETCORE).
  • dotnet build src/Paket.Core/Paket.Core.fsproj -c Release — succeeded (net461 + netstandard2.0).
  • dotnet test tests/Paket.Tests/Paket.Tests.fsproj -f net10.0 --filter "FullyQualifiedName~GetFolderPath" — 1/1 passed.
  • dotnet test tests/Paket.Tests/Paket.Tests.fsproj -f net10.0 --filter "FullyQualifiedName~UtilsSpecs" — 30 passed, 4 pre-existing failures (verified identical on master via git stash, unrelated to this change), 2 skipped.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38
Add regression test verifying the improved error message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
dsyme marked this pull request as ready for review September 27, 2026 17:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant