我在 conda 环境之外的 RStudio 中使用 R(我安装了 miniconda3 来操作 QIIME2)。但是,当我尝试安装 R 包时,我总是收到错误,因为 R 总是在错误的目录中查找。我几乎总是安装了包,因此运行sudo apt-get
无法解决问题。我在 Ubunutu 18.04 上运行 R 3.6.1。
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_NZ.UTF-8 LC_NUMERIC=C LC_TIME=en_NZ.UTF-8 LC_COLLATE=en_NZ.UTF-8 LC_MONETARY=en_NZ.UTF-8 LC_MESSAGES=en_NZ.UTF-8
[7] LC_PAPER=en_NZ.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] usethis_1.5.1 devtools_2.0.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 ps_1.3.0 prettyunits_1.0.2 rprojroot_1.3-2 withr_2.1.2 digest_0.6.20 crayon_1.3.4 assertthat_0.2.1 R6_2.4.0
[10] backports_1.1.4 magrittr_1.5 rlang_0.4.0 cli_1.1.0 fs_1.3.1 remotes_2.1.0 rstudioapi_0.10 testthat_2.2.1 callr_3.3.1
[19] desc_1.2.0 tools_3.6.1 glue_1.3.1 pkgload_1.0.2 compiler_3.6.1 processx_3.4.1 pkgbuild_1.0.4 sessioninfo_1.1.1 memoise_1.1.0
我的 .libPaths() 配置如下:
> .libPaths()
[1] "/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6" "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"
并echo $PATH
在终端返回:
barefootbushman@barefootbushman:~/Documents/DWER Thresholds/HMSIC Example$ echo $PATH
/home/linuxbrew/.linuxbrew/bin:/etc/:/usr/:/usr/lib/x86_64-linux-gnu/pkgconfig/:/home/linuxbrew/.linuxbrew/bin:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/x86_64-linux-gnu:/usr/lib/:/home/linuxbrew/.linuxbrew/bin:/usr/include/:/usr/:/usr/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/bin:/home/barefootbushman/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
我有三个主要问题。第一个是安装BayesLogit
- 一个 R 包。我得到以下信息:
> library(devtools)
> install_url('https://cran.r-project.org/src/contrib/Archive/BayesLogit/BayesLogit_0.6.tar.gz')
Downloading package from url: https://cran.r-project.org/src/contrib/Archive/BayesLogit/BayesLogit_0.6.tar.gz
Your system is ready to build packages!
✔ checking for file ‘/tmp/RtmpFgmgVU/remotes10aa2c0130d5/BayesLogit/DESCRIPTION’ ...
─ preparing ‘BayesLogit’:
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ looking to see if a ‘data/datalist’ file should be added
─ building ‘BayesLogit_0.6.tar.gz’
Installing package into ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package ‘BayesLogit’ ...
** using staged installation
** libs
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c Matrix.cpp -o Matrix.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c MatrixFrame.cpp -o MatrixFrame.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RRNG.cpp -o RRNG.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RNG.cpp -o RNG.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c FSF_nmix.cpp -o FSF_nmix.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c LogitWrapper.cpp -o LogitWrapper.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c PolyaGamma.cpp -o PolyaGamma.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c PolyaGammaAlt.cpp -o PolyaGammaAlt.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c PolyaGammaSP.cpp -o PolyaGammaSP.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -I"/usr/share/R/include" -DNDEBUG -DUSE_R -DNDEBUG -DDISABLE_SINGLE -DNTHROW -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c InvertY.cpp -o InvertY.o
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o BayesLogit.so Matrix.o MatrixFrame.o RRNG.o RNG.o FSF_nmix.o LogitWrapper.o PolyaGamma.o PolyaGammaAlt.o PolyaGammaSP.o InvertY.o -lblas -lgfortran -lm -lquadmath -llapack -L/usr/lib/R/lib -lR
/home/barefootbushman/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lblas
/home/barefootbushman/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -llapack
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'BayesLogit.so' failed
make: *** [BayesLogit.so] Error 1
ERROR: compilation failed for package ‘BayesLogit’
* removing ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6/BayesLogit’
Error: Failed to install 'unknown package' from URL:
(converted from warning) installation of package ‘/tmp/RtmpFgmgVU/file10aaf61ed1/BayesLogit_0.6.tar.gz’ had non-zero exit status
>
我知道lblas
并且lapack
安装在以下文件夹中:
(base) barefootbushman@barefootbushman:~$ whereis lblas
lblas: /usr/lib/lblas.so
(base) barefootbushman@barefootbushman:~$ whereis lapack
lapack: /usr/lib/x86_64-linux-gnu/lapack
我如何告诉 R 查看正确的文件夹?
其次,在更新/安装新软件包时,我不断收到ANTICONF ERROR
以下是一个例子:
> install.packages("curl")
Installing package into ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/curl_4.0.tar.gz'
Content type 'application/x-gzip' length 379180 bytes (370 KB)
==================================================
downloaded 370 KB
* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/x86_64-linux-gnu
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
* deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
* rpm: libcurl-devel (Fedora, CentOS, RHEL)
* csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6/curl’
* restoring previous ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6/curl’
Warning in install.packages :
installation of package ‘curl’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpFgmgVU/downloaded_packages’
我知道我已经libcurl
安装在这些位置:
(base) barefootbushman@barefootbushman:~$ whereis libcurl
libcurl: /usr/lib/x86_64-linux-gnu/libcurl.la /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libcurl.a
几乎每个 R 包都会发生这种情况,即使源包不同。
第三个问题与 zlib.h 有关。再次查找错误的目录
> install.packages("git2r")
Installing package into ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/git2r_0.26.1.tar.gz'
Content type 'application/x-gzip' length 1214783 bytes (1.2 MB)
==================================================
downloaded 1.2 MB
* installing *source* package ‘git2r’ ...
** package ‘git2r’ successfully unpacked and MD5 sums checked
** using staged installation
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
configure: Package dependency requirement 'libgit2 >= 0.26.0' could not be satisfied.
-----------------------------------------------------------------------
Unable to find the libgit2 library on this system. Building 'git2r'
using the bundled source of the libgit2 library.
To build git2r with a system installation of libgit2, please install:
libgit2-dev (package on e.g. Debian and Ubuntu)
libgit2-devel (package on e.g. Fedora, CentOS and RHEL)
libgit2 (Homebrew package on OS X)
and try again.
If the libgit2 library is installed on your system but the git2r
configuration is unable to find it, you can specify the include and
lib path to libgit2 with:
given you downloaded a tar-gz archive:
R CMD INSTALL git2r-.tar.gz --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'
or cloned the GitHub git2r repository into a directory:
R CMD INSTALL git2r/ --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'
or download and install git2r in R using
install.packages('git2r', type='source', configure.vars='LIB_DIR=-L/path/to/libs INCLUDE_DIR=-I/path/to/headers')
On macOS, another possibility is to let the configuration
automatically download the libgit2 library from the Homebrew
package manager with:
R CMD INSTALL git2r-.tar.gz --configure-vars='autobrew=yes'
or
R CMD INSTALL git2r/ --configure-vars='autobrew=yes'
or
install.packages('git2r', type='source', configure.vars='autobrew=yes')
-----------------------------------------------------------------------
configure: Attempting configuration of bundled libgit2
checking size of void*... 8
checking for library containing inflate... no
checking for zlib... yes
checking for library containing EVP_EncryptInit... no
checking for openssl... yes
checking for library containing libssh2_version... no
checking for libssh2... yes
checking for ANSI C header files... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for struct stat.st_mtim... yes
checking for struct stat.st_mtimespec... no
checking for struct stat.st_mtime_nsec... no
checking for struct stat.st_mtim.tv_nsec... yes
checking for futimens... no
checking for qsort_r... no
checking for qsort_s... no
----- Results of the git2r package configure -----
HTTPS transport......................: yes
LibSSH2 to enable the SSH transport..: yes
--------------------------------------------------
configure: creating ./config.status
config.status: creating src/Makevars_libgit2
** libs
/home/barefootbushman/miniconda3/bin/x86_64-conda_cos6-linux-gnu-cc -I"/usr/share/R/include" -DNDEBUG -I. -Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser -DGIT_ARCH_64 -DGIT_OPENSSL=1 -DGIT_HTTPS=1 -DGIT_SSH -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DLIBGIT2_NO_FEATURES_H -DR_NO_REMAP -DSTRICT_R_HEADERS -DGIT_SHA1_OPENSSL=1 -DGIT_USE_STAT_MTIM -DGIT_USE_NSEC -DGIT_DEPRECATE_HARD -DGIT2R_HAVE_BUF_DISPOSE -DGIT2R_HAVE_OBJECT_ANY -DGIT2R_HAVE_GIT_ERROR -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c libgit2/src/apply.c -o libgit2/src/apply.o
In file included from libgit2/src/delta.h:10:0,
from libgit2/src/apply.c:22:
libgit2/src/pack.h:13:10: fatal error: zlib.h: No such file or directory
#include <zlib.h>
^~~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:167: recipe for target 'libgit2/src/apply.o' failed
make: *** [libgit2/src/apply.o] Error 1
ERROR: compilation failed for package ‘git2r’
* removing ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6/git2r’
* restoring previous ‘/home/barefootbushman/R/x86_64-pc-linux-gnu-library/3.6/git2r’
Warning in install.packages :
installation of package ‘git2r’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpFgmgVU/downloaded_packages’
再次,zlib
在这里:
(base) barefootbushman@barefootbushman:~$ whereis zlib.h
zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz
任何帮助解决这些问题的帮助都将不胜感激。我需要继续做大量的工作,并花了几天时间试图了解如何更改 R 寻找这些文件的目录。