无法配置 r-base-core

无法配置 r-base-core

当我尝试在 Ubuntu 16.04 xenial 上安装 R 时,我卡住了,因为r-base-core无法配置。我正在使用通用手册安装失败并尝试手动配置后,r-base-core控制台基本上如下所示:

~$ sudo dpkg --configure r-base-core
   Setting up r-base-core (3.3.2-1xenial0) ...
   dpkg: error processing package r-base-core (--configure):
    subprocess installed post-installation script returned error exit      
    status 10
   Errors were encountered while processing:
   r-base-core

安装后脚本r-base-core.postinst 包含/var/lib/dpkg/info以下内容:

#!/bin/sh
#
# postinst script for the Debian GNU/Linux r-base-core package
# This version originally written by Douglas Bates <[email protected]>
# and now written and maintained by Dirk Eddelbuettel <[email protected]>

set -e

# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/bash_completion.d/R /usr/share/bash-completion/completions/R -- "$@"
# End automatically added section



case "$1" in
  configure)
    # edd 19 Jun 2004   deal with papersize 
    # edd 22 Jun 2004   make that conditional on paperconf
    # edd 25 Oct 2006   rewritten for R 2.4.0 and R_PAPERSIZE_USER
    # edd 21 Jun 2008   rewritten for R 2.7.1 and ucf input 
    # edd 23 Feb 2013   trying to avoid md5sum issues with help from Andy Beckman
    # edd 26 Feb 2013   correct mode of temp. Renviron file with help from Don Armstrong
    tmpRenviron=$(mktemp)
    chmod 0644 "$tmpRenviron"
    cat /usr/lib/R/etc/Renviron.ucf > "$tmpRenviron"
    #if [ -x /usr/bin/paperconf ]; then
        ## get the value we want from Debian's paperconf utility
        papersize=`paperconf`
    ## have perl subst. second expression with $papersize for first
    ## uses the x mod. and curlies to denote the usual s|1st|2nd|
    perl -p -i -e "s{^R_PAPERSIZE_USER=\\$\{R_PAPERSIZE\}}
        {R_PAPERSIZE_USER=\\$\{R_PAPERSIZE-'$papersize'\}}x" "$tmpRenviron"
    #fi
    # edd 21 Jun 2008  whether or not Renviron was modified, ucf will handle it, 
    #                  so tell ucf that file Renviron.ucf is the source for 
    #                  conffile in /etc and register it
    ucf "$tmpRenviron" /etc/R/Renviron
    ucfr r-base-core /etc/R/Renviron
    rm -f "$tmpRenviron"
    #
    #if [ -x /usr/bin/update-menus ]; then
    #  update-menus 
    #fi

    # edd 03 Apr 2003  cf Section 10.1.2 of Debian Policy
    if [ ! -e /usr/local/lib/R ]; then
      if mkdir /usr/local/lib/R 2>/dev/null; then
    chown root:staff /usr/local/lib/R
    chmod 2775 /usr/local/lib/R
      fi
    fi
    if [ ! -e /usr/local/lib/R/site-library ]; then
      if mkdir /usr/local/lib/R/site-library 2>/dev/null; then
    chown root:staff /usr/local/lib/R/site-library
    chmod 2775 /usr/local/lib/R/site-library
      fi
    fi

    #if [ -x /usr/bin/mktexlsr ]; then
    #  mktexlsr /usr/share/texmf
    #fi
    ;;
  abort-upgrade|abort-remove|abort-deconfigure)
    ;;
  *)
    echo "postinst called with unknown argument \`$1'" >&2
    ;;
esac

我已经尝试删除安装后脚本,以便上述配置可以无错误运行,并且实际上可以安装 r-base。但是,R在控制台中输入时,控制台如下所示:

cannot find system Renviron

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error : .onLoad failed in loadNamespace() for 'utils', details:
  call: options(op.utils[toset])
  error: invalid value for 'editor'
