R CMD BATCH vs R CMD batch

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

R CMD BATCH vs R CMD batch

Marius Hofert-4
Hi,

Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
didn't get an error so didn't think about the consequences... One
consequence is (at least on Mac OS X 10.11 but probably in more
generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
in my case... I am thus wondering whether it makes sense to either a)
have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
not allow "R CMD batch" as a valid command (so requiring to use "R CMD
BATCH"). Both approaches might be delicate... just wanted to point
this issue out...

Cheers,
M

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Dirk Eddelbuettel

On 28 October 2015 at 21:39, Marius Hofert wrote:
| Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
| didn't get an error so didn't think about the consequences... One
| consequence is (at least on Mac OS X 10.11 but probably in more
| generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
| in my case... I am thus wondering whether it makes sense to either a)
| have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
| not allow "R CMD batch" as a valid command (so requiring to use "R CMD
| BATCH"). Both approaches might be delicate... just wanted to point
| this issue out...

Same reason we have 'R CMD INSTALL' as there often is /usr/bin/install with
different options ...

In general 'R CMD foo' will run for any 'foo' in the path:

   edd@max:~$ R CMD date
   Wed Oct 28 21:05:01 CDT 2015
   edd@max:~$

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Marius Hofert-4
In reply to this post by Marius Hofert-4
Great, thanks, Dirk. Nice example :-)


On Wed, Oct 28, 2015 at 10:05 PM, Dirk Eddelbuettel <[hidden email]> wrote:

>
> On 28 October 2015 at 21:39, Marius Hofert wrote:
> | Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
> | didn't get an error so didn't think about the consequences... One
> | consequence is (at least on Mac OS X 10.11 but probably in more
> | generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
> | in my case... I am thus wondering whether it makes sense to either a)
> | have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
> | not allow "R CMD batch" as a valid command (so requiring to use "R CMD
> | BATCH"). Both approaches might be delicate... just wanted to point
> | this issue out...
>
> Same reason we have 'R CMD INSTALL' as there often is /usr/bin/install with
> different options ...
>
> In general 'R CMD foo' will run for any 'foo' in the path:
>
>    edd@max:~$ R CMD date
>    Wed Oct 28 21:05:01 CDT 2015
>    edd@max:~$
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Rainer Krug-3
In reply to this post by Dirk Eddelbuettel
Dirk Eddelbuettel <[hidden email]> writes:

> On 28 October 2015 at 21:39, Marius Hofert wrote:
> | Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
> | didn't get an error so didn't think about the consequences... One
> | consequence is (at least on Mac OS X 10.11 but probably in more
> | generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
> | in my case... I am thus wondering whether it makes sense to either a)
> | have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
> | not allow "R CMD batch" as a valid command (so requiring to use "R CMD
> | BATCH"). Both approaches might be delicate... just wanted to point
> | this issue out...
>
> Same reason we have 'R CMD INSTALL' as there often is /usr/bin/install with
> different options ...
>
> In general 'R CMD foo' will run for any 'foo' in the path:
>
>    edd@max:~$ R CMD date
>    Wed Oct 28 21:05:01 CDT 2015
>    edd@max:~$
So what is R CMD exactly doing in this example? The output is the same if
I say only the command (using pwd as otherwise the time has changed...):

,----
| 09:35:03 ~$ R CMD pwd
| /Users/rainerkrug
| 09:35:37 ~$ R CMD pwd
| /Users/rainerkrug
| 09:37:44 ~$ pwd
| /Users/rainerkrug
| 09:37:49 ~$
`----

And this happens, except in cases where the foo is defined as a CMD in R (build, ...):

,----
| Commands:
|   BATCH Run R in batch mode
|   COMPILE Compile files for use with R
|   SHLIB Build shared library for dynamic loading
|   INSTALL Install add-on packages
|   REMOVE Remove add-on packages
|   build Build add-on packages
|   check Check add-on packages
|   LINK Front-end for creating executable programs
|   Rprof Post-process R profiling files
|   Rdconv Convert Rd format to various other formats
|   Rd2pdf Convert Rd format to PDF
|   Rd2txt Convert Rd format to pretty text
|   Stangle Extract S/R code from Sweave documentation
|   Sweave Process Sweave documentation
|   Rdiff Diff R output ignoring headers etc
|   config Obtain configuration information about R
|   javareconf Update the Java configuration variables
|   rtags                 Create Emacs-style tag files from C, R, and Rd files
`----

Unless I miss something, is this is an inconsistency in R?

Rainer


>
> Dirk

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

signature.asc (463 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Deepayan Sarkar
On Thu, Oct 29, 2015 at 2:09 PM, Rainer M Krug <[hidden email]> wrote:

> Dirk Eddelbuettel <[hidden email]> writes:
>
>> On 28 October 2015 at 21:39, Marius Hofert wrote:
>> | Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
>> | didn't get an error so didn't think about the consequences... One
>> | consequence is (at least on Mac OS X 10.11 but probably in more
>> | generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
>> | in my case... I am thus wondering whether it makes sense to either a)
>> | have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
>> | not allow "R CMD batch" as a valid command (so requiring to use "R CMD
>> | BATCH"). Both approaches might be delicate... just wanted to point
>> | this issue out...
>>
>> Same reason we have 'R CMD INSTALL' as there often is /usr/bin/install with
>> different options ...
>>
>> In general 'R CMD foo' will run for any 'foo' in the path:
>>
>>    edd@max:~$ R CMD date
>>    Wed Oct 28 21:05:01 CDT 2015
>>    edd@max:~$
>
> So what is R CMD exactly doing in this example? The output is the same if
> I say only the command (using pwd as otherwise the time has changed...):
>
> ,----
> | 09:35:03 ~$ R CMD pwd
> | /Users/rainerkrug
> | 09:35:37 ~$ R CMD pwd
> | /Users/rainerkrug
> | 09:37:44 ~$ pwd
> | /Users/rainerkrug
> | 09:37:49 ~$
> `----
>
> And this happens, except in cases where the foo is defined as a CMD in R (build, ...):
>
> ,----
> | Commands:
> |   BATCH                       Run R in batch mode
> |   COMPILE             Compile files for use with R
> |   SHLIB                       Build shared library for dynamic loading
> |   INSTALL             Install add-on packages
> |   REMOVE              Remove add-on packages
> |   build                       Build add-on packages
> |   check                       Check add-on packages
> |   LINK                        Front-end for creating executable programs
> |   Rprof                       Post-process R profiling files
> |   Rdconv              Convert Rd format to various other formats
> |   Rd2pdf              Convert Rd format to PDF
> |   Rd2txt              Convert Rd format to pretty text
> |   Stangle             Extract S/R code from Sweave documentation
> |   Sweave              Process Sweave documentation
> |   Rdiff                       Diff R output ignoring headers etc
> |   config              Obtain configuration information about R
> |   javareconf          Update the Java configuration variables
> |   rtags                 Create Emacs-style tag files from C, R, and Rd files
> `----
>
> Unless I miss something, is this is an inconsistency in R?

One important difference (not sure if the only one) is that R CMD
defines more environment variables. Compare

env | grep -i tex
R CMD env | grep -i tex

So for example

R CMD pdflatex

will behave differently from plain pdflatex.

-Deepayan

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Rainer Krug-3
Deepayan Sarkar <[hidden email]> writes:

> On Thu, Oct 29, 2015 at 2:09 PM, Rainer M Krug <[hidden email]> wrote:
>> Dirk Eddelbuettel <[hidden email]> writes:
>>
>>> On 28 October 2015 at 21:39, Marius Hofert wrote:
>>> | Out of laziness I just used "R CMD batch" instead of "R CMD BATCH". I
>>> | didn't get an error so didn't think about the consequences... One
>>> | consequence is (at least on Mac OS X 10.11 but probably in more
>>> | generality) that R_BATCH_OPTIONS are ignored, which was kind of fatal
>>> | in my case... I am thus wondering whether it makes sense to either a)
>>> | have R_BATCH_OPTIONS also be respected for "R CMD batch" or b) simply
>>> | not allow "R CMD batch" as a valid command (so requiring to use "R CMD
>>> | BATCH"). Both approaches might be delicate... just wanted to point
>>> | this issue out...
>>>
>>> Same reason we have 'R CMD INSTALL' as there often is /usr/bin/install with
>>> different options ...
>>>
>>> In general 'R CMD foo' will run for any 'foo' in the path:
>>>
>>>    edd@max:~$ R CMD date
>>>    Wed Oct 28 21:05:01 CDT 2015
>>>    edd@max:~$
>>
>> So what is R CMD exactly doing in this example? The output is the same if
>> I say only the command (using pwd as otherwise the time has changed...):
>>
>> ,----
>> | 09:35:03 ~$ R CMD pwd
>> | /Users/rainerkrug
>> | 09:35:37 ~$ R CMD pwd
>> | /Users/rainerkrug
>> | 09:37:44 ~$ pwd
>> | /Users/rainerkrug
>> | 09:37:49 ~$
>> `----
>>
>> And this happens, except in cases where the foo is defined as a CMD in R (build, ...):
>>
>> ,----
>> | Commands:
>> |   BATCH                       Run R in batch mode
>> |   COMPILE             Compile files for use with R
>> |   SHLIB                       Build shared library for dynamic loading
>> |   INSTALL             Install add-on packages
>> |   REMOVE              Remove add-on packages
>> |   build                       Build add-on packages
>> |   check                       Check add-on packages
>> |   LINK                        Front-end for creating executable programs
>> |   Rprof                       Post-process R profiling files
>> |   Rdconv              Convert Rd format to various other formats
>> |   Rd2pdf              Convert Rd format to PDF
>> |   Rd2txt              Convert Rd format to pretty text
>> |   Stangle             Extract S/R code from Sweave documentation
>> |   Sweave              Process Sweave documentation
>> |   Rdiff                       Diff R output ignoring headers etc
>> |   config              Obtain configuration information about R
>> |   javareconf          Update the Java configuration variables
>> |   rtags                 Create Emacs-style tag files from C, R, and Rd files
>> `----
>>
>> Unless I miss something, is this is an inconsistency in R?
>
> One important difference (not sure if the only one) is that R CMD
> defines more environment variables. Compare
>
> env | grep -i tex
> R CMD env | grep -i tex
>
> So for example
>
> R CMD pdflatex
>
> will behave differently from plain pdflatex.
Reading Dirk's email again, I think I get the picture of what ~R CMD foo~ is
doing: running ~foo~ after doing some initial magic.

Out of interest: What is the magic ~R CMD~ is doing? Is it documented
anywhere?

Rainer

>
> -Deepayan

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

signature.asc (463 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Peter Dalgaard-2

On 29 Oct 2015, at 10:44 , Rainer M Krug <[hidden email]> wrote:

> Out of interest: What is the magic ~R CMD~ is doing? Is it documented
> anywhere?


R is open source.... (and shell scripts are considered self-documenting by some)

On Unix-alikes, R is a shell script which, if called with 1st argument CMD, calls ${R_HOME}/bin/Rcmd, which is another shell script that ends with

case "${1}" in
## this was a separate command prior to 2.10.0
  Rd2txt)
    cmd="${R_HOME}/bin/Rdconv"
    extra="-t txt"
    ;;
## removed in 2.15.0
  Rd2dvi)
    echo "R CMD Rd2dvi is defunct: use Rd2pdf instead"
    exit 1
    ;;
  *)
    if test -x "${R_HOME}/bin/${1}"; then
      cmd="${R_HOME}/bin/${1}"
    else
      cmd="${1}"
    fi
    ;;
esac
shift

exec "${cmd}" ${extra} "${@}"

I.e., except for setting up variables and such, R CMD ${foo} essentially looks for ${R_HOME}/bin/${foo} and executes it if it exists and is executable, otherwise it just executes ${foo}.

Notice that, somewhat contrary to what Dirk said, this logic works at the mercy of the file system when it comes to case sensitivity. On OSX with the default case-insensitive setup we get

Peters-iMac:IBP pd$ R CMD install
Error: ERROR: no packages specified

which comes from R's package installer, whereas a case-sensitive FS would pick up /usr/bin/install instead. That is just how the "test" shell built-in works:

Peters-iMac:~ pd$ test -x `R RHOME`/bin/INSTALL ; echo $?
0
Peters-iMac:~ pd$ test -x `R RHOME`/bin/UNSTALL ; echo $?
1
Peters-iMac:~ pd$ test -x `R RHOME`/bin/install ; echo $?
0


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R CMD BATCH vs R CMD batch

Rainer Krug-3
peter dalgaard <[hidden email]> writes:

> On 29 Oct 2015, at 10:44 , Rainer M Krug <[hidden email]> wrote:
>
>> Out of interest: What is the magic ~R CMD~ is doing? Is it documented
>> anywhere?
>
>
> R is open source.... (and shell scripts are considered self-documenting by some)

True - should have looked in the sources...

>
> On Unix-alikes, R is a shell script which, if called with 1st argument
> CMD, calls ${R_HOME}/bin/Rcmd, which is another shell script that ends
> with
>
> case "${1}" in
> ## this was a separate command prior to 2.10.0
>   Rd2txt)
>     cmd="${R_HOME}/bin/Rdconv"
>     extra="-t txt"
>     ;;
> ## removed in 2.15.0
>   Rd2dvi)
>     echo "R CMD Rd2dvi is defunct: use Rd2pdf instead"
>     exit 1
>     ;;
>   *)
>     if test -x "${R_HOME}/bin/${1}"; then
>       cmd="${R_HOME}/bin/${1}"
>     else
>       cmd="${1}"
>     fi
>     ;;
> esac
> shift
>
> exec "${cmd}" ${extra} "${@}"
>
> I.e., except for setting up variables and such, R CMD ${foo}
> essentially looks for ${R_HOME}/bin/${foo} and executes it if it
> exists and is executable, otherwise it just executes ${foo}.
Thanks for that detailed explanation of the mechanism - it is much
clearer now. And as usual, if one knows how something is happening, it's
not "magical" anymore.

>
> Notice that, somewhat contrary to what Dirk said, this logic works at
> the mercy of the file system when it comes to case sensitivity. On OSX
> with the default case-insensitive setup we get
>
> Peters-iMac:IBP pd$ R CMD install
> Error: ERROR: no packages specified
>
> which comes from R's package installer, whereas a case-sensitive FS
> would pick up /usr/bin/install instead. That is just how the "test"
> shell built-in works:
>
> Peters-iMac:~ pd$ test -x `R RHOME`/bin/INSTALL ; echo $?
> 0
> Peters-iMac:~ pd$ test -x `R RHOME`/bin/UNSTALL ; echo $?
> 1
> Peters-iMac:~ pd$ test -x `R RHOME`/bin/install ; echo $?
> 0
Yeah - true. I was already starting to wonder as I always was using ~R
CMD install~ and it always worked on my Mac.

Thanks again,

Rainer

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

signature.asc (463 bytes) Download Attachment