ropensci/magick

installing without sudo

dm8000 opened this issue · 6 comments

Hello. I have tried installing magick in a R terminal and got this

> install.packages("magick")
Installing package into ‘/data04/projects04/MarianaBoroni/adipocyte_int/lib/Gabiluizlib_2/Gabiluizlib2/Gabiluizlib’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/magick_2.7.3.tar.gz'
Content type 'application/x-gzip' length 4813163 bytes (4.6 MB)
==================================================
downloaded 4.6 MB

* installing *source* package ‘magick’ ...
** package ‘magick’ successfully unpacked and MD5 sums checked
** using staged installation
Package Magick++ was not found in the pkg-config search path.
Perhaps you should add the directory containing `Magick++.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Magick++' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lMagick++-6.Q16
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the Magick++ library. Try installing:
 - deb: libmagick++-dev (Debian, Ubuntu)
 - rpm: ImageMagick-c++-devel (Fedora, CentOS, RHEL)
 - csw: imagemagick_dev (Solaris)
 - brew imagemagick@6 (MacOS)
For Ubuntu versions Trusty (14.04) and Xenial (16.04) use our PPA:
   sudo add-apt-repository -y ppa:cran/imagemagick
   sudo apt-get update
   sudo apt-get install -y libmagick++-dev
If Magick++ is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a Magick++.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:22: fatal error: Magick++.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘magick’
* removing ‘/data04/projects04/MarianaBoroni/adipocyte_int/lib/Gabiluizlib_2/Gabiluizlib2/Gabiluizlib/magick’
Warning in install.packages :
  installation of package ‘magick’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpdtGlml/downloaded_packages’

I am using R remotely and I have no root access. I have tried downloading the rpm binaries for installation instead, but there is an unending loop of dependencies that make this impossible. Is there any alternative for the installation?

In this case you need to build magick from source. For example, to install magick in /cluster/soft/magick and let R find it, you may do like this:

tar xvzf ImageMagick.tar.gz
cd ImageMagick-7.1.0-51
./configure --prefix=/cluster/soft/magick
make
make install

export PKG_CONFIG_PATH=/cluster/soft/magick/lib/pkgconfig
export LD_LIBRARY_PATH=/cluster/soft/magick/lib

cd /temp/dir/to/build/r-magick
git clone https://github.com/ropensci/magick
R CMD INSTALL magick

@zhenglukai I am trying this process to install magick for use on HPC system and am running into some issues. Due to allocation limits I am trying to install into an R library I specified in my project directory. I adjusted the first code chunk as follows:

tar xvzf ImageMagick.tar.gz  
cd ImageMagick-7.1.0-62  
./configure --prefix=/project/dir/R/lib/magick LDFLAGS='-L/project/dir/R/lib'  
make  
make install

At this point, I get the following warning:

cp -f Magick++/lib/Magick++.pc Magick++/lib/Magick++-7.Q16HDRI.pc
make[1]: warning:  Clock skew detected.  Your build may be incomplete.

When I run the R CMD at the end of the code chunk, I get the following error:

ERROR: cannot install to srcdir for package ‘magick’

I have already tried conventional package installation in R v4.2.0 and when running in console it outputs the following error:

Error: package or namespace load failed for ‘magick’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/project/dir/R/lib/magick/libs/magick.so':
libMagick++-6.Q16.so.8: cannot open shared object file: No such file or directory

Interestingly, this installation works if I'm using an interactive RStudio Server session. However, I need to be able to submit batch jobs that can run a long time so need to find a way to get a complete install.

Hi @burnsal ,

Regarding the "Clock skew detected" warning, usually make clean and rebuilding the software could help.

libMagick++-6.Q16.so.8: cannot open shared object file: No such file or directory

Please take a look at the directory where you installed ImageMagick. You built ImageMagick from the source file of version 7.1.0, so I assume there is no libMagick++-6.Q16.so.8. See if making a soft link named libMagick++-6.Q16.so.8 to the actual file in your folder helps.

Good luck!

Thanks @zhenglukai ! Still trying to find a workaround. Do you have any thoughts on the srcdir error?

ERROR: cannot install to srcdir for package ‘magick’

Thanks @zhenglukai ! Still trying to find a workaround. Do you have any thoughts on the srcdir error?

ERROR: cannot install to srcdir for package ‘magick’

Did you download the source code of the R package to the location of your R library (R_LIBS_USER)? If that is the case, try to download the source in another place and R CMD INSTALL magick there.

I was having a similar issue installing the package in RStudio server being managed by IT (so no sudo for me).
I followed the steps posted by @zhenglukai but ended up with the following error message when calling library(magick):
libMagick++-7.Q16HDRI.so.5: cannot open shared object file: No such file or directory
The missing piece of information to solve this issue was to use:
dyn.load("/path/to/libMagick++-7.Q16HDRI.so.5")

Now just gotta go figure out how to install popper for pdftools...