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

Allow XDG user directories #4382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noahgitsham
Copy link
Contributor

@noahgitsham noahgitsham commented May 12, 2024

Addresses #228. This is my first time writing go, please feel free to correct any bad code. *

This change defaults to using the XDG Base Directory Specification for the history file and private key files which are currently generated in the .ollama directory.
It will still use .ollama if it exists (hence shouldn't break current setups), but allows use of $XDG_DATA_HOME/ollama instead.

I am unsure if/where these should be moved to, do they also belong in XDG_DATA_HOME?

I'm also unsure if I need to add/change anything here, I'm assuming my changes don't even affect windows, so no?

I simply searched the repo for ".ollama" to find stuff to change, please let me know if I missed anything.
I have only tested and designed this to work on Linux, let me know if this doesn't work for macOS.

*A styleguide and/or contributing document would be great #2231

@tecosaur
Copy link

I am unsure if/where these should be moved to, do they also belong in XDG_DATA_HOME?

Two comments on XDG organization:

  • Surely config.json should go in XDG_CONFIG_HOME?
  • Log and history files should arguably go in XDG_STATE_HOME

@noahgitsham
Copy link
Contributor Author

It's hard to tell what these files are for, I haven't been following development closely. They seem to both be part of incomplete (?) desktop apps, it would be great if someone who worked on this could provide some clarification.

Surely config.json should go in XDG_CONFIG_HOME?

By name alone that would make sense, though in my brief search I think it's some desktop app configuration rather than user configuration. Judging by this commit message, it seems like it isn't currently implemented for MacOS or Linux.

Log and history files should arguably go in XDG_STATE_HOME

Ah yes, of couse, though this again seems to not be fully implemented.

I think we need some util functions for getting all these paths in an OS agnostic way, so that future implementation can easily conform to the spec.

I realise MacOS and Windows do not follow the XDG spec. This shows examples, and this library appears to have implemented all of this already. I'm happy to make the functions if introducing external dependencies is (understandably) off the table for this project.

All this would be a complete alternative to the current .ollama directory implementation. If we want to completely do away with .ollama and not break current setups we could also make a migration function to move everything into the right place. This would probably be worth doing if there are plans to make an Ollama desktop app.

It would be nice to know what core contributors think about this.

P.S. Funny seeing you here, really excited by your work on org-mode.

@noahgitsham
Copy link
Contributor Author

Sorry for the walls of text, I realise this isn't pleasant to read through.

Basic questions for core contributors:

  • Should Ollama adhere to system specific directory specs or do you not want to change from the current .ollama directory?
  • If so, should it adhere to these by default?

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.

None yet

2 participants