oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

Error installing FastR on macOS. #2531

Closed peter-fm closed 4 years ago

peter-fm commented 4 years ago

Trying to install FastR on macOS, I originally installed the compiler:

brew install gcc@4.9

Then seem to be able to install R okay:

sudo gu install R  
Downloading: Component catalog from www.graalvm.org
Processing Component: FastR
Downloading: Component R: FastR  from github.com
Installing new component: FastR (org.graalvm.R, version 20.1.0)
NOTES:
---------------
FastR should work out of the box on most Linux distributions and recent MacOS versions. Run the following script to check FastR requirements and create a personal R packages library directory: 
    /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/bin/configure_fastr

The R component comes without native image by default. If you wish to build the native image, which provides faster startup, but slightly slower peak performance, then run the following:
    gu rebuild-images R

The native image is then used by default. Pass '--jvm' flag to the R or Rscript launcher to use JVM instead of the native image. Note that the native image is not stable yet and is intended for evaluation and experiments for curious users. Some features may not work in the native image mode. Most notably, the --polyglot switch works only in JVM mode (when --jvm is used).

See http://www.graalvm.org/docs/reference-manual/languages/r for more.

Then I run the configure_fastr script:

% /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/bin/configure_fastr
The basic configuration of FastR was successfull.

Note: if you intend to install R packages you may need additional dependencies.
The most common dependency is GFortran, which must be of version 8.3.0 or later.
See https://gcc.gnu.org/wiki/GFortranBinaries.
If the 'gfortran' binary is not on the system path, you need to configure the full path to it in /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/etc/Makeconf (variable FC)
FastR unexpected failure: error loading libR from: /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib.
Message: dlopen(/Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib
  Referenced from: /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libRblas.dylib
  Reason: image not found

Troubleshooting: 

  * Please run /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/bin/configure_fastr. It will check that your system has the necessary dependencies and if not it will suggest how to install them.

  * If this does not help, please open an issue on https://github.com/oracle/fastr/ or reach us on https://graalvm.slack.com.

Then at this point it asks if I want to create a personal directory to which I choose y:

Default personal library directory () does exist. Do you wish to create it? (Yy/Nn) y
Creating personal library directory: 
mkdir: : No such file or directory
DONE

which looks like an error and when I run R it produces:

/Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/bin/R
Password:
R version 3.6.1 (FastR)
Copyright (c) 2013-19, Oracle and/or its affiliates
Copyright (c) 1995-2018, The R Core Team
Copyright (c) 2018 The R Foundation for Statistical Computing
Copyright (c) 2012-4 Purdue University
Copyright (c) 1997-2002, Makoto Matsumoto and Takuji Nishimura
All rights reserved.

FastR is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information.

Type 'q()' to quit R.
FastR unexpected failure: error loading libR from: /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib.
Message: dlopen(/Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib
  Referenced from: /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/lib/libRblas.dylib
  Reason: image not found

Troubleshooting: 

  * Please run /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0/Contents/Home/jre/languages/R/bin/configure_fastr. It will check that your system has the necessary dependencies and if not it will suggest how to install them.

  * If this does not help, please open an issue on https://github.com/oracle/fastr/ or reach us on https://graalvm.slack.com.

Any help with this?

fniephaus commented 4 years ago

The 20.1 release notes contain some additional hints for macOS users: https://www.graalvm.org/docs/release-notes/20_1/

peter-fm commented 4 years ago

That seems to have worked! The default installation of brew install gcc is 9.3.0 not 8.3.0 as it says in the docs but like a maverick I still ran install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib $GOMPLIB $R_HOME/lib/libRblas.dylib and install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib $GOMPLIB $R_HOME/lib/libRlapack.dylib so I'm guessing the 8.3.0 path is pointing to a 9.3.0 version but it seems to work and I can install packages and run code. Many thanks @fniephaus!

fniephaus commented 4 years ago

I went through the same pain and raised the issue on Slack, that's when they added the hints. Hopefully, this will be easier to set up with the next release. /cc @steve-s

steve-s commented 4 years ago

Yes, we are working on improving this in the next release: there should be zero additional requirements for FastR on MacOS. Thank you @fniephaus for responding faster than me :-) I assume we can close this for now.

pat-s commented 4 years ago

A few more specific instructions from my installation experience on macOS 10.15.5:

Ran

install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib $GOMPLIB $GRAALVM_HOME/languages/R/lib/libRlapack.dylib

install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib $GOMPLIB $GRAALVM_HOME/languages/R/lib/libRblas.dylib 

and was then able to start R via /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.1.0/Contents/Home/bin/R