Skip to content

Too Many Open FilesΒ #387

@kostabekre

Description

@kostabekre

πŸ› Describe the bug

When I link a note using double brackets ([[) or rename a note, sometimes I have errors "Too many open files".
I use my forked repository, which uses the main branch and PR from the aliases.

Those errors started occur several weeks ago, I think it's linked with removing of the plenary.

Example of errors:

198 error(s) occurred during search. First error from note at '/home/frainx8/Documents/WorkVault/Source Files/202409101531 Boxing and Unboxing V
alue Types.md':
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/note.lua:544: bad argument #1 to 'lines' (/home/frainx8/Documents/WorkVault/Source Files/2024
09101531 Boxing and Unboxing Value Types.md: Too many open files)
"~/Documents/WorkVault/Base/Internet Protocols.md" 12L, 155B written
Created note 'Communication Types Between Microservices' at 'Base/Communication Types Between Microservices.md'
"~/Documents/WorkVault/Base/Communication Types Between Microservices.md" 12L, 141B written
Created note 'gRPC' at 'Base/gRPC.md'
Created note 'RPC' at 'Base/RPC.md'
139 error(s) occurred during search. First error from note at '/home/frainx8/Documents/WorkVault/Base/202406042005 Connect to PostgreSQL Docker
Instance via Web GUI.md':
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/note.lua:544: bad argument #1 to 'lines' (/home/frainx8/Documents/WorkVault/Base/202406042005
 Connect to PostgreSQL Docker Instance via Web GUI.md: Too many open files)
Created note 'UDP' at 'Base/UDP.md'
236 error(s) occurred during search. First error from note at '/home/frainx8/Documents/WorkVault/Source Files/202407291225 Verifiability and Con
straints.md':
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/note.lua:544: bad argument #1 to 'lines' (/home/frainx8/Documents/WorkVault/Source Files/2024
07291225 Verifiability and Constraints.md: Too many open files)

Config

			obsidian.setup({
				legacy_commands = false,

				workspaces = {
					{
						name = "personal",
						path = "~/Documents/PowerVault",
					},
					{
						name = "work",
						path = "~/Documents/WorkVault",
					},
					{
						name = "test",
						path = "~/Documents/TestVault",
					},
				},

				completion = {
					nvim_cmp = true,
					blink = false,
					create_new = false,
				},

				picker = {
					-- Set your preferred picker. Can be one of 'telescope.nvim', 'fzf-lua', 'mini.pick' or 'snacks.pick'.
					name = "telescope.nvim",
					-- Optional, configure key mappings for the picker. These are the defaults.
					-- Not all pickers support all mappings.
					note_mappings = {
						-- Create a new note from your query.
						new = "<C-x>",
						-- Insert a link to the selected note.
						insert_link = "<C-l>",
					},
					tag_mappings = {
						-- Add tag(s) to current note.
						tag_note = "<C-x>",
						-- Insert a tag at the current location.
						insert_tag = "<C-l>",
					},
				},

				---@return table
				note_frontmatter_func = function(note)
					local out = { aliases = note.aliases, tags = note.tags }

					if note.metadata and not vim.tbl_isempty(note.metadata) then
						for k, v in pairs(note.metadata) do
							if k == "updated" then
								v = tostring(os.date("%Y-%m-%dT%H:%M"))
							end

							out[k] = v
						end
					end

					if not out["parent"] then
						out["parent"] = ""
					end

					if not out["created"] then
						out["created"] = tostring(os.date("%Y-%m-%dT%H:%M"))
					end

					if not out["updated"] then
						out["updated"] = tostring(os.date("%Y-%m-%dT%H:%M"))
					end

					return out
				end,

				notes_subdir = "Base",
				new_notes_location = "current_dir",

				-- Optional, sort search results by "path", "modified", "accessed", or "created".
				-- The recommend value is "modified" and `true` for `sort_reversed`, which means, for example,
				-- that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time
				sort_by = "modified",
				sort_reversed = true,

				daily_notes = {
					folder = "Daily",
				},

				templates = {
					folder = "Templates",
					date_format = "%Y-%m-%dT%H:%M",
					substitutions = {
						custom_title = function()
							--local file_name = require("obsidian").Note.name
							--print(file_name)
							return "test"
							--local name_only = file_name:sub(0, #file_name - 3)
							--return string.gmatch(name_only, " ")[1];
						end,
					},
				},

				backlinks = {
					parse_headers = false,
				},

				-- Optional, customize how note IDs are generated given an optional title.
				---@param title string|?
				---@return string
				note_id_func = function(title)
					if title ~= nil then
						return title
					else
						local suffix = tostring(os.date("%Y-%m-%d"))
						return suffix
					end
				end,
				-- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
				-- URL it will be ignored but you can customize this behavior here.
				---@param url string
				follow_url_func = function(url)
					vim.fn.jobstart({ "xdg-open", url }) -- linux
					-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
					-- vim.ui.open(url) -- need Neovim 0.10.0+
				end,

				-- follow_img_func = function(img)
				-- vim.fn.jobstart { "qlmanage", "-p", img }  -- Mac OS quick look preview
				-- vim.fn.jobstart({"xdg-open", img})  -- linux
				-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
				-- end,

				callbacks = {
					post_setup = function(_)
						vim.keymap.set("n", "<leader>gd", "<CMD>Obsidian follow_link<CR>", { desc = "Follow link" })
						vim.keymap.set(
							"n",
							"<C-]>",
							"<CMD>Obsidian follow_link<CR>",
							{ noremap = true, desc = "Follow link" }
						)
					end,
				},
				attachments = {
					img_folder = "Files",
				},

				ui = {
					enable = false,
				},
				cache = {
					enabled = true,
					path = ".cache.json",
				},

				statusline = {
					enabled = false,
				},

				---@class obsidian.config.FooterOpts
				footer = {
					enabled = true,
					--format = "{{backlinks}} backlinks  {{properties}} properties  {{words}} words  {{chars}} chars",
					format = "{{backlinks}} backlinks",
					hl_group = "Comment",
					separator = string.rep("-", 80),
				},
			})

Environment


==============================================================================
obsidian:                                                                   βœ…

- βœ… OK neovim >= 0.11

obsidian.nvim [Version] ~
- βœ… OK obsidian.nvim v3.13.0 (187a80cd757e1cd0048105450064ec627043e43d)

obsidian.nvim [Environment] ~
- βœ… OK operating system: Linux

obsidian.nvim [Config] ~
- βœ… OK β€’ dir: /home/frainx8/Documents/WorkVault

obsidian.nvim [Pickers] ~
- βœ… OK telescope.nvim: b4da76be54691e854d3e0e02c36b0245f945c2c7

obsidian.nvim [Completion] ~
- βœ… OK nvim-cmp: b5311ab3ed9c846b585c0c15b7559be131ec4be9

obsidian.nvim [Dependencies] ~
- βœ… OK rg: 14.1.1
- βœ… OK wl-paste: 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions