Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation failed for package ‘ranger’ #669

Closed
wangzitiner opened this issue Apr 13, 2023 · 35 comments
Closed

compilation failed for package ‘ranger’ #669

wangzitiner opened this issue Apr 13, 2023 · 35 comments

Comments

@wangzitiner
Copy link

Hello!
I am trying to install "ranger" on linux with CentOS, and then to install URD. But I met this error, and my gcc version is already suitable. Waiting for your advice, thank you very much!!!

The error is like this:
g++ -std=gnu++11 -I"/usr/local/lib64/R/include" -DNDEBUG -DR_BUILD -I'/usr/local/lib64/R/library/Rcpp/include' -I'/usr/local/lib64/R/library/RcppEigen/include' -I/usr/local/include -fpic -g -O2 -c AAA_check_cpp11.cpp -o AAA_check_cpp11.o
AAA_check_cpp11.cpp:3:2: error: #error Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler.
#error Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler.
^~~~~
make: *** [AAA_check_cpp11.o] Error 1
ERROR: compilation failed for package ‘ranger’

  • removing ‘/usr/local/lib64/R/library/ranger’

The downloaded source packages are in
‘/tmp/Rtmp1OYeEo/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("ranger") :
installation of package ‘ranger’ had non-zero exit status

This is my gcc version :
g++ --version
g++ (GCC) 8.5.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@mnwright
Copy link
Member

The problem is that it tries to compile with -std=gnu++11, which shouldn't be included. Do you have something in your local Makevars file, e.g. in ~/.R/Makevars?

@aschmidt-amplify
Copy link

aschmidt-amplify commented Apr 13, 2023

I was coming to write about this same issue, too. I am running into similar errors on Windows. Is there a ~/.R/Makevars on a Windows machine?

My errors look like

C:/Users/AnthonySchmidt/Documents/R/win-library/4.1/RcppEigen/include/Eigen/src/SparseCore/SparseMatrixBase.h:47:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__vector(2) double'} [-Wignored-attributes]
                      >::type PacketReturnType;
                              ^~~~~~~~~~~~~~~~

@mnwright
Copy link
Member

I expected that the C++14 change causes problems here and there. @wangzitiner which R version is this?

@aschmidt-amplify here is a list where Makevars.win could be.

Generally, a workaround is to install a version <0.14.2 where we switched to C++14.

@wangzitiner
Copy link
Author

wangzitiner commented Apr 14, 2023

@mnwright I tried on both R4.2.2 and R3.6.9, both have the same error.
And it seems that I don't have Makevars on my linux, but I'm not sure if I searched the right way.

