Skip to content

fix(cli): expand TEMP and env paths for clone/image deployment#3453

Merged
jmcouffin merged 2 commits into
developfrom
fix/temp-path-resolution
Jun 24, 2026
Merged

fix(cli): expand TEMP and env paths for clone/image deployment#3453
jmcouffin merged 2 commits into
developfrom
fix/temp-path-resolution

Conversation

@jmcouffin

Copy link
Copy Markdown
Contributor

Summary

  • Fixes clone-from-image failures when TEMP is stored as unexpanded %LOCALAPPDATA%\Temp (reported on CLI 6.5.0 admin signed builds)
  • Adds recursive %VAR% path expansion via CommonUtils.ExpandEnvironmentPath and GetUserTempDirectory
  • Expands --dest and local image paths in DeployFromImage / DeployFromRepo
  • Replaces raw GetEnvironmentVariable(TEMP) in clone, extensions, and runner code paths

Root cause

Environment.ExpandEnvironmentVariables(%TEMP%) returns %LOCALAPPDATA%\Temp without expanding nested variables, so zip staging and deployment copy operate on invalid paths.

Test plan

  • CommonUtilsPathTests (3 tests) pass on net48, including TEMP=%LOCALAPPDATA%\Temp staging scenario
  • PyRevitInstallScopeTests regression pass
  • Manual: set TEMP=%LOCALAPPDATA%\Temp, run pyrevit clone master --deploy=basepublic --dest=C:\pyRevitTest
  • Manual: pyrevit clone master --dest=%LOCALAPPDATA%\pyRevit\clones

Recursive environment expansion fixes clone-from-image when TEMP is stored as unexpanded %LOCALAPPDATA%\\Temp. Centralizes temp resolution, expands --dest and local image paths, and adds unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jmcouffin
jmcouffin requested a review from Copilot June 24, 2026 17:09
@jmcouffin jmcouffin added the Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem] label Jun 24, 2026
@pyrevitlabs pyrevitlabs deleted a comment from devloai Bot Jun 24, 2026
@jmcouffin

Copy link
Copy Markdown
Contributor Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes pyRevit CLI deployment/clone failures caused by %TEMP% (and other paths) containing nested unexpanded environment variables (e.g. TEMP=%LOCALAPPDATA%\Temp) by introducing recursive %VAR% expansion and applying it to clone/image staging and destination paths.

Changes:

  • Added recursive environment-variable expansion utilities (CommonUtils.ExpandEnvironmentPath, CommonUtils.GetUserTempDirectory).
  • Updated clone/image deployment, extensions DB download, and runner working directory to use expanded temp and expanded user-supplied paths (--dest, local image path).
  • Added new unit tests covering nested expansion and a clone-from-image staging scenario.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dev/pyRevitLabs/pyRevitLabs.Common/CommonUtils.cs Adds recursive environment-variable path expansion + temp directory resolver.
dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs Switches UserTemp to use the new expansion behavior.
dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitClones.cs Expands --dest/image paths and uses expanded TEMP for staging/download.
dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitExtensions.cs Uses expanded TEMP for extension metadata download destination.
dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitRunner.cs Uses expanded TEMP for runner execution working directory.
dev/pyRevitLabs/pyRevitLabs.UnitTests/pyRevitLabs.UnitTests.CommonUtilsPath.cs Adds unit tests for nested expansion and deploy-from-image staging.

Comment thread dev/pyRevitLabs/pyRevitLabs.Common/CommonUtils.cs
Comment thread dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs Outdated
…lete

Address Copilot review: centralize UserTemp on GetUserTempDirectory and use Path.GetTempPath when env expansion still contains % tokens.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jmcouffin
jmcouffin merged commit dc1053c into develop Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.5.1

@jmcouffin
jmcouffin deleted the fix/temp-path-resolution branch June 24, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants