image.nvim icon indicating copy to clipboard operation
image.nvim copied to clipboard

issue with installing magic rock

Open MichaelC001 opened this issue 2 years ago • 29 comments

Mac os , lua 5.4

image.nvim: magick rock not found, please install it and restart your editor luarocks install magick: To check if it is available for other Lua versions, use --check-lua-versions.

it seems that magic rock only support lua 5.1

How to solve it? Can I run neovim without magic rock?

thank you. This plugin is amazing ,its a game changer!

MichaelC001 avatar Nov 27 '23 15:11 MichaelC001

Hey, I'm not sure how things work on macOS, does this help you? https://github.com/3rd/image.nvim/issues/18#issuecomment-1826976752

3rd avatar Nov 27 '23 17:11 3rd

Hey, I'm not sure how things work on macOS, does this help you? #18 (comment)

this I tried. still not working

CleanShot_2023_11_28_235610

MichaelC001 avatar Nov 28 '23 15:11 MichaelC001

Neovim is supposed to come with LuaJIT, and it should works in its context, your external Lua version doesn't matter. Check if nvim --version says it has LuaJIT, and preferably Neovim itslef is v0.10

3rd avatar Nov 28 '23 17:11 3rd

I had the same problem, and this did the trick: brew install lua51 luarocks --lua-version=5.1 install magick

Gabz-Araujo avatar Nov 30 '23 01:11 Gabz-Araujo

I have tried this but it didn't work. Which chip you are using? M or intel? @Gabz-Araujo

neuromaancer avatar Dec 17 '23 09:12 neuromaancer

I followed @Gabz-Araujo and it worked. But, nvim --clean -c ":luafile minimal-setup.lua" for minimal-setup.lua does NOT show the image. I use Apple M1.

spring-haru avatar Jan 04 '24 14:01 spring-haru

@spring-haru you will likely have to follow some instructions in the pinned issue if you're on macos

benlubas avatar Jan 11 '24 21:01 benlubas

Hi there. It happens on Ubuntu 22.04. Does it relate to the 'magick' command being replaced by convert in 'imagemagick' package?

pbower avatar Feb 15 '24 02:02 pbower

no, it's using the magick lua rock, you can check if your setup worked by running :lua require("magick") in neovim, without loading the plugin

3rd avatar Feb 16 '24 01:02 3rd

I had the same problem, and this did the trick: brew install lua51 luarocks --lua-version=5.1 install magick

This no longer seems to be an option.

Error: [email protected] has been disabled because it is deprecated upstream!

Luckily compiling it from source is quite simple.

Stianhn avatar Mar 24 '24 14:03 Stianhn

Getting a similar error on install:

Error detected while processing VIMINIT:
image.nvim: magick rock not found, please install it and restart your editor
[LSP] Format request failed, no matching language servers.

Here's my package path extension:

-- Package Path Upgrade
----------
-- Rocks installed through luarocks.nvim
package.path = package.path .. ";" .. plugin_path .. "/luarocks.nvim/.rocks/share/lua/5.1/?.lua"
package.path = package.path .. ";" .. plugin_path .. "/luarocks.nvim/.rocks/share/lua/5.1/?/init.lua"
-- Rocks installed through local luarocks
package.path = package.path .. ";" .. fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua"
package.path = package.path .. ";" .. fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua"
-- Literally Pointing to my magick install
package.path = package.path .. ";" .. fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/magick/init.lua"
----------

Plugin just doesn't seem to be able to find magick/init.lua???

mesa123123 avatar Mar 25 '24 20:03 mesa123123

Plugin just doesn't seem to be able to find magick/init.lua???

Updated it so it shows the loading error for the rock, it might point you in the right direction.

3rd avatar Mar 27 '24 21:03 3rd

I tried this on my M2 chip Macbook and it worked, see https://github.com/3rd/image.nvim/issues/9#issuecomment-1637153929

change the magick/wand/lib.lua try_to_load as, for example:

lib = try_to_load("/opt/homebrew/lib/libMagickWand-7.Q16HDRI.dylib", function()
  -- local lname = get_flags():match("-l(MagickWand[^%s]*)")
  -- local suffix
  -- if ffi.os == "OSX" then
  --   suffix = ".dylib"
  -- elseif ffi.os == "Windows" then
  --   suffix = ".dll"
  -- else
  --   suffix = ".so"
  -- end
  -- return lname and "lib" .. lname .. suffix
end)

xell avatar Mar 28 '24 14:03 xell

I also have a similar issue. However, I only get image.nvim: magick not found when I try to run the demo. I'm on MacOs, on an M2 Pro chip. I'm running Neovim: 0.9.5

Here's my image.lua file:

return {
  "3rd/image.nvim",
  dependencies = { "luarocks.nvim" },
}

and here's my rocks.lua file:

return {
  "vhyrro/luarocks.nvim",
  priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
  config = true,
}

If I run magick from the terminal, it works, so the path is set correctly, I think 🤔

FunnyGhost avatar Apr 15 '24 11:04 FunnyGhost

If you want to use luarocks.nvim you have to tell it to install the magick rock. Image.nvim doesn't do it automatically like some other plugins do.

Take a look at the image.nvim readme for an example

benlubas avatar Apr 15 '24 12:04 benlubas

If you want to use luarocks.nvim you have to tell it to install the magick rock. Image.nvim doesn't do it automatically like some other plugins do.

