feat: add configurable temp directory to resolve Windows access denied errors#629
Open
sergio-sisternes-epam wants to merge 7 commits intomicrosoft:mainfrom
Open
Conversation
Add `temp-dir` configuration key so users can override the system temporary directory used during apm install. This resolves [WinError 5] Access is denied errors in corporate Windows environments where endpoint security restricts %TEMP%. - Add get_temp_dir(), set_temp_dir(), get_apm_temp_dir() to config module - Resolution order: APM_TEMP_DIR env var > config file > system default - Wire all tempfile.mkdtemp/TemporaryDirectory call sites - Catch PermissionError/OSError in download path with actionable message - Add 51 new tests covering config, CLI, and error handling - Update CLI reference docs, skills resource, and CHANGELOG Fixes microsoft#624 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a user-configurable temporary directory override (env var + persisted config + CLI wiring) so apm install and other operations can avoid locked-down %TEMP% locations in corporate Windows environments.
Changes:
- Introduces
get_temp_dir(),set_temp_dir(), andget_apm_temp_dir()withAPM_TEMP_DIR> config file > system default resolution. - Wires
temp-dirintoapm configshow/get/set and routes temp creation sites to use the effective temp directory. - Adds unit tests + updates docs and
CHANGELOG.mdto document the new configuration key.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/apm_cli/config.py |
Adds temp-dir config getters/setters and effective temp dir resolution logic. |
src/apm_cli/commands/config.py |
Exposes temp-dir via apm config show/get/set flows. |
src/apm_cli/deps/github_downloader.py |
Uses configurable temp dir for git temp work; adds access-denied error messaging. |
src/apm_cli/bundle/unpacker.py |
Extract temp dir for bundle unpacking now respects configured temp base. |
src/apm_cli/runtime/manager.py |
Embedded runtime scripts now run in temp dirs under the configured base. |
src/apm_cli/commands/update.py |
Update installer temp script is created under the configured temp base. |
tests/unit/test_github_downloader_temp_dir.py |
Adds tests around access-denied handling in subdirectory downloads. |
tests/unit/test_config_command.py |
Adds tests for config display + config/temp-dir resolution helpers + CLI config get/set temp-dir. |
docs/src/content/docs/reference/cli-commands.md |
Documents temp-dir in CLI reference and usage examples. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Updates skill resource command list to mention temp-dir. |
CHANGELOG.md |
Adds an Unreleased entry for the new temp-dir configuration key. |
- Move mkdtemp() inside try block so PermissionError is caught (microsoft#629) - Narrow error handler to check failing path is under temp_dir - Differentiate "does not exist" vs "not a directory" in set_temp_dir - Log resolved path in success message, not raw input - Fix tests to trigger PermissionError from mkdtemp (realistic path) - Fix test temp dir leaks using tmp_path fixture - Update CHANGELOG to reference PR microsoft#629 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel
approved these changes
Apr 9, 2026
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.
Description
Add
temp-dirconfiguration key so users can override the system temporary directory used duringapm install. This resolves[WinError 5] Access is deniederrors in corporate Windows environments where endpoint security or Group Policy restricts access to%TEMP%.Fixes #624
Changes
src/apm_cli/config.py-- Addget_temp_dir(),set_temp_dir(),get_apm_temp_dir()with resolution chain:APM_TEMP_DIRenv var > config file > system defaultsrc/apm_cli/commands/config.py-- Wiretemp-dirintoset/get/display subcommandssrc/apm_cli/deps/github_downloader.py-- Useget_apm_temp_dir()at all 4 temp creation sites + catchPermissionError/OSErrorwith actionable messagesrc/apm_cli/bundle/unpacker.py,runtime/manager.py,commands/update.py-- Wiredir=get_apm_temp_dir()at remaining temp sitesUsage
Type of change
Testing