How can I deal with this nloptr error in R? - r

init_nloptr.c:35:10: fatal error: 'nlopt.h' file not found
#include "nlopt.h"
^~~~~~~~~
1 error generated.
make: *** [init_nloptr.o] Error 1
ERROR: compilation failed for package 'nloptr'
* removing '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/nloptr'
Warning in install.packages :
installation of package 'nloptr' had non-zero exit status
I got this error message when I installed nloptr package which need to install mi package.

From the path showing up in the error message, it looks like you're running on macOS.
If so, you must install the nlopt system library before installing nloptr.
Hopefully you have Homebrew installed (if not, please reply/comment and I will attach some further info), hence open the Terminal and run
brew install nlopt
At the end of the brew install command, go back to R and install nloptr.

Related

Unable to install package "quanteda.textstats" in R under Ubuntu 22.04.1 LTS

I am trying to install the package quanteda.textstats in R under Ubuntu Version 22.04.1 LTS.
I initially ran:
install.packages("quanteda.textstats")
where I got an error message saying it could not install the dependency proxyC. I was able to install that, but I still get an error message when running the above code.
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: quanteda.textstats.so] Error 1
ERROR: compilation failed for package ‘quanteda.textstats’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/4.2/quanteda.textstats’
Warning in install.packages :
installation of package ‘quanteda.textstats’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpuUtAq1/downloaded_packages’
I would guess I am missing certain dependencies, but I am unable to figure out what -llapack and -lblas stands for.
I also tried running the github install (option 3):
remotes::install_github("quanteda/quanteda.textstats")
but there as well I get a similar error:
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: quanteda.textstats.so] Error 1
ERROR: compilation failed for package ‘quanteda.textstats’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/4.2/quanteda.textstats’
Warning message:
In i.p(...) :
installation of package ‘/tmp/RtmpuUtAq1/file17581cc7f39c/quanteda.textstats_0.96.tar.gz’ had non-zero exit status
Can anybody help please?
Your are trying to compile the package which requires to have certain system dependencies installed, in this case lblas and llapack. This is not the recommended way to install R packages on Ubuntu. Instead you should install them as PPAs as described on CRAN.
If you insist on compiling the package yourself, install the dependencies via apt in the system terminal:
sudo apt-get install libblas-dev liblapack-dev

How to install edgeR package using R4.2.0, BiocManager?

I tried to install edgeR with the following:
if (!require("BiocManager", quietly = TRUE)); install.packages("BiocManager"; BiocManager::install("edgeR")
This is the message I got
Bioconductor version 3.15 (BiocManager 1.30.18), R 4.2.0 (2022-04-22)
Installing package(s) 'edgeR' Warning: unable to access index for
repository
https://bioconductor.org/packages/3.15/bioc/bin/macosx/big-sur-arm64/contrib/4.2:
cannot open URL
'https://bioconductor.org/packages/3.15/bioc/bin/macosx/big-sur-arm64/contrib/4.2/PACKAGES'
Warning: unable to access index for repository
https://bioconductor.org/packages/3.15/data/annotation/bin/macosx/big-sur-arm64/contrib/4.2:
cannot open URL
'https://bioconductor.org/packages/3.15/data/annotation/bin/macosx/big-sur-arm64/contrib/4.2/PACKAGES'
Warning: unable to access index for repository
https://bioconductor.org/packages/3.15/data/experiment/bin/macosx/big-sur-arm64/contrib/4.2:
cannot open URL
'https://bioconductor.org/packages/3.15/data/experiment/bin/macosx/big-sur-arm64/contrib/4.2/PACKAGES'
Warning: unable to access index for repository
https://bioconductor.org/packages/3.15/workflows/bin/macosx/big-sur-arm64/contrib/4.2:
cannot open URL
'https://bioconductor.org/packages/3.15/workflows/bin/macosx/big-sur-arm64/contrib/4.2/PACKAGES'
Warning: unable to access index for repository
https://bioconductor.org/packages/3.15/books/bin/macosx/big-sur-arm64/contrib/4.2:
cannot open URL
'https://bioconductor.org/packages/3.15/books/bin/macosx/big-sur-arm64/contrib/4.2/PACKAGES'
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘edgeR’
Do you want to attempt to install these from sources? (Yes/no/cancel)
so I pressed yes, then,i got the warning message
ld: warning: directory not found for option
'-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
ld: warning: directory not found for option
'-L/opt/R/arm64/gfortran/lib' ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see
invocation) make: *** [edgeR.so] Error 1 ERROR: compilation failed for
package ‘edgeR’
removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/edgeR’
The downloaded source packages are in
‘/private/var/folders/kt/6_fbqvnx7p94hxygb7x6qbnc0000gr/T/RtmpG39FBI/downloaded_packages’
Warning message: In install.packages(...) : installation of package
‘edgeR’ had non-zero exit status
Please advise on what I should to fix this problem.
As a Macbook pro (Monterey) M1 user, I re-installed R package (R-4.2.0.pkg), and removed the old package (R-4.2.0-arm64.pkg). This allowed me to use BiocManager to install other packages.
I'm also on an Apple Silicon Mac. I had assorted previous R installs via homebrew and others. Removing all existing R installations (check via Terminal with 'which R') then reinstalling from a fresh download of the arm64 build did the trick.