Take a look at the image.nvim readme for an example

Sorry, you're right. I somehow forgot to add options. Here's my updated rocks.lua file:

return {
  "vhyrro/luarocks.nvim",
  priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
  opts = {
    rocks = { "magick" },
  },
}

The issue is still happening. I did restart the terminal.

FunnyGhost avatar Apr 15 '24 12:04 FunnyGhost

Probably need to run :Lazy build luarocks.nvim to install the rock

benlubas avatar Apr 15 '24 12:04 benlubas

Probably need to run :Lazy build luarocks.nvim to install the rock

Yeah, I also thought so. Didn't help 🤔 . How can I check if the build command worked? Because when I run it, it pops-up the Lazy panel.

FunnyGhost avatar Apr 15 '24 12:04 FunnyGhost

Did you follow the other steps for Mac os from the readme? The installing magic part in particular? There's a note about brew installing something in a place that nvim doesn't check and how to fix it

benlubas avatar Apr 15 '24 13:04 benlubas

Did you follow the other steps for Mac os from the readme? The installing magic part in particular? There's a note about brew installing something in a place that nvim doesn't check and how to fix it

Yep. I did that:

export DYLD_LIBRARY_PATH="/opt/homebrew/lib/"

and if I check with echo $DYLD_LIBRARY_PATH it shows the correct path.

FunnyGhost avatar Apr 15 '24 13:04 FunnyGhost

What's your exact error? You should get something more than just image.nvim: magick rock not found I think. and if you don't, make sure you're up to date with the latest version of image.nvim.

benlubas avatar Apr 15 '24 14:04 benlubas

@FunnyGhost solved it like https://github.com/3rd/image.nvim/issues/91#issuecomment-2025287226

3rd avatar Apr 15 '24 14:04 3rd

@benlubas Yes, solved with @3rd's help on Discord. Sorry for the late reply. Thanks a ton for the help 🙏

FunnyGhost avatar Apr 16 '24 08:04 FunnyGhost

@mesa123123 About this: image.nvim: magick rock not found, please install it and restart your editor

I listened to @Gabz-Araujo's suggestion:

luarocks --lua-version=5.1 install magick

The solution I found was the following: modify the excerpt from the file '.luarocks/share/lua/5.1/magick/wand/lib.lua':

lib = try_to_load(
"/opt/homebrew/Cellar/imagemagick/7.1.1-30/lib/libMagickWand-7.Q16HDRI.dylib",
"/opt/homebrew/Cellar/imagemagick@6/6.9.13-7/lib/libMagickWand-6.Q16.dylib",
"/opt/homebrew/bin/imagemagick/7.1.1-25/lib/libMagickWand-7.Q16HDRI.dylib"
)

In my case, in the first line:

"/opt/homebrew/Cellar/imagemagick/7.1.1-30/lib/libMagickWand-7.Q16HDRI.dylib", read 7.1.1-29.

Checking the path I realized it should be 7.1.1-30 It worked

drmoc avatar Apr 18 '24 19:04 drmoc

after a while try reinstalling lua/luajit and install pkg-config using brew, mine finally works in MacAir M1

destngx avatar May 26 '24 07:05 destngx

Unfortunately this is still an issue. You cannot install Lua 5.1 with homebrew anymore

❯ brew install lua51
luarocks --lua-version=5.1 install magick


Warning: Formula lua51 was renamed to [email protected].
Error: [email protected] has been disabled because it is deprecated upstream! It will be disabled on 2024-02-16.
zsh: command not found: luarocks

t18n avatar Aug 08 '24 09:08 t18n

Unfortunately this is still an issue. You cannot install Lua 5.1 with homebrew anymore

❯ brew install lua51
luarocks --lua-version=5.1 install magick


Warning: Formula lua51 was renamed to [email protected].
Error: [email protected] has been disabled because it is deprecated upstream! It will be disabled on 2024-02-16.
zsh: command not found: luarocks

Hey @t18n, for lua 5.1 you can install luajit.

brew install luajit
luarocks --local --lua-version=5.1 install magick

mikesmithgh avatar Aug 10 '24 01:08 mikesmithgh

Unfortunately this is still an issue. You cannot install Lua 5.1 with homebrew anymore

❯ brew install lua51
luarocks --lua-version=5.1 install magick


Warning: Formula lua51 was renamed to [email protected].
Error: [email protected] has been disabled because it is deprecated upstream! It will be disabled on 2024-02-16.
zsh: command not found: luarocks

Hey @t18n, for lua 5.1 you can install luajit.

brew install luajit
luarocks --local --lua-version=5.1 install magick

This worked for me, thank you! I'm on Macbook Air M2, Nvim 0.10.1 and Lua 5.4.7

Cheveniko avatar Aug 13 '24 08:08 Cheveniko

I've re-packaged the luarocks package for neovim, and modified it slightly so that it will locate the local installation of magick as well.

Instead of using luarocks, you can just install this plugin.

https://github.com/kiyoon/magick.nvim

kiyoon avatar Sep 19 '24 15:09 kiyoon

https://github.com/3rd/image.nvim/issues/91#issuecomment-2025287226 worked for me. Instead of .dylib, I had to replace it with .so file on linux.

Here is the command I used to get the library path:

 fd 'libmagickwand.*\.(so|dylib|dll)$' / --hidden

guruor avatar Oct 09 '24 07:10 guruor