Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows install can't download Ollama #318

Open
zpar-ky opened this issue Jul 14, 2024 · 3 comments
Open

Windows install can't download Ollama #318

zpar-ky opened this issue Jul 14, 2024 · 3 comments

Comments

@zpar-ky
Copy link

zpar-ky commented Jul 14, 2024

Describe the bug
downloadOllama.js windows absolute url 404's.

To Reproduce

  • First time installing - installed as admin
  • Open Reor and immediately get this error message:
Error: Failed to start Ollama: exec error: Error: Command failed: "C:\Program Files\Reor\resources\binaries\ollama-windows-amd64.exe" serve The system cannot find the path specified. 
Stack Trace: Error: Failed to start Ollama: exec error: 
Error: Command failed: "C:\Program Files\Reor\resources\binaries\ollama-windows-amd64.exe" serve The system cannot find the path specified. 
at Ba.serve (C:\Program Files\Reor\resources\app.asar\dist-electron\main\index.js:218:4336) 
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 
at async Ba.init (C:\Program Files\Reor\resources\app.asar\dist-electron\main\index.js:218:2623) 
at async C:\Program Files\Reor\resources\app.asar\dist-electron\main\index.js:242:1337

I don't expect the following to work either, but here's what I get when trying to add a local llm:

llama3:latest download failed: Error: Error invoking remote method 'pull-ollama-model': TypeError: Cannot read properties of undefined (reading 'pull') 
Stack Trace: Error: Error invoking remote method 'pull-ollama-model': TypeError: Cannot read properties of undefined (reading 'pull')

cursory investigation leads me to the downloadOllama script and it looks for a exe but ollama switched to serving zips at some point for windows.

I downloaded the zip manually and tossed the contents in resources/binaries and things appear to be working. I renamed the exe to ollama-windows-amd64.exe.

Desktop (please complete the following information):

  • OS: Win11 23H2 22631.3880
  • Hardware: Ryzen 7, RTX 40 something
  • Version 0.2.15
Copy link

greptile-apps bot commented Jul 14, 2024

To resolve the issue with downloading Ollama on Windows, update the downloadOllama.js script to handle the new zip format for Windows binaries. Here are the specific steps:

  1. Modify the binariesInfo object in scripts/downloadOllama.js to point to the zip file:
win32: {
  url: "https://github.com/ollama/ollama/releases/download/v0.1.48/ollama-windows-amd64.zip",
  path: "../binaries/win32/ollama-windows-amd64.zip",
},
  1. Update the downloadIfMissing function to extract the zip file after downloading:
const unzip = require('unzipper');

function downloadIfMissing(platformKey) {
  const info = binariesInfo[platformKey];
  const filePath = path.join(__dirname, info.path);
  ensureDirectoryExistence(filePath);

  fs.access(filePath, fs.constants.F_OK, (err) => {
    if (err) {
      console.log(`Downloading ${platformKey} Ollama binary...`);
      const request = https.get(info.url, (response) => {
        if (response.statusCode === 200) {
          const file = fs.createWriteStream(filePath);
          response.pipe(file);
          file.on('finish', () => {
            file.close(async () => {
              console.log(`Downloaded ${platformKey} Ollama binary.`);
              if (platformKey === 'win32') {
                await fs.createReadStream(filePath).pipe(unzip.Extract({ path: path.dirname(filePath) }));
                fs.unlinkSync(filePath); // Remove the zip file after extraction
              } else {
                setExecutable(filePath);
              }
            });
          });
        } else if (response.statusCode === 302 || response.statusCode === 301) {
          console.log(`Redirection to ${response.headers.location}`);
          binariesInfo[platformKey].url = response.headers.location;
          downloadIfMissing(platformKey);
        } else {
          console.error(`Failed to download ${platformKey} binary. Status code: ${response.statusCode}`);
        }
      });
      request.on('error', (error) => {
        console.error(`Error downloading ${platformKey} binary: ${error.message}`);
      });
    } else {
      console.log(`${platformKey} Ollama binary already exists.`);
      if (platformKey !== 'win32') {
        setExecutable(filePath);
      }
    }
  });
}
  1. Ensure the OllamaService in electron/main/llm/models/Ollama.ts correctly references the extracted executable path for Windows:
case 'win32':
  exeName = 'ollama-windows-amd64.exe';
  exeDir = app.isPackaged
    ? path.join(process.resourcesPath, 'binaries')
    : path.join(app.getAppPath(), 'binaries', 'win32');
  break;

These changes should address the issue with downloading and extracting the Ollama binary on Windows.

References

/scripts/downloadOllama.js
/electron/main/llm/models/Ollama.ts
/electron/main/index.ts

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Ask Greptile · Edit Issue Bot Settings

@zpar-ky
Copy link
Author

zpar-ky commented Jul 14, 2024

Is that an AI written response or a known issue at the moment lol

@weilirs
Copy link
Collaborator

weilirs commented Jul 15, 2024

It's an AI. I am not using Windows, sorry I can't help you with that...

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

No branches or pull requests

2 participants