Unable to install igraph on Mac for R

I’m getting the same error regardless of the version I attempt to install and whether I attempt to install via CRAN or github. I’d ideally like to install the most recent version via CRAN. I’m on an M1 mac with OS Monterey 12.0.1.

This is the error message I get:

core/centrality/prpack.cpp: In function ‘int igraph_i_personalized_pagerank_prpack(const igraph_t*, igraph_vector_t*, igraph_real_t*, igraph_vs_t, igraph_bool_t, igraph_real_t, const igraph_vector_t*, const igraph_vector_t*)’:
core/centrality/prpack.cpp:42:17: error: ‘nullptr’ was not declared in this scope
     double *u = nullptr;
make: *** [core/centrality/prpack.o] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/insert/fake/fileshare/R/x86_64-pc-linux-gnu-library/4.2/igraph’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpNwX4xp/file2ecb6004e0c3/igraph_1.5.0.9009.tar.gz’ had non-zero exit status

Has anyone run into a similar issue in the past? I’ve tried looking all over google/stackoverflow and couldn’t find anything here either, but it’s possible I missed something.

Where did you obtain R, and which R version do you have?

If you are not experienced with compiling software from sources, then

  • Please get R directly from CRAN, https://cloud.r-project.org/
  • Make sure that you have the latest R version (currently 4.3), and definitely not older than the previous version (currently 4.2).

Then you will be able to install pre-compiled binaries instead of having to build igraph yourself.

For reference, the troubleshooting page is here:

Hi szhorvat, thanks for the reply.

I downloaded R from CRAN and I’m currently using 4.2.2

I read through that installation troubleshooting page before I created this page, but I didn’t find anything that helped with my issue. Based on everything I’ve mentioned it seems like I should just be able to install the package from CRAN as per usual, but I get the same error I posted above and I haven’t been able to find posts on other forums where people have run into the same error. I might have missed the portion that would have helped with this issue, if so I apologize.

That is quite strange, as if you have 4.2, then you should be getting the binary (i.e. pre-compiled) version by default.

Can you run the following in a terminal, and post the output of each command?

which R
R --version
R CMD config --all

Do you have an ~/.R/Makevars file and if yes, what are its contents?

All that said, I would recommend upgrading to 4.3.1 unless you have a specific reason not to.

Hmm maybe the second one explains it? Still a bit confusing. It seems to indicate I’m running R 3.6.0, but R studio is indicating I’m running 4.2.2 in the top right of R studio.

bash-4.2$ which R

bash-4.2$ R --version
WARNING: ignoring environment value of R_HOME
R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see

Here’s the results of the 3rd command:

bash-4.2$ R CMD config --all
WARNING: ignoring environment value of R_HOME
CC = gcc -m64 -std=gnu99
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
CPP = gcc -m64 -std=gnu99 -E
CPPFLAGS = -I/usr/local/include
CXX = g++
CXXCPP = g++ -E
CXXFLAGS = -O3 -march=native -Wno-ignored-attributes
CXX98 = g++ -m64
CXX98STD = -std=gnu++98
CXX98FLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
CXX11 = g++
CXX11STD = -std=c++11
CXX11FLAGS = -O3 -march=native -Wno-ignored-attributes
CXX14 = g++
CXX14STD = -std=c++14
CXX14FLAGS = -O3 -march=native -Wno-ignored-attributes
CXX17 = g++
CXX17STD = -std=c++17
CXX17FLAGS = -O3 -march=native -Wno-ignored-attributes
DYLIB_LD = gcc -m64 -std=gnu99
DYLIB_LDFLAGS = -shared -fopenmp
FC = gfortran -m64
F77 = gfortran -m64
FFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -I/usr/lib64/gfortran/modules
FLIBS = -lgfortran -lm -lquadmath
FCFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
SAFE_FFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -I/usr/lib64/gfortran/modules -msse2 -mfpmath=sse
OBJC = gcc
OBJCFLAGS = -g -O2 -fobjc-exceptions
JAVA = /bin/java
JAVAC = /bin/javac
JAVAH = /bin/javah
JAR = /bin/jar
JAVA_HOME = /usr/lib/jvm/jre-1.8.0-ibm
JAVA_LIBS = -L/usr/lib/jvm/java-1.8.0-openjdk- -ljvm
JAVA_CPPFLAGS = -I/usr/lib/jvm/jre-1.8.0-ibm/../include -I/usr/lib/jvm/jre-1.8.0-ibm/../include/linux
LDFLAGS = -Wl,-z,relro
SHLIB_CXX98LD = g++ -m64 -std=gnu++98
SHLIB_CXX11LD = g++ -std=c++11
SHLIB_CXX14LD = g++ -std=c++14
SHLIB_CXX17LD = g++ -std=c++17
SHLIB_LD = gcc -m64 -std=gnu99
TCLTK_CPPFLAGS = -I/usr/include -I/usr/include
TCLTK_LIBS = -L/usr/lib64 -ltcl8.5 -L/usr/lib64 -ltk8.5 -lX11
BLAS_LIBS = -L/usr/lib64/R/lib -lRblas
LAPACK_LIBS = -L/usr/lib64/R/lib -lRlapack
MAKE = make
LIBnn = lib64

You said you are using a Mac with an ARM CPU, macOS Monterey and R 4.2. But what you are showing here is RedHat Linux, Intel CPU and R 3.6.

I’m remoting into the redhat server from the mac, I should have been more specific originally. The 3.6 part is confusing because R studio is showing something else in the UI but I guess I’ll work on it from that angle. Thank you

In RStudio, you see the R installed on your Mac. The software on your Mac is completely separate from the software on the remote Linux machine you are using. You stated,

but it seems this was not correct. You were in fact running R on a Linux computer with an Intel CPU, right?

I suggest that you do not use such an outdated version of R, but if you still want to go ahead and try to resolve the issue on this Linux machine, please post:

  • Your operating system and its version (which RHEL?)
  • Output of uname -a and lsb_release -a
  • Output of gcc --version and g++ --version
  • A few lines from before the error message, which will hopefully show the compiler command that was run