Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with installing magic rock #91

Open
MichaelC001 opened this issue Nov 27, 2023 · 46 comments
Open

issue with installing magic rock #91

MichaelC001 opened this issue Nov 27, 2023 · 46 comments

Comments

@MichaelC001
Copy link

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!

@3rd
Copy link
Owner

3rd commented Nov 27, 2023

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

@MichaelC001
Copy link
Author

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

@3rd
Copy link
Owner

3rd commented Nov 28, 2023

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

@Gabz-Araujo
Copy link

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

@neuromaancer
Copy link

neuromaancer commented Dec 17, 2023

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

@spring-haru
Copy link

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.

@benlubas
Copy link
Contributor

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

@pbower
Copy link

pbower commented Feb 15, 2024

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

@3rd
Copy link
Owner

3rd commented Feb 16, 2024

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

@Stianhn
Copy link

Stianhn commented Mar 24, 2024

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: lua@5.1 has been disabled because it is deprecated upstream!

Luckily compiling it from source is quite simple.

@mesa123123
Copy link

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???

@3rd
Copy link
Owner

3rd commented Mar 27, 2024

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.

@xell
Copy link

xell commented Mar 28, 2024

I tried this on my M2 chip Macbook and it worked, see #9 (comment)

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)

@FunnyGhost
Copy link

FunnyGhost commented Apr 15, 2024

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 🤔

@benlubas
Copy link
Contributor

benlubas commented Apr 15, 2024

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

@FunnyGhost
Copy link

FunnyGhost commented Apr 15, 2024

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.

@benlubas
Copy link
Contributor

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

@FunnyGhost
Copy link

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.

@benlubas
Copy link
Contributor

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

@FunnyGhost
Copy link

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.

@benlubas
Copy link
Contributor

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.

@3rd
Copy link
Owner

3rd commented Apr 15, 2024

@FunnyGhost solved it like #91 (comment)

@FunnyGhost
Copy link

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

@drmoc
Copy link

drmoc commented Apr 18, 2024

@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

@destngx
Copy link

destngx commented May 26, 2024

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

@t18n
Copy link

t18n commented Aug 8, 2024

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 lua@5.1.
Error: lua@5.1 has been disabled because it is deprecated upstream! It will be disabled on 2024-02-16.
zsh: command not found: luarocks

@mikesmithgh
Copy link

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 lua@5.1.
Error: lua@5.1 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

@Cheveniko
Copy link

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 lua@5.1.
Error: lua@5.1 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

@kiyoon
Copy link

kiyoon commented Sep 19, 2024

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

@guruor
Copy link

guruor commented Oct 9, 2024

#91 (comment) 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

@dreilly1982
Copy link

I beat my head against the wall for bit with this, but I had to install pkgconfig to get this to work:

brew install pkgconfig

Then it magically worked

@sudopseudocode
Copy link

+1 to @dreilly1982 's suggestion. I'm currently using MacOS and was originally able to resolve the issue with this workaround mentioned above.

Happy to say this workaround is no longer necessary after running brew install pkgconfig.

@burbschat
Copy link
Contributor

I ran into a similar issue when trying to run the minimal config on a fresh installation of Arch Linux. I noticed that for the tiniest amount of time a message from presumably the shell (?) flashed on the screen which mentioned that pkg-config is not available as a command. On Arch, pkg-config is provided by the pkgconfig package and installing this package resolved the issue. So pkg-config seems to be a dependency of some sort? In that case perhaps it should be mentioned in the README.

I also noticed that the mode of failure seems to be the same as when magick is not available. In both cases :lua require("magick") produces the same error.

@3rd
Copy link
Owner

3rd commented Nov 2, 2024

@burbschat do you have an otherwise working ImageMagick installation? (convert and identify commands available and working)
If you do you can switch to the magick_cli processor instead of using the Lua rock.

@burbschat
Copy link
Contributor

@3rd Yes indeed I do have a working ImageMagick installation. Switching to magick_cli does seem to work and thank you for documenting this option. However, if pgk-config is not available, first I still see sh: line 1: pkg-config: command not found and the same error message as when I use magick_rock (with pkg-config not available) appears (see screenshot below). If I just ignore the message and advance by pressing ENTER, images are displayed without problems. So it seems like the error message is accidentally triggered? I mean it is complaining that the magick rock is not found, even though it is not needed.
image
A similar error is triggered when I try to :lua require("magick") (without having pgk-config available), so perhaps magick is required (by which I mean loaded with require) somewhere even if the processor is set to magick_cli.

