Unable to install R-package prophet

I am trying to install R-package prophet using these commands:
install.packages("prophet", repos = "http://cran.r-project.org ")
and
install.packages("prophet")

I get this error:

<stdin>:1:10: fatal error: v8.h: No such file or directory
compilation terminated.
------------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/V8’
Warning in install.packages :
  installation of package ‘V8’ had non-zero exit status
ERROR: dependency ‘V8’ is not available for package ‘rstan’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status
ERROR: dependency ‘rstan’ is not available for package ‘prophet’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/prophet’
Warning in install.packages :
  installation of package ‘prophet’ had non-zero exit status

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

When I try to install rstan, I get the same error. But I already have the os library V8 installed on the RHEL. Please let me know what am I missing?

Thank you

Which V8 packages do you have installed on the system level? Only the runtime-library or also the development package? The latter is typically identified by a name like *-devel and is need for installation from source.

Thank you so much for the response. Yes there is an OS package v8-dev*

sh-4.2$ rpm -qa v8*
v8-3.14.5.10-25.el7.x86_64
v8-devel-3.14.5.10-25.el7.x86_64
sh-4.2$

I cannot reproduce this in a simple test system. Can you post the full output of install.packages("V8")?

BTW, you could also just use the pre-build binaries available from https://packagemanager.rstudio.com/. You just have to set your CRAN mirror to https://packagemanager.rstudio.com/all/__linux__/centos7/latest. I am assuming you are on RHEL 7 based on the quoted versions above.

Thanks, yes it is on RHEL7.

Here is the entire output:

 install.packages("prophet")
Installing package into ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘V8’, ‘rstan’

trying URL 'https://cran.rstudio.com/src/contrib/V8_3.2.0.tar.gz'
Content type 'application/x-gzip' length 680510 bytes (664 KB)
==================================================
downloaded 664 KB

trying URL 'https://cran.rstudio.com/src/contrib/rstan_2.21.2.tar.gz'
Content type 'application/x-gzip' length 1152008 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/src/contrib/prophet_0.6.1.tar.gz'
Content type 'application/x-gzip' length 217454 bytes (212 KB)
==================================================
downloaded 212 KB

* installing *source* package ‘V8’ ...
** package ‘V8’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
Using PKG_LIBS=-lv8 -lv8_libplatform
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find the libv8 engine library. Try installing:
 * deb: libv8-dev or libnode-dev (Debian / Ubuntu)
 * rpm: v8-devel (Fedora, EPEL)
 * brew: v8 (OSX)
 * csw: libv8_dev (Solaris)
To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
---------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:10: fatal error: v8.h: No such file or directory
compilation terminated.
------------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/V8’
Warning in install.packages :
  installation of package ‘V8’ had non-zero exit status
ERROR: dependency ‘V8’ is not available for package ‘rstan’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status
ERROR: dependency ‘rstan’ is not available for package ‘prophet’
* removing ‘/home/wsuser/R/x86_64-redhat-linux-gnu-library/3.6/prophet’
Warning in install.packages :
  installation of package ‘prophet’ had non-zero exit status

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

Does the file v8.h exist, i.e. what is the output of rpm -qf /usr/include/v8.h?

BTW, please familiarize yourself with the formatting possibilities provided by this platform. It really helps if code(like) blocks are formatted as such.

Thanks Yes I do see the file.

There seems to be something strange going on during the test compilations on your system. To debug this, I suggest you grab the source tar.gz file from CRAN and unpack it somewhere. Go to that directory and run

bash -x configure

This will produce quite a bit of output and should fail with the same message as the installation attempt. The interesting thing would be right before the failure message. Which command is actually executed to test if v8.h can be found?

Thanks a lot for your time. I get this error when I run the configure command:

When I try to install rstan in R command prompt, I get this error:

I am sorry for the confusion. I meant the source .tar.gz file for the V8 package, since that is the one that is currently failing. We need to look closer at why that is happening.

Hi @rr1234 :

Thanks for your post, I am facing exactly the issue when installing prophet on MacOS and wondering did you resolve this issue? any solution to share?

Big thanks

Hi Guys,

I was facing the same issue and please follow the steps below to resolve it.
Step 1 : install.packages("matrixStats")
Step 2: install.packages("loo")

Step 3: Sys.setenv(DOWNLOAD_STATIC_LIBV8=1)
Step 4 : install.packages("V8")

Step 5 : install.packages("rstan")
Step 6 : install.packages("prophet")

Hope this helps :slight_smile: