Skip to content

Conversation

bennyyang11
Copy link
Contributor

Description, Motivation and Context

This PR fixes a critical bug in the Ollama installer for Windows systems. On Windows, files must be explicitly closed before they can be executed. Without this fix, attempting to run the Ollama installer fails because the temporary installer file is still open, causing file access errors.

The Problem:
When downloading and installing Ollama on Windows, the temporary installer file was being executed immediately after writing without closing the file handle first. Windows locks open files and prevents execution, causing the installation to fail.

The Solution:
Added an explicit tmpFile.Close() call before attempting to execute the installer. This ensures the file handle is properly released and the installer can be executed successfully.

Impact:

  • Fixes Ollama installation failures on Windows
  • Ensures proper file handling across platforms
  • No impact on Linux/macOS systems

Checklist

  • New and existing tests pass locally with introduced changes.
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • Yes
  • No

Windows requires files to be closed before they can be executed. This fix
ensures the temporary installer file is properly closed before attempting
to run it, preventing file access errors on Windows systems.
@bennyyang11 bennyyang11 added the type::feature New feature or request label Oct 10, 2025
cursor[bot]

This comment was marked as outdated.


// Close the file before executing it (required on Windows)
tmpFile.Close()

Copy link

Choose a reason for hiding this comment

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

Bug: Temporary File Leak Causes Deletion Failures

Removing defer tmpFile.Close() introduces a resource leak. If errors occur during download, HTTP status check, or writing the installer, the temporary file handle remains open. On Windows, this can prevent os.Remove from successfully deleting the file.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type::feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant