【发布时间】:2021-03-18 18:31:15
【问题描述】:
我已经创建了一个基于 Centos7 的 docker 镜像,并使用下面的 Dockerfile 安装了 R:
FROM centos:7
ENV TZ=Etc/UTC
# OS Dependencies
RUN yum install -y \
epel-release \
centos-release-scl-rh \
openblas-Rblas \
devtoolset-8-toolchain \
tre-devel \
wget \
libcurl-devel \
&& yum group install -y "Development Tools"
# Install R
RUN yum install -y \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/libRmath-devel-4.0.2-1.sdl7.x86_64.rpm \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/libRmath-4.0.2-1.sdl7.x86_64.rpm \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/R-java-devel-4.0.2-1.sdl7.x86_64.rpm \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/R-devel-4.0.2-1.sdl7.x86_64.rpm \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/R-core-devel-4.0.2-1.sdl7.x86_64.rpm \
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/R-core-4.0.2-1.sdl7.x86_64.rpm
我正在尝试安装 R 包 rlang,但收到与“C99”模式相关的错误,我无法解决。
> install.packages("rlang", repos = "https://cran.rstudio.org")
Installing package into '/usr/lib64/R/library'
(as 'lib' is unspecified)
trying URL 'https://cran.rstudio.org/src/contrib/rlang_0.4.10.tar.gz'
Content type 'application/x-gzip' length 915685 bytes (894 KB)
==================================================
downloaded 894 KB
* installing *source* package 'rlang' ...
** package 'rlang' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -m64 -I"/usr/include/R" -DNDEBUG -I./lib/ -I/usr/local/include -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c capture.c -o capture.o
gcc -m64 -I"/usr/include/R" -DNDEBUG -I./lib/ -I/usr/local/include -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c export.c -o export.o
In file included from export.c:1:0:
export/exported.c: In function 'rlang_env_bind_list':
export/exported.c:93:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (r_ssize i = 0; i < n; ++i) {
^
export/exported.c:93:3: note: use option -std=c99 or -std=gnu99 to compile your code
In file included from export.c:1:0:
export/exported.c: In function 'rlang_is_string':
export/exported.c:572:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (r_ssize i = 0; i < n; ++i) {
^
make: *** [export.o] Error 1
ERROR: compilation failed for package 'rlang'
* removing '/usr/lib64/R/library/rlang'
The downloaded source packages are in
'/tmp/RtmpEmr8lk/downloaded_packages'
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages("rlang", repos = "https://cran.rstudio.org") :
installation of package 'rlang' had non-zero exit status
2: In file.create(f.tg) :
cannot create file '/usr/share/doc/R-4.0.2/html/packages.html', reason 'No such file or directory'
3: In make.packages.html(.Library) : cannot update HTML package index
该错误与here 讨论的错误相同,但我正在寻找一种可以在图像构建期间实现的解决方案(即环境变量或更改为 R 配置文件),该解决方案对于那些使用映像并在将来安装 R 包,允许它们通过简单的调用 install.packages() 进行安装,而不必为每个包安装使用 withr::with_makevars()。
【问题讨论】:
-
你能用 CentOS8 镜像代替吗?
-
@dbush 不幸的是,由于其他一些依赖项的可用性,我不能(我不知道细节,这正是 SA 告诉我的)。
-
设置环境变量
CFLAGS="-std=c99"有帮助吗?
标签: r c dockerfile centos7 c99