Error : .onLoad failed in loadNamespace() for 'utils', details:
  call: options(op.utils[toset])
  error: invalid value for 'editor'
In addition: Warning message:
package ‘utils’ in options("defaultPackages") was not found 
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found 

像这样设置环境变量不会改变任何事情:

export R_HOME=/usr/lib/R/

R安装文件夹的内容为:

~$ ls -l /etc/R
total 40
-rw-r--r-- 1 root root  793 Nov  1 11:45 ldpaths
-rw-r--r-- 1 root root  784 Apr 24  2016 ldpaths.dpkg-old
-rw-r--r-- 1 root root 6304 Nov  1 11:45 Makeconf
-rw-r--r-- 1 root root 6354 Apr 24  2016 Makeconf.dpkg-old
-rw-r--r-- 1 root root  608 Apr 24  2016 Renviron.site
-rw-r--r-- 1 root root 1161 Nov  1 11:45 repositories
-rw-r--r-- 1 root root 1424 Apr 24  2016 repositories.dpkg-old
-rw-r--r-- 1 root root  792 Apr 24  2016 Rprofile.site

显然,当 ucf 应该执行某些操作时,安装后脚本会失败。在将-x参数添加到安装后脚本时:

Setting up r-base-core (3.3.2-1xenial0) ...
+ dpkg-maintscript-helper mv_conffile /etc/bash_completion.d/R /usr/share/bash-completion/completions/R -- configure 
+ mktemp
+ tmpRenviron=/tmp/tmp.MANJybxXxQ
+ chmod 0644 /tmp/tmp.MANJybxXxQ
+ cat /usr/lib/R/etc/Renviron.ucf
+ paperconf
+ papersize=a4
+ perl -p -i -e s{^R_PAPERSIZE_USER=\$\{R_PAPERSIZE\}}
        {R_PAPERSIZE_USER=\$\{R_PAPERSIZE-'a4'\}}x /tmp/tmp.MANJybxXxQ
+ ucf /tmp/tmp.MANJybxXxQ /etc/R/Renviron
dpkg: error processing package r-base-core (--configure):
 subprocess installed post-installation script returned error exit status 10

根据我在网上找到的有关安装后脚本中的 ucf 问题的其他帖子,我在安装后脚本中的 ucf 行中添加了调试级别 3。控制台现在如下所示:

+ dpkg-maintscript-helper mv_conffile /etc/bash_completion.d/R /usr/share/bash-completion/completions/R -- configure 
+ mktemp
+ tmpRenviron=/tmp/tmp.LsP3FSBIRI
+ chmod 0644 /tmp/tmp.LsP3FSBIRI
+ cat /usr/lib/R/etc/Renviron.ucf
+ paperconf
+ papersize=a4
+ perl -p -i -e s{^R_PAPERSIZE_USER=\$\{R_PAPERSIZE\}}
        {R_PAPERSIZE_USER=\$\{R_PAPERSIZE-'a4'\}}x /tmp/tmp.LsP3FSBIRI
+ ucf --debug=3 /tmp/tmp.LsP3FSBIRI /etc/R/Renviron
The new start file is      `/tmp/tmp.LsP3FSBIRI\'
The destination is         `/etc/R/Renviron\' (`\/etc\/R\/Renviron\')
The history is kept under  \'/tmp\'
The file may be cached at \'/var/lib/ucf/cache/:etc:R:Renviron\'
The destination file does not exist.
The old md5sum does not exist.
The new file exists, and has md5sum:
7c899e0d9d42df33d5dfd303ef43c46b  /tmp/tmp.LsP3FSBIRI
Historical md5sums are not available
The new start file is      `/tmp/tmp.LsP3FSBIRI\'
The destination is         `/etc/R/Renviron\' (`\/etc\/R\/Renviron\')
The history is kept under  \'/tmp\'
The file may be cached at \'/var/lib/ucf/cache/:etc:R:Renviron\'
dpkg: error processing package r-base-core (--configure):
 subprocess installed post-installation script returned error exit status 20

相关内容