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

sqlite3.OperationalError: unable to open database file, looks like failure to mkdir io.datasette.llm? #137

Open
michaelrhanson opened this issue Jul 28, 2023 · 1 comment

Comments

@michaelrhanson
Copy link

michaelrhanson commented Jul 28, 2023

On a fresh install of llm v0.6 running on MacOS 13.4.1, installed from homebrew, I received

  File "/opt/homebrew/bin/llm", line 33, in <module>
    sys.exit(load_entry_point('llm==0.6', 'console_scripts', 'llm')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.6/libexec/lib/python3.11/site-packages/llm/cli.py", line 372, in logs_turn_off
    path.touch()
  File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 1108, in touch
    fd = os.open(self, flags, mode)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<redacted>/Library/Application Support/io.datasette.llm/logs-off'

... or a similar error, after every prompt. I was unable to "llm logs off" because of a similar error ((FileNotFoundError: [Errno 2] No such file or directory: '/Users/<redacted>/Library/Application Support/io.datasette.llm/logs-off')).

On investigation it looked like the problem was that io.datasette.llm didn't exist and wasn't being created. I mkdir'ed it and the problems went away.

@gtrefalt
Copy link

I can confirm this bug, the same happens in linux. If you do not set the key with llm keys set the io.datasette.llm folder is not created and then when llm tries to log you get this error.

I guess the problem would be solved with log_path.parent.mkdir(parents=True, exist_ok=True) wherever the log_path is first created.

PS: @simonw thanks for this great library, loving it :)

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