telescope-smart-history.nvim
telescope-smart-history.nvim copied to clipboard
sqlite.lua doesn't seem to work with this.
NVIM v0.6.0 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Latest version of all the lua libraries.
E5108: Error executing lua ...m/site/pack/packer/start/sqlite.lua/lua/sqlite/utils.lua:252: loop or previous error loading module 'sqlite.tbl'
stack traceback:
[C]: in function 'require'
...m/site/pack/packer/start/sqlite.lua/lua/sqlite/utils.lua:252: in function '__index'
...nvim/site/pack/packer/start/sqlite.lua/lua/sqlite/db.lua:637: in function 'tbl'
...history.nvim/lua/telescope/_extensions/smart_history.lua:34: in function 'init'
...r/start/telescope.nvim/lua/telescope/actions/history.lua:76: in function 'handler'
...ker/start/telescope.nvim/lua/telescope/actions/state.lua:47: in function 'get_current_history'
...cker/start/telescope.nvim/lua/telescope/actions/init.lua:184: in function <...cker/start/telescope.nvim/lua/telescope/actions/init.lua:183>
...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:23: in function 'key_func'
...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:236: in function 'execute_keymap'
This is my reduced packer config:
require('packer').startup(function(use)
-- My plugins here
use 'wbthomason/packer.nvim'
use 'nvim-telescope/telescope.nvim'
use {
"nvim-telescope/telescope-smart-history.nvim",
config = function()
require"telescope".load_extension("smart_history")
end,
requires = {"tami5/sqlite.lua"}
}
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end)
Telescope setup:
require("telescope").setup {
defaults = {
wrap_results = true,
history = {
path = '~/.local/share/nvim/databases/telescope_history.sqlite3',
limit = 100
}
}
}
🤔 that's odd, couldn't reproduce. I'm on NVIM v0.7.0-dev
So...I was able to track it down.
If you manage to in some way install telescope-smart-history and have not yet gotten sqlite.lua working (if, for example, you don't have the sqlite binaries on your machine when you first install it), then telescope-smart-history will create a garbage sqlite file.
And from that point on, it will fail even if you get your machine set up as intended until you delete that garbage file.
Well done @fireboy1919, Interesting bug, any ideas to prevent it?
BTW, I also produced this error with telescope-frecency
This seems like something that should actually be built into sqlite.lua, but I can think of two defensive approaches that would prevent this bug:
- If the initial attempt to create a sqlite instance fails, then the library could aggressively clean up after itself.
This would unfortunately mean specifically keeping track of the case when you are first creating a file rather than entirely treating the database API as handling all file operations itself, but even so, it's not going to affect performance very much so that's probably okay.
- sqlite.lua could have some sort of "clobber" option that detects if the database doesn't load and can prompt the user to recreate the database if it fails to load.
Alternatively, this problem probably doesn't need to be actually prevented since it's easy for a user to fix. It just needs to be detected. If sqlite fails to load, there should be a better error message logged somewhere informing the user that sqlite.lua couldn't load the extension.
Hi @fireboy1919, I got the same error, but do not know the path of the garbage file. Could you tell me its path?
In my case i needed to install libsqlite3-dev on ubuntu.
To check if its ok run inside nvim after install sqlite.lua:
:lua require "sqlite.tbl"
I specified the path to the file in the telescope sqlite file as I showed in my config...
Hi @fireboy1919, I got the same error, but do not know the path of the garbage file. Could you tell me its path?
He means the one that u set in the path:
require("telescope").setup {
defaults = {
wrap_results = true,
history = {
path = '~/.local/share/nvim/databases/telescope_history.sqlite3',
limit = 100
}
}
}
So just delete telescope_history.sqlite3