ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
462 stars 65 forks source link

installation failure on Alpine Linux #319

Closed bastistician closed 3 years ago

bastistician commented 3 years ago

Installing current magick 2.7.2 on Alpine Linux succeeds with --no-staged-install. However, with a standard --staged-install, I get

** testing if installed package can be loaded from final location
Error in magick_image_readpath(path, density, depth, strip, defines) : 
  R: UnableToOpenBlob 'logo:': No such file or directory @ error/blob.c/OpenBlob/3537
Calls: <Anonymous> ... as.list.environment -> image_read -> magick_image_readpath
Execution halted
ERROR: loading failed

I get a similar error if I try a --fake install on my Ubuntu machine (maybe this helps debugging):

** testing if installed package can be loaded from final location
Error in .Call("_magick_magick_image_readpath", PACKAGE = "magick", paths,  : 
  "_magick_magick_image_readpath" not available for .Call() for package "magick"
Calls: <Anonymous> ... as.list.environment -> image_read -> magick_image_readpath
Execution halted
ERROR: loading failed

To reproduce on Alpine Linux using the current development version of magick:

docker pull rhub/r-minimal
cat <<EOF | docker run -i rhub/r-minimal /bin/sh
  installr -c -a "curl-dev imagemagick-dev" Rcpp curl magrittr remotes
  R -e 'remotes::install_github("ropensci/magick")'
EOF
jeroen commented 3 years ago

The ubuntu error is completely unrelated. It is expected if you do a --fake install that you have missing functions.

bastistician commented 3 years ago

Ok, this was a bad guess then.

Maybe I should report this failure @gaborcsardi, who maintains the rhub/r-minimal Alpine image and a list of known failures (which currently doesn't mention magick).

jeroen commented 3 years ago

From the error it looks like imagemagick on alpine is missing the logo demo image.

gaborcsardi commented 3 years ago

@jeroen Seems like it is in another package:

~ # apk info -L imagemagick-doc | grep logo
usr/share/doc/ImageMagick-7/images/logo-sm-flop.png
usr/share/doc/ImageMagick-7/images/logo-sm-fx.png
usr/share/doc/ImageMagick-7/images/logo-sm.png
usr/share/doc/ImageMagick-7/images/logo.jpg
usr/share/doc/ImageMagick-7/images/logo.png

But imagemagick does not find it there, it seems.

jeroen commented 3 years ago

No it's not a file, it is supposed to be a hardcoded demo image inside libmagick. Maybe they stripped it out somehow.

jeroen commented 3 years ago

@dlemstra is it possible that some builds of imagemagick do not have the "logo:" and "wizard:" etc images?

gaborcsardi commented 3 years ago

It seems to work with imagemagick 6, so instead of imagemagick-dev, you can use the imagemagick6-dev Alpine package. Maybe this is an imagemagick 7 thing? Or an Alpine thing.

bastistician commented 3 years ago

FWIW, if I do a --no-staged-install of magick (which succeeds), I can reproduce the error in an R session with:

library("magick")
## Linking to ImageMagick 7.0.11.13
## Enabled features: cairo, fontconfig, freetype, ghostscript, heic, lcms, rsvg, webp, x11
## Disabled features: fftw, pango, raw
logo <- image_read("logo:")
## Error in magick_image_readpath(path, density, depth, strip, defines) : 
##  R: UnableToOpenBlob 'logo:': No such file or directory @ error/blob.c/OpenBlob/3537
jeroen commented 3 years ago

It works on all platforms I have tried, both with IM6 and IM7. It seems like/feature a bug in alpine.

gaborcsardi commented 3 years ago

@jeroen I agree.

OTOH, FWIW the delayedAssign is not helping much, because the code is evaluated at load time, anyway. Maybe that was not your intent?

If you want to evaluate it "on-demand", then you can use an active binding, but you need to create it from .onLoad() because the packaging tool are not great with active bindings in the package namespace. Something like this works, I think:

dummy <- function() { }
.onLoad <- function(libname, pkgname) {
  makeActiveBinding(
    "logo",
    image_read("logo:"),
    environment(dummy)
  )
}

On course the simplest would be to use a function, logo() etc, but that is too late now.

bastistician commented 3 years ago

It seems to work with imagemagick 6, so instead of imagemagick-dev, you can use the imagemagick6-dev Alpine package.

Thanks. I can confirm that the legacy release of ImageMagick works for me:

library("magick")
## Linking to ImageMagick 6.9.11.55
## Enabled features: cairo, fontconfig, freetype, ghostscript, lcms, rsvg
## Disabled features: fftw, heic, pango, raw, webp, x11
## Using 4 threads
logo <- image_read("logo:")
logo
##   format width height colorspace matte filesize density
## 1    GIF   640    480       sRGB FALSE    28576   72x72
jeroen commented 3 years ago

delayedAssign was the intention. This is a demo image for use in examples that is initiated when the package is loaded.

It is also useful to test if the package works, because if the demo image cannot be loaded, something is usually very wrong, and the installation should fail.

jeroen commented 3 years ago

OK this seems like a bug in the imagemagick package in alpine. It works fine with imagemagick6 or 7 from homebrew, and also works with imagemagick6-dev on alpine.

gaborcsardi commented 3 years ago

delayedAssign was the intention. This is a demo image for use in examples that is initiated when the package is loaded.

Actually, it is not evaluated at load time, only at test-load time during installation.

@bastistician So you can install the package with --no-test-load with imagemagick 7, and it will work fine as long as you don't use the demo images:

R -e 'install.packages("magick", INSTALL_opts = "--no-test-load", repos = "https://cloud.r-project.org")'

Just make sure you install both the imagemagick and imagemagick-dev Alpine packages.

gaborcsardi commented 3 years ago

@bastistician Actually, forget all this, you just need both the imagemagick and imagemagick-dev packages, both install time and run time, and then everything works:

installr -d -a "imagemagick imagemagick-dev" -t "curl-dev" magick
bastistician commented 3 years ago

@bastistician Actually, forget all this, you just need both the imagemagick and imagemagick-dev packages, both install time and run time, and then everything works:

Yes, thank you, Gábor!

So this seems to be a peculiarity of the imagemagick 7 packaging in Alpine unrelated to magick. Sorry for the noise @jeroen.

(Debian/Ubuntu do not ship version 7 (yet); maybe we will see this issue coming up again when they do...)

jeroen commented 3 years ago

I think imagemagick-dev should always depend on imagemagick so you can't install one without the other. At least that is how it works in debian/ubuntu.