Search code examples
rmicrosoft-rdeployr

Reload Custom R Package from Source


I have created a custom package and would like to deploy it to a remote machine. Here is my current long workflow:

  • Create custom package 'my_package_0.1.0.tar.gz'
  • scp package to remote machine
  • create Remote session
  • install.packages("/path/to/my_package0.1.0.tar.gz")
  • library('my_package')

When others connect to the machine, they have to run install and library:

  • install.packages("/path/to/my_package0.1.0.tar.gz")
  • library('my_package')

Is there a way I can share a custom package and have the workflow be:

  • Create remote session
  • Load package with library('my_package')

Solution

  • Feedback in comments says the best practice is to install the package in a shared location.

    Here is how you can find a good place to install the packages.

    Running the following shows where libraries are loaded from

    .libPaths()
    # rserve2 rserve2 /opt/deployr/9.0.1/rserve/R
    #root root        /usr/lib64/microsoft-r/3.3/lib64/R/library
    

    There are two locations the R server is looking for libraries. One is owned by root so we shouldn't deploy here. The other location rserve2 has owndership and looks promising. We should create a library subfolder to store the shared packages.

    Based on this information, the work flow should be:

    • Create custom package 'my_package_0.1.0.tar.gz'
    • scp package to remote machine
    • create Remote session
    • install.packages("/path/to/my_package0.1.0.tar.gz", lib='/opt/deployr/9.0.1/rserve/R/library/')
    • library('my_package')

    When others connect to the machine, they can load the shared library:

    • library('my_package')