3rd / image.nvim

🖼️ Bringing images to Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Magick rock not found

bananaboy139 opened this issue · comments

I am using POP OS, kitty, latest neovim nightly appimage

I installed magick with luarocks --local --lua-version=5.1 install magick, but when I try to run nvim --clean -c ":luafile minimal-setup.lua", I get

Error detected while processing User Autocommands for "VeryLazy":
image.nvim: magick rock not found, please install it and restart your editor

I'm not sure why, I checked and magick is indeed in ~/.luarocks/share/lua/5.1, maybe it's because the default installed lua is 5.3?

I vaguely remember getting this error myself, but can't recreate it now. I do remember having issues with the latest nvim (but is just working for me now so don't know).

The error in my case was related to nvim 9.2 moving to LuaJIT 2.1.1692716794, which was having issues with hererocks. You can try nvim 9.1, but I can't explain why 9.4 is suddenly working now for me (or exactly why it didn't work).

@bananaboy139
This error will occur if the magick rock can't find ImageMagick. Can you confirm that you have that installed with which magick

If that's installed, then it's probably a path issue in some way or another, how did you install ImageMagick?

If you haven't already seen it, #18 is a similar issue but on MacOS, the steps that I took to figure out what was wrong are outlined in the comments though, and could be helpful

I have the same issue under arch and neovim 0.10.0-dev-9afbfb4 (nightly). ImageMagick is installed via paru from the aur and is accesible (which magick reveals /usr/bin/magick). I saw #18 and figured it's probably a related issue, but being a MacOS the solution didn't help me too much. I will say that I didn't spent too much time looking into this though as I was just interested in trying image.nvim and when it didn't run and I couldn't figure out how to solve in ~20 minutes I figured I'd wait until a patch emerges to try again, but I am happy to test any suggestions or provide any feedback.

Could you test on stable just so we can rule that out? I don't have the issue on nightly on macos though so I'm not hopeful

You could edit this file https://github.com/benlubas/image.nvim/blob/1355ea1dbc059136c6d6bd3fbefb0838ebe4ec85/lua/image/magick.lua#L1 so that it prints the full error (I should submit a PR to make this the default tbh). The variable magick will contain the error, so just print that with vim.inspect() b/c it might be a table.

If that doesn't give you anything useful you can go into the luarock itself and poke around (this is what I did) and go add some print statements. I can provide more detail if needed. but try the other things first.

There's also one thing that you can do to verify that it's a neovim path issue that's mentioned in the other issue. This comment.

Ah, if the pcall fails here magick has the error?

local has_magick, magick = pcall(require, "magick") 

Yup

Okay, so the error (for me) occurs on line 55 of init.lua, not in magick.lua. When this error is tripped, here's the contents of magick.

{                                                                                                                                                                                                                                       
  has_magick = false,                                                                                                                                                                                                                   
  load_image = <function 1>,                                                                                                                                                                                                            
  magick = "module 'magick' not found:\n\tno field package.preload['magick']\ncache_loader: module magick not found\ncache_loader_lib: module magick not found\n\tno file './magick.lua'\n\tno file '/home/runner/work/neovim/neovim/.de
ps/usr/share/luajit-2.1/magick.lua'\n\tno file '/usr/local/share/lua/5.1/magick.lua'\n\tno file '/usr/local/share/lua/5.1/magick/init.lua'\n\tno file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/magick.lua'\n\tno file '/
home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/magick/init.lua'\n\tno file './magick.so'\n\tno file '/usr/local/lib/lua/5.1/magick.so'\n\tno file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/magick.so'\n\tno file '
/usr/local/lib/lua/5.1/loadall.so'"                                                                                                                                                                                                     
} 

Interestingly if I'm inside of the ~/.local/share/nvim/lazy/image.nvim/lua/image directory at the time then the error doesn't trigger due to the presence of magick.lua there (I can also touch magick.lua in any directory to stop this error occurring on nvim load).

From what I understand, this is looking in the listed locations for magick.lua, but a quick fd magick.lua --hidden from my home directory reveals that .local/share/nvim/lazy/image.nvim/lua/image/magick.lua is the only place this exists.

For me, running luarocks --local --lua-version 5.1 install magick installs magick to ~/.luarocks/share/lua/5.1/magick, but I have no magick.lua in this directory or sub directories after install anyway. The files in this directory are base_image.lua gmwand.lua version.lua enum.lua init.lua wand gmwand thumb.lua wand.lua, where gmwand and wand are subdirectories, each containing the files data.lua image.lua lib.lua.

Ah, just tested this with neovim v0.9.4 and the error doesn't occur, so it seems to be some problem with image.nvim and neovim 0.10.

I followed the steps from https://github.com/leafo/magick, and ran

sudo apt-get install luajit
sudo apt-get install libmagickwand-dev
sudo apt-get install libgraphicsmagick1-dev

Now, when I run the nvim --clean -c ":luafile minimal-setup.lua", I don't get any errors, but the image does not load, There's just an empty space in between the lines, but no image loads.

I'm running kitty without tmux, if that's the issue maybe.

@HawkinsT it's ok that there's no magick.lua, it should load magick/init.lua.

Do you have this in your Neovim config?

package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;"
package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;"

@3rd I do, yes.

Edit - from my config:

	{
		"3rd/image.nvim",
		config = function()
			require("image").setup()
			-- note: I removed redundant ';' from the ends of each path
			package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua"
			package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua"
		end,
	},

Edit2:
Aha, I was being stupid and amending package.path after calling the image setup function, so this is now fixed for me. FYI the ending semicolons in the example are redundant as you also concatenate a semicolon at the beginning so currently you end up with doubled semicolons.

@bananaboy139 what version of kitty are you using? Apt has an old version of Kitty that has caused issues in the past. So installing the latest kitty version could fix it

Thanks! I installed kitty through the curl command and it works now.

@bananaboy139 awesome!

could you close this issue now that everyone is resolved?