Skip to content

Add install scope marker for all-users installation#3050

Merged
jmcouffin merged 2 commits intodevelopfrom
install-scope-marker
Feb 1, 2026
Merged

Add install scope marker for all-users installation#3050
jmcouffin merged 2 commits intodevelopfrom
install-scope-marker

Conversation

@jmcouffin
Copy link
Copy Markdown
Contributor

@jmcouffin jmcouffin commented Feb 1, 2026

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.cs

  • Install scope marker: Added constant InstallAllUsersMarkerFileName = "install_all_users" (file under %ProgramData%\pyRevit\).
  • IsInstallAllUsers(): New static helper that checks for the marker file at
    Environment.GetFolderPath(CommonApplicationData)\pyRevit\install_all_users. Result is cached in _isInstallAllUsers.
  • ConfigFilePath: No longer uses UserEnv.IsRunAsElevated(). Now:
    • If the all-users marker exists → config root = PyRevitLabsConsts.PyRevitProgramDataPath.
    • Otherwise → config root = PyRevitLabsConsts.PyRevitPath.

2. release/pyrevit-admin.iss

  • Install: In CurStepChanged(ssPostInstall), create %ProgramData%\pyRevit\ and write the file install_all_users with content AllUsers. Only the admin installer does this; per-user installer (pyrevit.iss) is unchanged and does not create the marker.
  • Uninstall: In CurUninstallStepChanged(usPostUninstall), delete the marker file so a later per-user install does not see an all-users scope.

3. PyRevitConfigs.cs

  • No code changes. GetConfigFile() already uses PyRevitConsts.ConfigFilePath; the only place that switches between user and ProgramData is ConfigFilePath, which now uses the marker.

Verification

Scenario Expected
Per-user install run elevated Config and clones under %AppData%\pyRevit\ (no marker → user config).
Admin install Marker exists; config under %ProgramData%\pyRevit\; pyrevit env and clones use that config.
Admin uninstall Marker removed; subsequent per-user use uses user config.
No marker + elevated process CLI uses user config (no elevation override).

Assumptions

- 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.
@jmcouffin jmcouffin self-assigned this Feb 1, 2026
@jmcouffin jmcouffin added Installer Issues related to the pyRevit installer [subsystem] Command Line Utility (CLI) Issues related to pyRevit CLI tool [subsystem] labels Feb 1, 2026
@jmcouffin jmcouffin requested a review from Copilot February 1, 2026 15:42
Copy link
Copy Markdown
Contributor

@devloai devloai bot left a comment

Choose a reason for hiding this comment

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

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:

  • @devloai fix the silent failure notification issue
  • @devloai add unit tests for the IsInstallAllUsers() method to verify marker detection logic

- 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.
@jmcouffin jmcouffin merged commit b896c2a into develop Feb 1, 2026
@jmcouffin jmcouffin deleted the install-scope-marker branch February 1, 2026 15:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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_users marker concept to PyRevitConsts and replace elevation-based logic in ConfigFilePath with 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) using PyRevitConsts.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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1553-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1612-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1624-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1738-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1743-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1829-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 5.3.1.26032+1937-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+1956-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2005-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New work-in-progress (wip) builds are available for 6.0.0.26032+2008-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New public release are available for 6.0.0.26032+2040

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

📦 New public release are available for 6.0.0.26032+2040

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] Installer Issues related to the pyRevit installer [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CLI, Path does not point to a valid clone

2 participants