Here is the code:
10:22 zhaoqy@wanglab:~$ which Makevars
/usr/bin/which: no Makevars in (/mnt/date3/Project/zhaoqy/.local/bin:/mnt/date3/Project/zhaoqy/miniconda3/condabin:/opt/rh/devtoolset-8/root/usr/bin:/usr/lib64/qt-3.3/bin:/opt/gridview//pbs/dispatcher-sched/bin:/opt/gridview//pbs/dispatcher-sched/sbin:/opt/gridview//pbs/dispatcher/bin/lsf_cmd:/opt/gridview//pbs/dispatcher/bin:/opt/gridview//pbs/dispatcher/sbin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bioware/source/subread-1.6.2-Linux-x86_64/bin:/bioware/homer/bin:/bioware/GraphProt-1.1.3/bin:/bioware/circRNA:/bioware/bin:/bioware/hisat2-2.0.5:/bioware/sratoolkit.2.10.9-centos_linux64/bin:/bioware/source/zhaowq/CogentAP:/bioware/bin:/bioware/bin/SystemPipeR:/bioware/bin/SingleCell:/bioware/bin/ngsplot/bin:/usr/local/python3/bin/:/bioware/meme-5.3.0/bin/:/bioware/source/Bismark-0.22.3:/user/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/bin:/user/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre/bin)

@wangzitiner
Copy link
Author

And also I tried to install "ranger" by conda, the install seems successful, but I still failed when install URD(a Trajectory analysis R package), and still the same kind of error.

1\ Install ranger through anaconda:
12:12 wangzt@wanglab:~$ conda install -c conda-forge r-ranger
Collecting package metadata (current_repodata.json): done
Solving environment: done
...
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

2\ Install URD in R4.2.2:
source("https://raw.githubusercontent.com/farrellja/URD/master/URD-Install.R")
Installing required packages from Bioconductor (BiocManager).
Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
Installing package(s) 'destiny'
还安装相依关系‘ranger’, ‘VIM’

  • installing source package ‘ranger’ ...
    ** 成功将‘ranger’程序包解包并MD5和检查
    ** using staged installation
    ** libs
    g++ -std=gnu++11 -I"/bioware/source/R-4.2.1/include" -DNDEBUG -DR_BUILD -I'/bioware/source/R-4.2.1/library/Rcpp/include' -I'/bioware/source/R-4.2.1/library/RcppEigen/include' -I/usr/local/include -fpic -g -O2 -c AAA_check_cpp11.cpp -o AAA_check_cpp11.o
    AAA_check_cpp11.cpp:3:2: error: #error Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler.
    #error Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler.
    ^~~~~
    make: *** [/bioware/source/R-4.2.1/etc/Makeconf:177: AAA_check_cpp11.o] Error 1
    ERROR: compilation failed for package ‘ranger’
  • removing ‘/bioware/source/R-4.2.1/library/ranger’
    ERROR: dependency ‘ranger’ is not available for package ‘VIM’
  • removing ‘/bioware/source/R-4.2.1/library/VIM’
    ERROR: dependency ‘VIM’ is not available for package ‘destiny’
  • removing ‘/bioware/source/R-4.2.1/library/destiny’

Hope for your help, thank u!

@rps13
Copy link

rps13 commented Apr 14, 2023

The problem is related to R setting the default C++ standard to C++11 on Windows until R version 4.2.3 (for the 4.2.X releases) when the bug was fixed (https://cran.r-project.org/doc/manuals/r-release/NEWS.html). However, I had the same issue on R 4.1.2 even though the corresponding RTools does support C++ 14. My fix was to re-build the package from source myself and adding CXX_STD = CXX14 to src/Makevars.win as advised here: https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-C_002b_002b-code

@wangzitiner
Copy link
Author

@rps13 Thank you so much. I use macOS system, does this problem still exists? (R setting the default C++ standard to C++11 on Windows until R version 4.2.3). And if it exists, will it be easier to directly update by R to 4.2.3?

@rps13
Copy link

rps13 commented Apr 14, 2023

@wangzitiner It was supposed to be a Windows-only issue so I don't think that would be the case for Mac; can you put the contents of your Makeconf which you can find in /Library/Frameworks/R.framework/Resources/etc up?

@wangzitiner
Copy link
Author

wangzitiner commented Apr 14, 2023

@rps13 Sorry, I don't know how to find this content. I use "which" to search "R.framework" and "Resources", both not found. where should I find my Makeconf?

@rps13
Copy link

rps13 commented Apr 14, 2023

@wangzitiner How did you install R? That is where the version from CRAN puts the files.

@wangzitiner
Copy link
Author

wangzitiner commented Apr 14, 2023

@rps13 I am still a tyro in this major. And I don't install R by myself, so please wait me a few minutes to check.

@wangzitiner
Copy link
Author

@mnwright @rps13
This is my Makeconf:
AR = ar
BLAS_LIBS = -L"$(R_HOME)/lib$(R_ARCH)" -lRblas
C_VISIBILITY = -fvisibility=hidden
CC = gcc -std=gnu11
CFLAGS = -g -O2 $(LTO)
CPICFLAGS = -fpic
CPPFLAGS = -I/usr/local/include
CXX = g++ -std=gnu++11
CXXFLAGS = -g -O2 $(LTO)
CXXPICFLAGS = -fpic
CXX11 = g++
CXX11FLAGS = -g -O2 $(LTO)
CXX11PICFLAGS = -fpic
CXX11STD = -std=gnu++11
CXX14 =
CXX14FLAGS = $(LTO)
CXX14PICFLAGS =
CXX14STD =
CXX17 =
CXX17FLAGS = $(LTO)
CXX17PICFLAGS =
CXX17STD =
CXX20 =
CXX20FLAGS = $(LTO)

Should I change the eighth line from "CXX = g++ -std=gnu++11" to "CXX_STD = CXX14"?

@rps13
Copy link

rps13 commented Apr 17, 2023

@wangzitiner You would only need to change gnu++11 to gnu++14 on line 8 but you should just copy line 8 into $HOME/.R/Makevars and modify it there instead of messing with the Makeconf

@wangzitiner
Copy link
Author

I changed it and it warned me because this file is readonly, and I use :wq! to force it to change. Is this situation same as yours?

@rps13
Copy link

rps13 commented Apr 17, 2023

@wangzitiner you should just copy line 8 into $HOME/.R/Makevars and modify it there instead of messing with the Makeconf

@wangzitiner
Copy link
Author

Actually I only found Makeconf, Makeovers still failed to be found.

@rps13
Copy link

rps13 commented Apr 17, 2023

You need to create Makevars yourself e.g.: vi ~/.R/Makevars and then put the modified line 8 in it: CXX = g++ -std=gnu++14

@wangzitiner
Copy link
Author

I just try to install URD again, it seems to achieve a further step like this, but the package "destiny" is still not available, which is so disgusting. And the "gcc -std=gnu11" doesn't change successfully.

Update all/some/none? [a/s/n]: n
Installing URD
Downloading GitHub repo farrellja/URD@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: vctrs (0.6.0 -> 0.6.1 ) [CRAN]
5: RcppArmad... (0.11.4.0.1 -> 0.12.2.0.0) [CRAN]
6: igraph (1.4.1 -> 1.4.2 ) [CRAN]
7: tibble (3.2.0 -> 3.2.1 ) [CRAN]
8: graphlayouts (0.8.2 -> 0.8.4 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 1

gcc -std=gnu11 -I"/bioware/source/R-4.2.1/include" -DNDEBUG -DUSING_R -I. -Icore -Iinclude -Ivendor -I/mnt/date3/Project/wangzt/anaconda3/include/libxml2 -I/mnt/date3/Project/wangzt/anaconda3/include -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DPRPACK_IGRAPH_SUPPORT -DIGRAPH_THREAD_LOCAL=/**/ -I'/bioware/source/R-4.2.1/library/cpp11/include' -I/usr/local/include -fvisibility=hidden -fpic -g -O2 -c vendor/cs/cs_compress.c -o vendor/cs/cs_compress.o
gcc -std=gnu11 -I"/bioware/source/R-4.2.1/include" -DNDEBU

@wangzitiner
Copy link
Author

This is the result, it seems that "ranger" is ok? I am not sure now.

URD installed successfully!
You can load it by typing: library("URD")
Try "?URD" for starting tips.
Warning messages:
1: package(s) not installed when version(s) same as or greater than current; use
force = TRUE to re-install: 'Biobase' 'S4Vectors' 'AnnotationDbi'
2: In i.p(...) : 安装程序包‘vctrs’时退出狀態的值不是0
3: In i.p(...) : 安装程序包‘RcppArmadillo’时退出狀態的值不是0
4: In i.p(...) : 安装程序包‘igraph’时退出狀態的值不是0
5: In i.p(...) : 安装程序包‘tibble’时退出狀態的值不是0
6: In i.p(...) : 安装程序包‘graphlayouts’时退出狀態的值不是0

@rps13
Copy link

rps13 commented Apr 17, 2023

Try loading ranger with library(ranger) to make sure but the other warnings are saying that the packages didn't install correctly (vctrs, RcppArmadillo, etc.)

@wangzitiner
Copy link
Author

I created a Makevars yesterday, but still failed in installation . Only after I changed the Makeconf today then it succeeded. And library(ranger) is completely ok!!

library(ranger)

Thank you so much for your patience !
So kind of you!

@rps13
Copy link

rps13 commented Apr 17, 2023

It's a bit strange Makevars didn't work as it's supposed to override Makeconf

@mnwright
Copy link
Member

If this fails for anyone else, please report here.

@admahood
Copy link

I am having the same problem in Debian linux, R 4.04

@admahood
Copy link

I am having the same problem in Debian linux, R 4.04

Adding the aforementioned line Makevars worked!

@olyerickson
Copy link

Here's what we're doing with our students who need ranger: we issue a bash script called rangerinstall.sh containing the following, which we have them execute:

#!/bin/bash
sed -i -e '$aCXX = g++ -std=gnu++14' ~/.R/Makevars
R -e 'install.packages("ranger",repos="https://cloud.r-project.org/")'
sed '$d' ~/.R/Makevars

All of our students are RStudio Server users, so executing this via the Terminal...

@mnwright
Copy link
Member

@olyerickson They are all working on the same machine?

To be clear: On an up-to-date system this should not happen and these workarounds should not be necessary.

@olyerickson
Copy link

By definition, RStudio Server is a shared, web-accessed service; in a given term we typically might have 60-90 students (plus researchers, et.al.) active on our cluster, most using R. On such a shared resource, updates e.g. to R and its dependencies happen more slowly (often during term breaks).

@mnwright
Copy link
Member

Please re-open if necessary. Anything we can improve to avoid such problems?

@mfoos
Copy link

mfoos commented Nov 1, 2023

Hi! I think it might help to put information about this on the github readme for the package (or a link to this issue thread). There's a big gap between the technical prowess needed to use R vs to diagnose this issue, and folks don't always control whether they have the latest version. Thanks!

@mnwright
Copy link
Member

mnwright commented Nov 2, 2023

What exactly would you put in the readme?

I wouldn't link this issue. It might confuse people and e.g. what @olyerickson writes in their FAQ is wrong (ranger does not specify C++11 anywhere).

I think the major problem was the bug in R (fixed in R 4.2.3) that still specified C++11 for Windows (see https://cran.r-project.org/doc/manuals/r-release/NEWS.html).

@mfoos
Copy link

mfoos commented Nov 3, 2023

I was thinking something like "ranger changed to the C++14 standard with version 0.15.0, if you are using R < 4.2.3 (Windows) or R < 4.1.0 (Mac and Linux) this may cause an error [link to slightly more detailed explanation]" (I'm not totally sure about the latter version, but I came to this issue from R 4.0.2 on an Ubuntu server that I do not have the ability to update).

But then I had the epiphany that it would be less noisy and more direct to put it in the error message (

#error Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler.
) but then I had the second epiphany that supporting an R package is complicated and time-consuming and that's not a good enough reason to ask someone to release a patch.

In any case, I think you're within your rights to do neither, there is certainly a point when "you should just have updated R" is a good response. And one I can use to put pressure on the IT department :)

@mnwright
Copy link
Member

mnwright commented Nov 3, 2023

Thanks! I thought the same with the error message and putting the version requirements somewhere also makes sense. But (as you pointed out) what exactly are those? The R NEWS (linked above) says C++14 is supported since 3.4.0 but the default was changed with 4.1.0 and by accident for Windows only with 4.2.3. Does that mean that people with with R<4.1.0 (Windows: 4.2.3) need something like CXX = g++ -std=gnu++11 in their Makevars? If that is true, there are two options:

  1. Add this to the ranger Makevars.
  2. People have to add it to their own Makevars.

When the change was made, CRAN people said we shouldn't do 1). Writing R Extensions says

Different versions of R have used different default C++ standards, so for maximal portability a package should specify the standard it requires.

but also:

On the other hand, specifying C++11 when the code is valid under C++14 or C++17 reduces future portability.

If this is all correct, we could add a note on how to install ranger with older R versions. Or even add CXX_STD = CXX14 to the ranger Makevars, even though that is not recommended.

What we really need is to specify that we need at least C++14 but that is not possible I think.

@mfoos
Copy link

mfoos commented Nov 6, 2023

That does sort of put you in a bind, although I understand why they'd say not to do # 1.

My perspective is that I arrived at "Error: ranger requires a C++14 compiler, e.g., gcc >= 5 or Clang >= 3.4. You probably have to update your C++ compiler." and then found that I had gcc 7.5, and just had no idea what to do for a week, until I eventually noticed the "C++11" on the console output. At which point I was still confused, hah.

So I guess I think for most users it's fine to ask THEM to do the fancy part (update their R version or modify their Makevars, the latter covering people like me who can't update the R version), and it would go a long way to give context/guidance in that same message. Like, presumably you made an informed decision on how to set up 0.15.0 and it seems like you should get to keep it that way and then also just add a lil note.

@CeceLee-Qian
Copy link

My R is 4.1, still have the same installation issue. Only the binary version can be successfully installed into my Windows CP, all other installation ways have the similar errors reported above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants