Skip to content

Use system temp directory for temporary font downloads instead of $HOME #63

@MariusStorhaug

Description

Install-NerdFont currently creates its temporary download directory under $HOME (i.e. $Env:USERPROFILE on Windows):

$tempPath = Join-Path -Path $HOME -ChildPath "NerdFonts-$guid"
if (-not (Test-Path -Path $tempPath -PathType Container)) {

$guid = (New-Guid).Guid
$tempPath = Join-Path -Path $HOME -ChildPath "NerdFonts-$guid"

If the command fails or is interrupted before the clean block runs, the temporary directory with downloaded archives persists in the user's home folder. This location is not subject to automatic cleanup by the OS (Disk Cleanup on Windows, tmpwatch/systemd-tmpfiles on Linux), so the leftover directories accumulate silently.

Request

Current experience

Temporary download artifacts are left in the user's home directory on failure. The user must manually discover and delete NerdFonts-<guid> folders.

Desired experience

Temporary files should reside under the system-designated temp directory ($Env:TEMP on Windows, /tmp on Linux/macOS). If the command fails, the OS or its cleanup utilities can reclaim the space automatically. The home directory remains clean.

Acceptance criteria

  • The temporary download directory is created under the appropriate system temp path, not $HOME
  • The GUID-based naming scheme can be retained or simplified, as long as collisions remain improbable
  • Existing cleanup logic in the clean block continues to work
  • No change in behavior when the command completes successfully

Related


Technical decisions

Temp path source: Use [System.IO.Path]::GetTempPath() or $Env:TEMP (Windows) / the equivalent on other platforms. Both are idiomatic. [System.IO.Path]::GetTempPath() is cross-platform by default.

Directory naming: Keep using New-Guid for uniqueness — it is fast, trivially unique, and already in use. No reason to change the naming scheme.


Implementation plan

  • Change the temp directory base path from $HOME to [System.IO.Path]::GetTempPath() in src/functions/public/Install-NerdFont.ps1
  • Verify cleanup in the clean block still removes the directory correctly
  • Test on Windows and (if CI supports it) Linux/macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions