Skip to content

R-scripts as executables for debian

3 messages · Michel Kuhlmann, Dirk Eddelbuettel

#
Hi,
I'm looking for a way to make executable R-scripts -- which are bound to
a certain package -- available to the operating system's search path.
The executable R-scripts I put in the package's 'exec' directory. 

Different solutions have come to my mind: 
    o 'configure'-script copies the files to /usr/local/bin
    o make a 'require'-shell function which adds 
      '/usr/local/lib/R/site-library/<pkg>/exec' dynamically to $PATH
    o generate a debian-package which contains separately the
      executables. 

Thank you for any suggestions or pointers,
Michel
#
Michel,
On 19 January 2012 at 15:39, Michel Kuhlmann wrote:
| I'm looking for a way to make executable R-scripts -- which are bound to
| a certain package -- available to the operating system's search path.
| The executable R-scripts I put in the package's 'exec' directory. 

Unless I misunderstand, that will always be outside of the system $PATH though.
 
| Different solutions have come to my mind: 
|     o 'configure'-script copies the files to /usr/local/bin
|     o make a 'require'-shell function which adds 
|       '/usr/local/lib/R/site-library/<pkg>/exec' dynamically to $PATH
|     o generate a debian-package which contains separately the
|       executables. 

For executable R scripts, I suggest you do 'sudo apt-get install littler' and
write scripts for #!/usr/bin/r -- and see the different examples included in
the package.

My personal convention is to just end thos in a lowercase .r and to 'chmod
755' them, I have a few in ~/bin and /usr/local/bin/.

The R packaging system makes it hard to distribute this via packaging as
everything is effectively /outside/ the system patch.  We work around this
using r as well Rscript with things like "Rscript -e 'Rcpp:::LdFlags()'"
which we need to call from other packages.

Other packages have the same problem (when trying to ship executables based
on their code), and there is no solution I can see.  For a more general
discussion, r-devel may be better anyway.

Hope this helps,  Dirk
#
On 19 January 2012 at 15:39, Michel Kuhlmann wrote:
|     o generate a debian-package which contains separately the
|       executables. 

PS That you can do. Just have a Depends: on littler (and whichever R packages
   you need) and ship scripts in /usr/bin with #!/usr/bin/r as shebang.

Dirk