首页 > 解决方案 > R:安装 ggplot2 的问题

问题描述

我在 Ubuntu 18.04 上的 RStudio 1.3.1093 中运行 R 版本 4.0.3 (2020-10-10) - “Bunny-Wunnies Freak Out”。ggplot2当我遇到以下错误消息时,我尝试安装该软件包:

Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘testthat’, ‘isoband’

trying URL 'https://cloud.r-project.org/src/contrib/testthat_3.0.1.tar.gz'
Content type 'application/x-gzip' length 678199 bytes (662 KB)
==================================================
downloaded 662 KB

trying URL 'https://cloud.r-project.org/src/contrib/isoband_0.2.3.tar.gz'
Content type 'application/x-gzip' length 1902568 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.3.3.tar.gz'
Content type 'application/x-gzip' length 3058840 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *source* package ‘testthat’ ...
** package ‘testthat’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c reassign.c -o reassign.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-catch.cpp -o test-catch.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-example.cpp -o test-example.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o testthat.so init.o reassign.o test-catch.o test-example.o test-runner.o -L/usr/lib/R/lib -lR
installing to /home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘testthat’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs/testthat.so':
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs/testthat.so)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/testthat’
Warning in install.packages :
  installation of package ‘testthat’ had non-zero exit status
ERROR: dependency ‘testthat’ is not available for package ‘isoband’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/isoband’
Warning in install.packages :
  installation of package ‘isoband’ had non-zero exit status
ERROR: dependency ‘isoband’ is not available for package ‘ggplot2’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/ggplot2’
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

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

我从第一条错误消息中发现问题testthat丢失了。我去了这里并尝试运行此命令,希望可以将这些 prereqs 安装到 ggplot2 withr::with_makevars(c(PKG_LIBS = "-liconv"), install.packages("testthat"), assignment = "+=") 但是,我仍然遇到更多错误:

Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/testthat_3.0.1.tar.gz'
Content type 'application/x-gzip' length 678199 bytes (662 KB)
==================================================
downloaded 662 KB

* installing *source* package ‘testthat’ ...
** package ‘testthat’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c reassign.c -o reassign.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-catch.cpp -o test-catch.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-example.cpp -o test-example.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o testthat.so init.o reassign.o test-catch.o test-example.o test-runner.o -liconv -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -liconv
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:10: recipe for target 'testthat.so' failed
make: *** [testthat.so] Error 1
ERROR: compilation failed for package ‘testthat’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/testthat’
Warning in install.packages :
  installation of package ‘testthat’ had non-zero exit status

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

至于isoband,我收到以下信息:

Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependency ‘testthat’

trying URL 'https://cloud.r-project.org/src/contrib/testthat_3.0.1.tar.gz'
Content type 'application/x-gzip' length 678199 bytes (662 KB)
==================================================
downloaded 662 KB

trying URL 'https://cloud.r-project.org/src/contrib/isoband_0.2.3.tar.gz'
Content type 'application/x-gzip' length 1902568 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

* installing *source* package ‘testthat’ ...
** package ‘testthat’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c reassign.c -o reassign.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-catch.cpp -o test-catch.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-example.cpp -o test-example.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -DCOMPILING_TESTTHAT     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o testthat.so init.o reassign.o test-catch.o test-example.o test-runner.o -L/usr/lib/R/lib -lR
installing to /home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘testthat’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs/testthat.so':
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/nick/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-testthat/00new/testthat/libs/testthat.so)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/testthat’
Warning in install.packages :
  installation of package ‘testthat’ had non-zero exit status
ERROR: dependency ‘testthat’ is not available for package ‘isoband’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/4.0/isoband’
Warning in install.packages :
  installation of package ‘isoband’ had non-zero exit status

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

标签: rgcc

解决方案


推荐阅读