Skip to content

Use $INSTDIR\tmp as the temporary directory for EXE to avoid Windows Defender errors#1247

Merged
marcoesters merged 4 commits into
conda:mainfrom
marcoesters:exe-conda-standalone-temp
May 27, 2026
Merged

Use $INSTDIR\tmp as the temporary directory for EXE to avoid Windows Defender errors#1247
marcoesters merged 4 commits into
conda:mainfrom
marcoesters:exe-conda-standalone-temp

Conversation

@marcoesters

Copy link
Copy Markdown
Contributor

Description

Use $INSTDIR\tmp as the temporary directory to avoid Windows Defender errors.

When conda-standalone is called, it extracts itself into a temporary directory. On Windows, this is done using the GetTempPathW function, which looks for the %TMP% environment variable first, which defaults to %LOCALAPPDATA%\Temp.

Windows Defender may disallow using the user temporary directory for the expanded binary (see #1243), but does allow them to be extracted into different directories. A natural location for such as "local" temporary directory is the installation directory as is already done in the SH installer: https://github.com/conda/constructor/blob/7cbad1abd101078059cd54db28a24fa5ba9520c5/constructor/header.sh

Closes #1243

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label May 26, 2026
@github-project-automation github-project-automation Bot moved this to 🆕 New in 🔎 Review May 26, 2026
@marcoesters
marcoesters marked this pull request as ready for review May 27, 2026 14:09
@marcoesters
marcoesters requested a review from a team as a code owner May 27, 2026 14:09
lrandersson
lrandersson previously approved these changes May 27, 2026

@lrandersson lrandersson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this looks good. I had some "concerns" initially about user-supplied scripts and use of %TMP% but I think that won't be an issue.

# being extracted into LOCALAPPDATA
# See https://github.com/conda/constructor/issues/1243
StrCpy $TmpDir "$INSTDIR\tmp"
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("TMP", "$TmpDir")'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just for consistency here we write $TmpDir but further down we write ${TmpDir}.

@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Approved in 🔎 Review May 27, 2026
Comment thread constructor/nsis/main.nsi.tmpl Outdated
@marcoesters
marcoesters merged commit 46a163d into conda:main May 27, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🏁 Done in 🔎 Review May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Windows install fails due to WDAC

3 participants