You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/04/24 04:49:55 UTC

[spark] branch branch-3.0 updated: [SPARK-31510][R][BUILD] Set setwd in R documentation build

This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new a0a673c  [SPARK-31510][R][BUILD] Set setwd in R documentation build
a0a673c is described below

commit a0a673cd03fe47e9b22e67c8f69d73ee5dfc32f0
Author: HyukjinKwon <gu...@apache.org>
AuthorDate: Wed Apr 22 00:38:57 2020 +0900

    [SPARK-31510][R][BUILD] Set setwd in R documentation build
    
    Seems like in certain environment, it requires to set `setwd` as below:
    
    ```
    > library(devtools); devtools::document(pkg="./pkg", roclets=c("rd"))
    Loading required package: usethis
    Error: Could not find package root, is your working directory inside a package?
    ```
    
    see also https://stackoverflow.com/questions/52670051/how-to-troubleshoot-error-could-not-find-package-root and https://groups.google.com/forum/#!topic/rdevtools/79jjjdc_wjg
    
    We can make up another story too. For example, if you set a specific directory in your `~/.Rprofile`, then R documentation build will fail as below:
    
    ```
    echo 'setwd("~")' > ~/.Rprofile
    sh R/create-rd.sh
    ```
    
    ```
    Using R_SCRIPT_PATH = /usr/local/bin
    Loading required package: usethis
    Error: Can't find './pkg'.
    Execution halted
    ```
    
    This PR proposes to set the `setwd` explicitly so it does not get affected on the global environment.
    
    To make R dev env more independent.
    
    No, dev only.
    
    Manually tested:
    
    ```bash
    echo 'setwd("~")' > ~/.Rprofile
    sh R/create-rd.sh
    ```
    
    Before:
    
    ```
    Using R_SCRIPT_PATH = /usr/local/bin
    Loading required package: usethis
    Error: Can't find './pkg'.
    Execution halted
    ```
    
    After:
    
    ```
    Using R_SCRIPT_PATH = /usr/local/bin
    Loading required package: usethis
    Updating SparkR documentation
    Loading SparkR
    Creating a new generic function for ‘as.data.frame’ in package ‘SparkR’
    Creating a new generic function for ‘colnames’ in package ‘SparkR’
    Creating a new generic function for ‘colnames<-’ in package ‘SparkR’
    Creating a new generic function for ‘cov’ in package ‘SparkR’
    Creating a new generic function for ‘drop’ in package ‘SparkR’
    Creating a new generic function for ‘na.omit’ in package ‘SparkR’
    Creating a new generic function for ‘filter’ in package ‘SparkR’
    Creating a new generic function for ‘intersect’ in package ‘SparkR’
    ...
    ```
    
    Closes #28285
---
 R/create-rd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/R/create-rd.sh b/R/create-rd.sh
index ff622a4..aaad3b1 100755
--- a/R/create-rd.sh
+++ b/R/create-rd.sh
@@ -34,4 +34,4 @@ pushd "$FWDIR" > /dev/null
 . "$FWDIR/find-r.sh"
 
 # Generate Rd files if devtools is installed
-"$R_SCRIPT_PATH/Rscript" -e ' if("devtools" %in% rownames(installed.packages())) { library(devtools); devtools::document(pkg="./pkg", roclets=c("rd")) }'
+"$R_SCRIPT_PATH/Rscript" -e ' if("devtools" %in% rownames(installed.packages())) { library(devtools); setwd("'$FWDIR'"); devtools::document(pkg="./pkg", roclets=c("rd")) }'


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org