[Rd] R CMD INSTALL fails if cd prints stuff to stdout ... (PR#8363)

p.lijnzaad@med.uu.nl p.lijnzaad at med.uu.nl
Fri Dec 2 17:42:05 CET 2005


--Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)
Content-type: text/plain; charset="us-ascii"
Content-disposition: inline
Content-transfer-encoding: 7bit

Dear all,

I came across puzzling behaviour of R CMD INSTALL, which I tracked down to the 
fact that in some shells (or in some user customizations of them), the cd 
command prints out the new directory. As a result, the $pkgs variable gets a 
wrong value, e.g.in the following transcript: 

philip at gen031:tmp$ R CMD INSTALL  GlobalAncova          
/usr/lib/R/bin/INSTALL: line 873: cd: /home/philip/tmp/GlobalAncova
/var/tmp/philip/misc/GlobalAncova: No such file or directory
sed: can't read DESCRIPTION: No such file or directory
ERROR: no 'Package' field in 'DESCRIPTION'
philip at gen031:tmp$ 

The error at line 873 is due to the variable $pkgs containing the string 
'/home/philip/tmp/GlobalAncova
/var/tmp/philip/misc/GlobalAncova'

(i.e. including the new line. Incidentally, /home/philip/tmp dir is a symlink 
to /var/tmp/philip/misc; hence the non-identical directory names). 

A simple fix (cd "${1}" > /dev/null 2>&1 && ${GETWD}) takes care of this, and 
should work under sh, ksh, bourne shell, zsh. A context diff is attached; I 
hope this will prove useful. Kind regards,


                                                                       Philip

-- 
Philip Lijnzaad
Genomics Laboratory
Dept. of Biomedical Genetics
University Medical Center (UMC), Utrecht
Stratenum room 2.201 (on Mondays and Thursdays not in after 14.45)
MSN chat (*NOT* email): philip_lijnzaad at hotmail.com
P.O. Box 85060, 3508 AB Utrecht
(Universiteitsweg 100, 3584 CG Utrecht)
The Netherlands
tel: +31 (0)30 253 8464
fax: +31 (0)30 253 8479

--Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)
Content-type: text/x-diff; charset="us-ascii"; name="INSTALL.patch"
Content-disposition: attachment; filename="INSTALL.patch"
Content-transfer-encoding: 7bit

*** INSTALL~	Wed Jun 22 11:09:59 2005
--- INSTALL	Fri Dec  2 17:08:50 2005
***************
*** 127,136 ****
  get_packages () {
    ## get the full path names to all packages contained in $1.
    ## NOTE: modifies pkgs!
    if grep "^Contains:" "${1}/DESCRIPTION" >/dev/null; then
      bundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`
      for p in ${bundlepkg}; do
!       pkgs="${pkgs} \"`cd "${1}/${p}" && ${GETWD}`\""
        if test -f "${1}/${p}/DESCRIPTION.in"; then
          ## Try being defensive about missing final newlines, or extra
  	## empty lines.
--- 127,138 ----
  get_packages () {
    ## get the full path names to all packages contained in $1.
    ## NOTE: modifies pkgs!
+   PROMPT_COMMAND=
+   BASH_COMMAND=
    if grep "^Contains:" "${1}/DESCRIPTION" >/dev/null; then
      bundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`
      for p in ${bundlepkg}; do
!       pkgs="${pkgs} \"`cd "${1}/${p}>/dev/null 2>&1" && ${GETWD}`\""
        if test -f "${1}/${p}/DESCRIPTION.in"; then
          ## Try being defensive about missing final newlines, or extra
  	## empty lines.
***************
*** 139,145 ****
        fi
      done
    else
!     pkgs="${pkgs} \"`cd "${1}" && ${GETWD}`\""
    fi
  }
  
--- 141,147 ----
        fi
      done
    else
!     pkgs="${pkgs} \"`cd "${1}" > /dev/null 2>&1 && ${GETWD}`\""
    fi
  }
  

--Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)--



More information about the R-devel mailing list