problem installing ComplexHeatmap. ERROR: compilation failed for package ‘cluster’

i am installing an R package called complex heatmaps (https://jokergoo.github.io/ComplexHeatmap-reference/book/). I get this error. So far i just identified it might be do to this package : https://packages.debian.org/buster/r-cran-cluster but i am not sure what to do at all. Thats why i am writing you.
Thanks a lot for your help
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'cluster.so' failed
make: *** [cluster.so] Error 1
ERROR: compilation failed for package ‘cluster’
* removing ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.6/cluster’
Error: Failed to install 'ComplexHeatmap' from GitHub:
(converted from warning) installation of package ‘cluster’ had non-zero exit status
The error message indicates that you are missing libfortran.so. You might even miss more tools necessary for installing R packages from source. How to install this depends on the Linux distribution you are using. For Debian, which you mention in the question, this would be
sudo apt install r-base-dev
If you want to speed up package installation, you can also use the binary packages available in Debian, i.e.
sudo apt install r-cran-cluster

How to fix Error installing RCurl on Mac OS X from source: 'curl/curl.h' file not found

Trying to reinstall RCurl from source so it can support sftp (having just installed libssh2 using homebrew):
install.packages("RCurl", type = "source")
I then get:
In file included from base64.c:1:
./Rcurl.h:4:10: fatal error: 'curl/curl.h' file not found
#include <curl/curl.h>
^~~~~~~~~~~~~
1 error generated.
make: *** [base64.o] Error 1
ERROR: compilation failed for package ‘RCurl’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RCurl’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RCurl’
Warning in install.packages :
installation of package ‘RCurl’ had non-zero exit status
I've tried Googling and looking on StackOverflow and there are plenty of threads on Debian, Linux, Ubuntu and Windows and none on Mac OS X hence this post.
Any ideas? Please help.

rgdal installation error: core dumped when finalizing install

I'm currently using linux subsystem on Windows.
Few days ago I've installed microsoft-r and RStudio and tried to install a rgdal package(ultimately I will install tmap and tmaptools packages). Of course, libgdal-dev and its dependencies are correctly configured in the way I've known.
Here's a error message when R finalizes the installation of rgdal: (truncated)
*** installing vignettes
** testing if installed package can be loaded
sh: line 1: 8835 aborted (core dumped) '/usr/lib64/microsoft-r/3.4/lib64/R/bin/R' --no-save --slave 2>&1 < '/tmp/RtmpDpn26L/file1f726636ef3e'
ERROR: loading failed
* removing '/home/felix/R/x86_64-pc-linux-gnu-library/3.4/rgdal'
Warning in install packages:
installation of package 'rgdal' had non-zero exit status
`
Does anyone have a similar experience like my case?
Thanks in advance.

Resources