nvim-telescope / telescope-cheat.nvim

WIP integration
MIT License
115 stars 6 forks source link

Couldn't connect to sql database when running Telescope cheat fd #7

Open smjonas opened 2 years ago

smjonas commented 2 years ago

Hey, I wanted to try out this plugin but couldn't get it working (it should be installed correctly since require("telescope").extensions shows cheat as an installed extension).

Running Telescope cheat fd shows me this error message:

E5108: Error executing lua /home/jonas/.vim/plugged/sqlite.lua/lua/sqlite/defs.lua:667: sqlite  
.lua: couldn't connect to sql database, ERR:    

(with an empty error message)

Could you help me with this?

kkharji commented 2 years ago

🤔 interesting, are you on nightly? and does pervious commits work? try git checkout HEAD^ in telescope-cheat directory. Maybe recent changes to improve startuptime, factored this odd error

smjonas commented 2 years ago

I was on the stable 0.5 version, but I just tested it on the nightly from a few days ago and got the same problem.

The old version worked with git checkout HEAD^ . :smiley: . Once the database is created I can then switch to the latest version and I get no errors.

EDIT: it's not working since 888594e, the commit before that (7322a73) works

kkharji commented 2 years ago

The old version worked with git checkout HEAD^ .

To confirm https://github.com/nvim-telescope/telescope-cheat.nvim/commit/4a58b92fc70af622ddc115f843b0e552ca5bd6ea broke it?

EDIT: it's not working since 888594e, the commit before that (7322a73) works

Is it possible that you have an outdated sqlite.lua?

Thanks @jonasstr for investigating, I'm going to try to reproduced and switch to nightly later tonight.

smjonas commented 2 years ago

It was broken even one commit before 4a58b92 (888594e broke it). What I wrote about "it worked with git checkout HEAD^" was wrong.

I could reproduce it on 888594e after deleting the databases folder inside vim.fn.stdpath "data" .. "/databases", which is /home/jonas/.local/share/nvim for me.

I have the latest version of sqlite.lua (2bd7cda).

Thanks @jonasstr for investigating, I'm going to try to reproduced and switch to nightly later tonight.

Glad I can help :) Just to inform you, I could reproduce this on the stable version also.

younger-1 commented 2 years ago

Once the database is created I can then switch to the latest version and I get no errors.

I encountered the same error. This workaround works for me.

ghillb commented 2 years ago

Got the same error, with a fresh install. After creating the folder vim.fn.stdpath "data" .. "/databases" manually, it worked.

jaime10a commented 2 years ago

Im having the same issue. Im on Nvim 0.6 and have all the plugins updated.

Got the same error, with a fresh install. After creating the folder vim.fn.stdpath "data" .. "/databases" manually, it worked.

That worked perfectly:) In case anyone is wondering for nvim you have to create the directory $HOME/.local/share/nvim/databases

pmatulis commented 1 year ago

This bug has been open for a while. This seems like an easy fix.

genebean commented 8 months ago

Just ran into this too. FWIW, it seems that this is the bit that should be making the directory: https://github.com/nvim-telescope/telescope-cheat.nvim/blob/93f4af8240819833ba9c81c0947ee9fc94c93490/lua/telescope/_extensions/cheat/db.lua#L72-L75

That is called by https://github.com/nvim-telescope/telescope-cheat.nvim/blob/93f4af8240819833ba9c81c0947ee9fc94c93490/lua/telescope/_extensions/cheat.lua#L85-L87

Any idea what needs to be done to actually fix this?

genebean commented 8 months ago

FWIW, I added this to my init.lua before loading my plugins and everything works as expected, so I think the call to this same bit of code in the plugin isn't actually happening.

-- hack to deal with bug in telescope-cheat.nvim
-- https://github.com/nvim-telescope/telescope-cheat.nvim/issues/7
local cheat_dbdir = vim.fn.stdpath "data" .. "/databases"
if not vim.loop.fs_stat(cheat_dbdir) then
  vim.loop.fs_mkdir(cheat_dbdir, 493)
end