问题
CentOS7下安装rjags失败 installation of package ‘rjags’ had non-zero exit status
详细报错
> install.packages("gbs2ploidy", dependencies=TRUE)
also installing the dependency ‘rjags’
trying URL 'https://cran.rstudio.com/src/contrib/rjags_4-6.tar.gz'
Content type 'application/x-gzip' length 71719 bytes (70 KB)
==================================================
downloaded 70 KB
trying URL 'https://cran.rstudio.com/src/contrib/gbs2ploidy_1.0.tar.gz'
Content type 'application/x-gzip' length 1294606 bytes (1.2 MB)
==================================================
downloaded 1.2 MB
* installing *source* package ‘rjags’ ...
** package ‘rjags’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: pkg-config file for jags 4 unavailable
configure: WARNING: Consider adding the directory containing `jags.pc`
configure: WARNING: to the PKG_CONFIG_PATH environment variable
configure: Attempting legacy configuration of rjags
checking for jags... no
configure: error: "automatic detection of JAGS failed. Please use pkg-config to locate the JAGS library. See the INSTALL file for details."
ERROR: configuration failed for package ‘rjags’
* removing ‘/gpfs_fs/home/jcbagley/R/lib64/R/library/rjags’
ERROR: dependency ‘rjags’ is not available for package ‘gbs2ploidy’
* removing ‘/gpfs_fs/home/jcbagley/R/lib64/R/library/gbs2ploidy’
The downloaded source packages are in
‘/gpfs_fs/home/jcbagley/tmp/RtmpkmTK42/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("gbs2ploidy", dependencies = TRUE) :
installation of package ‘rjags’ had non-zero exit status
2: In install.packages("gbs2ploidy", dependencies = TRUE) :
installation of package ‘gbs2ploidy’ had non-zero exit status
原因与解决方法
问题在于jags的pkg-config文件不可用,所以我们用conda安装后再进行尝试:
#shell下执行
conda install pkg-config jags
export PKG_CONFIG_PATH="~/【conda目录】/lib/pkgconfig"
#R中执行
install.packages("rjags", dependencies=TRUE)
完成

