posit-dev / posit-dev/positron

R: Get `DYLD_FALLBACK_LIBRARY_PATH` and `LD_LIBRARY_PATH` from `etc/ldpaths`

Open
#4,048 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area: workbench bug lang: r
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

In https://github.com/posit-dev/ark/pull/205, one of the things we did was attempt to set the env vars LD_LIBRARY_PATH on Linux and DYLD_FALLBACK_LIBRARY_PATH on macOS.

We did this by utilizing R's etc/ldpaths script, which sets the corresponding env var to the correct value and exports it. We were able to first set R_HOME, then run that script, then print out the corresponding env var, and then we could be confident that we were going to be setting it to the right thing.

Notably, etc/ldpaths also contains information about Java, and will include Java related paths in the corresponding env var. This is used by rJava in particular.


Now, we have since realized that setting those env vars after ark has started does absolutely nothing. They must be set in the parent process before ark has started up, and on macOS we also must enable the allow-dyld-environment-variables entitlement (which we already do) for it to get passed to the child process.

So the correct thing to do is to set these from Positron (or a "wrapper" script for ark that would also be used in standalone Jupyter kernels) as we do in https://github.com/posit-dev/positron/pull/3921 and https://github.com/posit-dev/positron/pull/2809.

The problem with those 2 PRs is that they ignore etc/ldpaths entirely, missing information about Java.

We need to go back and add support for extracting these env vars from etc/ldpaths instead, either by finally writing that wrapper script or by sourcing etc/ldpaths from positron-r. When we do this, go back to https://github.com/posit-dev/ark/pull/205 and reference the tooling used in source_ldpaths_script(), as that has all the smarts to set R_HOME and use the most portable bash incantation to get the env var out.


The other half of this issue is that we need to go ahead and remove the dead tooling from ark, since we have determined it is not doing anything. I will go ahead and do that and link to this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading source_ldpaths_script() and the tooling from ark PR 205, then review the environment handling in Positron PRs 3921 and 2809. The work is done when LD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH include values from R's etc/ldpaths, including Java paths, and the dead ark tooling is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, r, typescript
Domain
developer-experience, devtools, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.