3rd / image.nvim

🖼️ Bringing images to Neovim.
MIT License
1.17k stars 51 forks source link

issue with installing magic rock #91

Open MichaelC001 opened 1 year ago

MichaelC001 commented 1 year ago

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 commented 1 year ago

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

MichaelC001 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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

neuromaancer commented 11 months ago

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

spring-haru commented 10 months ago

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 commented 10 months ago

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

pbower commented 9 months ago

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

3rd commented 9 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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)
FunnyGhost commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

FunnyGhost commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

FunnyGhost commented 7 months ago

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

drmoc commented 7 months ago

@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 commented 6 months ago

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

t18n commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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 commented 1 month ago

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
dreilly1982 commented 1 month ago

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 commented 1 month ago

+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 commented 3 weeks ago

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 commented 3 weeks ago

@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 commented 3 weeks ago

@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 commented 3 weeks ago

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 https://github.com/3rd/image.nvim/issues/240

sankantsu commented 3 weeks ago

@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. https://github.com/folke/lazy.nvim/issues/1576

I'm not sure about #240.

3rd commented 3 weeks ago

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