Skip to content

[Windows] @elevate_as_needed decorator ignores .nonadmin marker when user is admin #453

@lrandersson

Description

@lrandersson

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

On Windows, when running as admin with a .nonadmin marker file present within the install directory, the new-style menu JSON files (those with $schema) create shortcuts in the system location (ProgramData) instead of the user location (AppData).

Expected behavior: The .nonadmin marker file should signal a user-mode install regardless of whether the process is elevated.

Current behavior:

  • Legacy code path (no $schema): Checks .nonadmin before deciding mode (which seems to work as expected)
  • New code path (with $schema): @elevate_as_needed decorator checks user_is_admin() first, passes _mode="system" without checking .nonadmin (which does not work as expected)

Reproduction (conda install spyder shows the bug):

  1. Create a conda environment with .nonadmin marker file within PREFIX
  2. Run conda install as an elevated process (e.g., "Run as Administrator")
  3. Install a package with new-style menu JSON ($schema present)
  4. Observe: shortcut created in %ProgramData% instead of %AppData%

Suspected location: menuinst/utils.py lines 509-517, the @elevate_as_needed decorator:

if user_is_admin():
   return func(*args, _mode="system", **kwargs)

This should check for .nonadmin before defaulting to system mode.

Conda Info

Conda Config

Conda list

Additional Context

The legacy menuinst code (_legacy/__init__.py lines 62-87) correctly checks .nonadmin before deciding the mode. The new code path should have consistent behavior.

This inconsistency causes issues when conda is invoked from an elevated process but the install is intended to be per-user (as signaled by .nonadmin).

Metadata

Metadata

Assignees

Labels

type::bugdescribes erroneous operation, use severity::* to classify the type

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions