Add install scope marker for all-users installation#3050
Conversation
- Introduced a new constant for the all-users installation marker file. - Implemented logic to check if the installation was performed for all users. - Updated the config file path retrieval to depend on the installation scope. - Added procedures in the installer script to create and remove the all-users marker during installation and uninstallation.
There was a problem hiding this comment.
PR Summary:
This PR introduces an install-scope marker file to explicitly determine config file location instead of relying on process elevation. The admin installer creates a marker file (install_all_users) in %ProgramData%\pyRevit\, which the CLI reads to choose between user-specific (%AppData%) and all-users (%ProgramData%) config paths. This fixes issue #2549 where per-user installs run elevated incorrectly used ProgramData config.
Review Summary:
Reviewed the install-scope marker implementation in C# and Inno Setup installer scripts. The approach correctly addresses the issue by decoupling config path selection from elevation status. Validated against repository coding standards including IronPython 2.7.12 compatibility and defensive programming patterns. One medium-severity issue identified regarding silent failure handling during marker creation that could cause user confusion.
Follow-up suggestions:
- Added a message box warning when the installer fails to create the all-users marker file. - Enhanced logging to provide clearer feedback during installation process.
There was a problem hiding this comment.
Pull request overview
This PR switches pyRevit’s config root selection from an elevation-based heuristic to an explicit “install scope” marker created by the admin installer, ensuring consistent behavior between per-user and all-users installs and fixing issues like #2549.
Changes:
- Add an
install_all_usersmarker concept toPyRevitConstsand replace elevation-based logic inConfigFilePathwith marker-based detection under%ProgramData%\pyRevit\. - Update the admin Inno Setup script (
pyrevit-admin.iss) to create the marker at post-install and remove it at post-uninstall. - Keep existing config-handling code (
PyRevitConfigs,PyRevitConfig) usingPyRevitConsts.ConfigFilePath, so behavior is now driven solely by the marker.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitConsts.cs | Introduces the install-scope marker constant and cached IsInstallAllUsers() helper, and reworks ConfigFilePath to switch between %AppData% and %ProgramData% based on the marker. |
| release/pyrevit-admin.iss | Adds installer/uninstaller hooks to create and remove the install_all_users marker in %ProgramData%\pyRevit, enabling the new install-scope behavior. |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1553-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1612-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1624-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1738-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1743-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1829-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1937-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+1956-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2005-wip |
|
📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2008-wip |
|
📦 New public release are available for 6.0.0.26032+2040 |
|
📦 New public release are available for 6.0.0.26032+2040 |
PR: Explicit config path — install scope marker (Phase 2)
Fixes #2549 (config/seed): per-user installs always use user config even when run elevated; all-users installs use ProgramData.
Summary
Config file location (user vs ProgramData) is now driven by an explicit install-scope marker, not by process elevation. The admin installer creates a marker file; the CLI reads it to choose the config root. Per-user installs never create the marker, so they always use
%AppData%\pyRevit\for config regardless of elevation.Changes
1.
dev/pyRevitLabs/pyRevitLabs.PyRevit/PyRevitConsts.csInstallAllUsersMarkerFileName = "install_all_users"(file under%ProgramData%\pyRevit\).IsInstallAllUsers(): New static helper that checks for the marker file atEnvironment.GetFolderPath(CommonApplicationData)\pyRevit\install_all_users. Result is cached in_isInstallAllUsers.ConfigFilePath: No longer usesUserEnv.IsRunAsElevated(). Now:PyRevitLabsConsts.PyRevitProgramDataPath.PyRevitLabsConsts.PyRevitPath.2.
release/pyrevit-admin.issCurStepChanged(ssPostInstall), create%ProgramData%\pyRevit\and write the fileinstall_all_userswith contentAllUsers. Only the admin installer does this; per-user installer (pyrevit.iss) is unchanged and does not create the marker.CurUninstallStepChanged(usPostUninstall), delete the marker file so a later per-user install does not see an all-users scope.3.
PyRevitConfigs.csGetConfigFile()already usesPyRevitConsts.ConfigFilePath; the only place that switches between user and ProgramData isConfigFilePath, which now uses the marker.Verification
%AppData%\pyRevit\(no marker → user config).%ProgramData%\pyRevit\;pyrevit envand clones use that config.Assumptions
Environment.GetFolderPath(CommonApplicationData)so it works on all supported machines.