Skip to content

llama-run: Fix model download on Windows#15988

Merged
ericcurtin merged 3 commits intoggml-org:masterfrom
npopov-vst:np/llama-run-windows-model-download-fix
Sep 15, 2025
Merged

llama-run: Fix model download on Windows#15988
ericcurtin merged 3 commits intoggml-org:masterfrom
npopov-vst:np/llama-run-windows-model-download-fix

Conversation

@npopov-vst
Copy link
Copy Markdown
Contributor

llama-run: Fix model download on Windows

  • fix SSL error (SSL peer certificate or SSH remote key was not OK)
  • fix program crash on std::filesystem::rename

 * fix SSL error (SSL peer certificate or SSH remote key was not OK)
 * fix program crash on std::filesystem::rename
@ericcurtin
Copy link
Copy Markdown
Collaborator

Thanks for the fix

I am going to split out the curl stuff in common/arg.cpp to a common/curl.cpp class

We should try and consolidate the llama-run specific stuff more in common/arg.cpp to help avoid things like this.

Comment thread tools/run/run.cpp Outdated
Comment thread tools/run/run.cpp Outdated
if (!output_file.empty()) {
// Explicitly close file in order to release lock
out.close();
std::filesystem::rename(output_file_partial, output_file);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would prefer if we put 412-447 into it's own function and relied on RAII to close the file. We would call this function in init and then:

if (!output_file.empty()) {
    std::filesystem::rename(output_file_partial, output_file);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, thanks! Yeah, I have created a separated method to utilize RAII.

@ericcurtin ericcurtin requested a review from Copilot September 14, 2025 20:33
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 fixes two critical issues affecting model downloads on Windows in the llama-run tool: SSL certificate verification errors and crashes during file operations. The changes reorganize the download logic to use temporary files properly and add Windows-specific SSL configuration.

  • Restructures the HttpClient class to handle temporary file operations in the public init method
  • Adds Windows-specific SSL configuration to use native certificate authority
  • Moves file renaming from download completion to the main download flow

Comment thread tools/run/run.cpp Outdated
}

if (!output_file.empty()) {
std::filesystem::rename(output_file_partial, output_file);
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

The std::filesystem::rename call lacks error handling. On Windows, this operation can fail due to file permissions, antivirus software, or if the target file is still open. Consider wrapping this in a try-catch block and providing appropriate error handling or retry logic.

Suggested change
std::filesystem::rename(output_file_partial, output_file);
try {
std::filesystem::rename(output_file_partial, output_file);
} catch (const std::filesystem::filesystem_error& e) {
printe("Error: Failed to rename '%s' to '%s': %s\n", output_file_partial.c_str(), output_file.c_str(), e.what());
return -1;
}

Copilot uses AI. Check for mistakes.
Comment thread tools/run/run.cpp Outdated
CURL * curl = nullptr;
struct curl_slist * chunk = nullptr;


Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

Trailing whitespace on line 476 should be removed to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@ericcurtin ericcurtin left a comment

Choose a reason for hiding this comment

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

Nice and clean

@ericcurtin
Copy link
Copy Markdown
Collaborator

Build failures unrelated

@ericcurtin ericcurtin merged commit 28c39da into ggml-org:master Sep 15, 2025
47 of 48 checks passed
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
* llama-run: Fix model download on Windows
 * fix SSL error (SSL peer certificate or SSH remote key was not OK)
 * fix program crash on std::filesystem::rename

* llama-run: create a separate method to utilize RAII

* llama-run: handle rename exception
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
* llama-run: Fix model download on Windows
 * fix SSL error (SSL peer certificate or SSH remote key was not OK)
 * fix program crash on std::filesystem::rename

* llama-run: create a separate method to utilize RAII

* llama-run: handle rename exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants