From d8cb9e38fb9c5fc7ead1ee45da55523e7f7e4c58 Mon Sep 17 00:00:00 2001 From: Cristian Ferretti <37232625+jcferretti@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:20:59 -0400 Subject: [PATCH] Fix an issue in R/rdeephaven/src/Makevars regarding pkg-config; simplify README.md instructions (#4376) --- R/rdeephaven/README.md | 87 ++++++++----------- .../etc/generate-dotRenviron-lines.sh | 4 + .../etc/generate-rserverdotconf-lines.sh | 3 + R/rdeephaven/src/Makevars | 2 +- 4 files changed, 44 insertions(+), 52 deletions(-) create mode 100755 R/rdeephaven/etc/generate-dotRenviron-lines.sh create mode 100755 R/rdeephaven/etc/generate-rserverdotconf-lines.sh diff --git a/R/rdeephaven/README.md b/R/rdeephaven/README.md index 294e43c841c..3fa221efdc6 100644 --- a/R/rdeephaven/README.md +++ b/R/rdeephaven/README.md @@ -57,8 +57,10 @@ Currently, the R client is only supported on Ubuntu 20.04 or 22.04 and must be b https://github.com/deephaven/deephaven-core/blob/main/cpp-client/README.md. Follow the instructions at least to the point for "Build and install Deephaven C++ client". At that point you would have both the Deephaven C++ client and any C++ libraries it depends on, - all installed in a particular directory of your choosing. - Define an environment variable `DHCPP` and assign it an absolute path to that directory. + all installed in a particular directory of your choosing. In what follows we assume that + directory is `/path/to/dhcpp`. Independently of where that directory is in your + chosen installation, a file called `env.sh` should exist on it, and a `local` subdirectory + as well. 2. Choose a directory where the Deephaven R client source code will live. Here, the source code will be downloaded into a new directory called `rdeephaven`. @@ -73,20 +75,26 @@ Currently, the R client is only supported on Ubuntu 20.04 or 22.04 and must be b git pull origin main ``` -3. Ensure that the environment variables from the C++ client installation are set. Print them out with - these commands: +3. Set environment variables from the C++ client installation required for building the package. + Use: ``` - echo $DHCPP - echo $DHCPP_LOCAL - echo $CMAKE_PREFIX_PATH - echo $NCPUS - echo $LD_LIBRARY_PATH + source /path/to/dhcpp/env.sh ``` - If any or all of these are empty, set them as follows: + where `/path/to/dhcpp` is the directory you created in step (1) above. + You can ensure the environment variables that are necessary for the steps + that follow are set by checking their values by running the commands: + ``` - export DHCPP=/path/to/dhcpp - source $DHCPP/env.sh + echo $DHCPP + echo $LD_LIBRARY_PATH ``` + + Both environment libraries need to be defined for installing the package in the + instructions below. Once the package is installed, you will only need + `LD_LIBRARY_PATH` to be set in the R session where you intend to use the `rdeephaven` library. + If you are starting R from the command line, you can set the environment variable as explained + above. If you are using RStudio, see the note in the following point. + Refer to the instructions on the C++ client installation for more details on the `dhcpp` directory. 4. Start an R console inside the rdeephaven directory. In that console, install the dephaven client dependencies @@ -103,45 +111,22 @@ Currently, the R client is only supported on Ubuntu 20.04 or 22.04 and must be b --- **NOTE** - If using RStudio for this step, the environment variables that were set in step 3 may not persist into the RStudio environment, - if it is not a child process of the process where the environment variables were set. Suppose that we have the following values - for the environment variables: - ```bash - > echo $DHCPP - ABC - - > echo $DHCPP_LOCAL - 123 - - > echo $CMAKE_PREFIX_PATH - XYZ - - > echo $NCPUS - 4 - - > echo $LD_LIBRARY_PATH - libpath - ``` - Now, to resolve this issue, add the following file called `.Renviron` to the `deephaven-core` directory: - ```bash - DHCPP=ABC - DHCPP_LOCAL=123 - CMAKE_PREFIX_PATH=XYZ - NCPUS=4 - LD_LIBRARY_PATH=libpath - ``` - Setting these to the _exact_ values of the environment variables is critical, as compilation will fail otherwise. - - Then, create a new R project from the existing `deephaven-core` directory using RStudio, and the corresponding R session will inherit - all of the necessary environment variables for successful compilation. - - If RStudio Server is being used, all of the above must be followed for successful compilation. _In addition_, the following line should - be added to `rserver.conf`: - ``` - rsession-ld-library-path=libpath - ``` - where `libpath` is the actual value of the `LD_LIBRARY_PATH` environment variable. - + If using RStudio for this step, the environment variables that were set in step 3 may not persist into the RStudio + R environment if RStudio is not a child process of the shell where the environment variables were set + (ie, if RStudio is not started from that same shell and after the environment variables are set in that shell). + R supports using a `.Renviron` file for settings like this. You can generate the right content to add + to your .Renviron file (or for creating a new one) using the script under `etc/generate-dotRenviron-lines.sh` + + You can create a new `.Renviron` file under the `deephave-core` directory with the lines producing by running + the `etc/generate-dotRenviron-lines.sh` in the same shell where you set the environment variables; + the script will give you the right content for the `.Renviron` file. + Then, create a new R project from the existing `deephaven-core` directory using RStudio, and the corresponding + R session will inherit all of the necessary environment variables for successful compilation. + + If RStudio Server is being used, all of the above must be followed for successful compilation. _In addition_, + use the output from the script `etc/generate-rserverdotconf-lines.sh` and add them to the `rserver.conf` file + for the RStudio Server installation (the location of that file may depend on your particular RStudio server + installation, but a common location is `/etc/rstudio/rserver.conf`). --- 6. Now, run diff --git a/R/rdeephaven/etc/generate-dotRenviron-lines.sh b/R/rdeephaven/etc/generate-dotRenviron-lines.sh new file mode 100755 index 00000000000..e911055f118 --- /dev/null +++ b/R/rdeephaven/etc/generate-dotRenviron-lines.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "DHCPP=$DHCPP" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/R/rdeephaven/etc/generate-rserverdotconf-lines.sh b/R/rdeephaven/etc/generate-rserverdotconf-lines.sh new file mode 100755 index 00000000000..78cf61acdcc --- /dev/null +++ b/R/rdeephaven/etc/generate-rserverdotconf-lines.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "rsession-ld-library-path=$LD_LIBRARY_PATH" diff --git a/R/rdeephaven/src/Makevars b/R/rdeephaven/src/Makevars index e590fdeb441..8fb8611e2c0 100644 --- a/R/rdeephaven/src/Makevars +++ b/R/rdeephaven/src/Makevars @@ -19,7 +19,7 @@ DEPENDENCY_DIRS = -L$(DHCPP)/local/lib DEPENDENCY_LIBS = \ -lprotobufd \ -larrow_flight -larrow -larrow_bundled_dependencies \ - `PKG_CONFIG_PATH=$DHCPP/local/lib/pkgconfig --libs grpc` + `PKG_CONFIG_PATH=\${DHCPP}/local/lib/pkgconfig pkg-config --libs grpc++` # tells the compiler where to look for additional include directories