Skip to content

Defer machine font directory creation#4

Merged
Graphixa merged 1 commit into
Graphixa:mainfrom
Magniquick:fix-user-scope-font-manager
Apr 24, 2026
Merged

Defer machine font directory creation#4
Graphixa merged 1 commit into
Graphixa:mainfrom
Magniquick:fix-user-scope-font-manager

Conversation

@Magniquick
Copy link
Copy Markdown
Contributor

Summary

  • stop Linux and macOS font manager initialization from creating machine font directories unconditionally
  • create the selected target font directory lazily during install instead
  • fixes user-scope installs failing when /usr/local/share/fonts or /Library/Fonts is not writable or does not exist

Verification

  • go test ./internal/platform
  • go run . install google.google-sans --scope user --accept-agreements --accept-defaults --debug
    • confirmed the command used /home/magni/.local/share/fonts
    • installed 8 Google Sans variants successfully without requiring /usr/local/share/fonts

Copilot AI review requested due to automatic review settings April 19, 2026 14:39
Copy link
Copy Markdown

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 prevents Linux and macOS font manager initialization from eagerly creating machine-wide font directories, and instead creates the chosen target directory lazily during installation—fixing user-scope installs when system directories are missing or not writable.

Changes:

  • Remove unconditional ensureDir for machine font directories during NewFontManager() on Linux/macOS.
  • Ensure the selected targetDir exists inside InstallFont() before copying the font.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
internal/platform/linux.go Stops eager creation of /usr/local/share/fonts; ensures the chosen install directory exists during install.
internal/platform/darwin.go Stops eager creation of /Library/Fonts; ensures the chosen install directory exists during install.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

if err := ensureDir(targetDir); err != nil {
return fmt.Errorf("failed to ensure font directory exists: %w", err)
Comment on lines +73 to +75
if err := ensureDir(targetDir); err != nil {
return fmt.Errorf("failed to ensure font directory exists: %w", err)
}
}

if err := ensureDir(targetDir); err != nil {
return fmt.Errorf("failed to ensure font directory exists: %w", err)
Comment on lines +72 to +74
if err := ensureDir(targetDir); err != nil {
return fmt.Errorf("failed to ensure font directory exists: %w", err)
}
Copy link
Copy Markdown
Owner

@Graphixa Graphixa left a comment

Choose a reason for hiding this comment

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

Thanks @Magniquick

This fixes user-scope installs failing when system font dirs are missing/unwritable by deferring directory creation until InstallFont() (and only for the selected target dir).

Merging.

@Graphixa Graphixa merged commit c93cac2 into Graphixa:main Apr 24, 2026
10 of 11 checks passed
Graphixa added a commit that referenced this pull request Apr 24, 2026
Builds on Magniquick's PR #4 by keeping Linux/macOS FontManager initialization side-effect free (no eager user-dir creation) and including scope + target path in ensureDir failures for easier troubleshooting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants