dahtah / imager

R package for image processing
GNU Lesser General Public License v3.0
187 stars 43 forks source link

R believes that X11 isn't install, even when it is? #149

Open ctross opened 3 years ago

ctross commented 3 years ago

Thanks for making your code for imager free for us all to use.

I am using the imager package specifically for the grabPoint() function in my own package.

Everything works fine when I run the package on a windows machine. But, on Mac, the function fails, with a message that X11 needs to be installed: "Error in select(im) : Please install X11 library to use this function."

This is where it gets weird. If we run, capabilities(), X11=TRUE. Similarly, we can run data.entry() which pulls up a working GUI in R. So, X11 is working fine, but imager, or really, just select() from cimg, doesn't believe X11 is there.

I was able to try on a second Mac, with an older imager version, and it worked.

This lead me to think that maybe, in your last commit, some code was introduced that makes R believe that X11 isn't install, even when it is?

Any idea if this is right? Or how to figure out where?

ShotaOchi commented 3 years ago

CRAN required me to disable functions that use X11 library to retain imager on CRAN when autotools can't find X11 library. That's why I modified imager. I don't know why autotools can't find X11 library on your Mac machine if XQuartz is installed on your Mac machine.

An idea to avoid the disablement is to modify the following line of configure.ac file https://github.com/dahtah/imager/blob/9173851410eeb415a556bd58f09899ed88ee531c/configure.ac#L59 like this DONT_HAVE_X11=''

The idea is a temporary measure. It's better to find out the reason for the disablement but I don't have a Mac machine.

ctross commented 3 years ago

I have now tested on several Mac machines, and they all have this error.

Autotools does find X11, but Imager does not detect X11. This causes Imager to disable some functions even when it shouldn't.

How does Imager detect when the X11 library isn't installed? Could there be a bug there?

ctross commented 3 years ago

PS. Thanks for the quick and help replies!

ShotaOchi commented 3 years ago

imager uses AC_PATH_X to locate the X11 and test whether the X11 is available or not with AC_CHECK_LIB. https://github.com/dahtah/imager/blob/9173851410eeb415a556bd58f09899ed88ee531c/configure.ac#L51-L52

The disablement means R failed to call XOpenDisplay function of X11. I guess AC_CHECK_LIB needs some extra library to call the function. We may find the extra library if AC_PATH_XTRA is used instead of AC_PATH_X.

ajfedorec commented 3 years ago

I have also just seen this error on my colleagues Mac after they upgraded their R version to 4.0.5. It had been working previously with R version 3.6

edit: and it appears that downgrading back to R 3.6 does not fix the issue.

NKleinenkuhnen commented 3 years ago

Same for me as for @ajfedorec haven't been able to use the library ever since upgrading to R 4.0.0 or R 4.0.5. Downgrading to 3.6.1 didn't help either.

ShotaOchi commented 3 years ago

The problem is AC_CHECK_LIB(X11, XOpenDisplay, [HAVE_LIBX11=TRUE], [HAVE_LIBX11=FALSE]) fails on MacOS. I'm not sure why it fails on macOS but the version of R is not a problem. Is your macOS latest? Does AC_CHECK_LIB work if you downgrade the version of macOS? I don't know if autotools are maintained well for the latest version of macOS because macOS is unstable and requires high cost of software developers.

ShotaOchi commented 3 years ago

We don't have a solution to the problem at the moment. I made a branch for Mac users. https://github.com/ShotaOchi/imager/tree/imager_0_42_10_mac R doesn't disable the functions that use X11 library when AC_CHECK_LIB(X11, XOpenDisplay, [HAVE_LIBX11=TRUE], [HAVE_LIBX11=FALSE]) fails. Thus you should be able to use the functions that use X11 library on Mac OS. Can you guys confirm it?