fix(cli): expand TEMP and env paths for clone/image deployment#3453
Merged
Conversation
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>
Contributor
Author
Contributor
There was a problem hiding this comment.
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. |
…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>
Contributor
|
📦 New work-in-progress (wip) builds are available for 6.5.1 |
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.
Summary
TEMPis stored as unexpanded%LOCALAPPDATA%\Temp(reported on CLI 6.5.0 admin signed builds)%VAR%path expansion viaCommonUtils.ExpandEnvironmentPathandGetUserTempDirectory--destand local image paths inDeployFromImage/DeployFromRepoGetEnvironmentVariable(TEMP)in clone, extensions, and runner code pathsRoot cause
Environment.ExpandEnvironmentVariables(%TEMP%)returns%LOCALAPPDATA%\Tempwithout expanding nested variables, so zip staging and deployment copy operate on invalid paths.Test plan
CommonUtilsPathTests(3 tests) pass on net48, includingTEMP=%LOCALAPPDATA%\Tempstaging scenarioPyRevitInstallScopeTestsregression passTEMP=%LOCALAPPDATA%\Temp, runpyrevit clone master --deploy=basepublic --dest=C:\pyRevitTestpyrevit clone master --dest=%LOCALAPPDATA%\pyRevit\clones