I've been testing this using the minimal config to which I added one line to set the processor to magick_rock or magick_cli. I also cleared the directory where lazy seems to install (?) the magick rock to (on my system that is ~/.local/share/nvim) after setting magick_cli in the minimal config, to ensure installation from scratch, but this did not appear to help.

Looking at the lazy-rocks directory, it seems like the magick rock is installed even if the processor is set to magick_cli. Not sure if this is relevant though. Just for the record, here is a tree ~/.local/share/nvim/lazy-rocks -L 5 showing the directories after a fresh initizalization with the minimal config:

~/.local/share/nvim/lazy-rocks
└── image.nvim
    ├── lib
    │   └── luarocks
    │       └── rocks-5.1
    │           ├── image.nvim
    │           ├── magick
    │           └── manifest
    └── share
        └── lua
            └── 5.1
                ├── image
                ├── magick
                └── types.lua

@3rd
Copy link
Owner

3rd commented Nov 3, 2024

Hey, it was an extra check that ran all the time, fixed now.
@sankantsu Is there any way to avoid doing the build and installing the rock when using "magick_cli"?
Possibly related #240

@sankantsu
Copy link
Contributor

@3rd , @burbschat

It seems that lazy.nvim has option to skip the build for plugin.
It might be helpful to document this option in README, for magick_cli processor users.
c.f. https://lazy.folke.io/spec#spec-setup

    {
        "3rd/image.nvim",
        opts = { ... },
        build = false,  -- This option disables build.
    },

I locally tested setting like above, and confirmed that it skips luarocks build steps.
It seems that opts.rocks.enabled = false also works, completely disables luarocks for all plugins (I didn't tried).
c.f. folke/lazy.nvim#1576

I'm not sure about #240.

@3rd
Copy link
Owner

3rd commented Nov 3, 2024

Thank you @sankantsu! Rewriting the README now with the help of Claude, who has a beautiful personality today 😂
image

@varung
Copy link

varung commented Dec 2, 2024

Hi, sorry, is this resolved? What's the answer? On MacOS how do I get the minimal example to work?

I tried one of the suggestions:
test_image_nvim % brew install luajit
luarocks --local --lua-version=5.1 install magick

which doesn't work (even after I brew install luarocks)

@varung
Copy link

varung commented Dec 2, 2024

so the answer is
brew install pkgconfig
?
Should this be in the readme.md for macos?

@aogposton
Copy link

@varung Ive also done all the above and am not getting it to work on M1 mac. Would love someone to post a cohesive way to get this to work.

@3rd
Copy link
Owner

3rd commented Dec 5, 2024

Hey, if you have a regular working imagemagick installation you can use the magick_cli backend instead of the rock.

@aogposton
Copy link

@3rd I couldnt get magick_cli to work either. I tried everything in this thread as well as other threads and simply couldnt giet it figured out on M1 MacOS. Maybe its just me though. Thats why I'd like to see a "full solution" to try.

@kiyoon
Copy link

kiyoon commented Dec 10, 2024

It's just my opinion, but given that it's so hard to install dev version of magick and involves more complicated steps with luarocks, I believe the CLI interface should be the default mode and leave FFI bindings for the the advanced users.

@3rd
Copy link
Owner

3rd commented Dec 15, 2024

@aogposton for cli mode the plugin uses only the identify and convert utilities from ImageMagick, can you confirm that those exist in your path and that they work?
try converting an image by using convert directly in your shell please.

@AhmadHdr
Copy link

AhmadHdr commented Jan 4, 2025

➜ lua -v
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio

➜ luarocks --lua-version=5.4 install magick

Error: Your user does not have write permissions in /usr/lib/luarocks/rocks-5.4
-- you may want to run as a privileged user or use your local tree with --local.

➜ luarocks install magick --local

Error: No results matching query were found for Lua 5.4.
To check if it is available for other Lua versions, use --check-lua-versions.

➜ luarocks install magick --local --check-lua-versions
magick not found for Lua 5.4.
Checking if available for other Lua versions...
Checking for Lua 5.1...
Checking for Lua 5.2...
Checking for Lua 5.3...

Error: No results matching query were found for Lua 5.4.
magick supports only Lua 5.1 but not Lua 5.4.

I found the problem, I need to downgrade the lua version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests