Skip to content

Link default R and Python onto PATH in workbench and session images - #245

Draft
ianpittwood wants to merge 1 commit into
mainfrom
feat/default-interpreter-links
Draft

ianpittwood wants to merge 1 commit into
mainfrom
feat/default-interpreter-links

Conversation

@ianpittwood

Copy link
Copy Markdown
Contributor

Refs posit-dev/images-shared#839

Depends on posit-dev/images-shared#888. The templates need that Bakery release to re-render. The rendered files are committed, so CI builds work without it.

Changes

workbench (Standard)

  • r.run_install(Dependencies.R, link_to_path=True) and python.copy_from_build_stage(Dependencies.python, link_to_path=True).
  • /opt/R/default points to /opt/R/4.6.2 and /opt/python/default points to /opt/python/3.14.10. R, Rscript, python, python3, pip and pip3 are linked into /usr/local/bin through those default paths.
  • Re-rendered 2026.11 only, following repo practice.

workbench-session (matrix)

  • Same links, using $R_VERSION / $PYTHON_VERSION.
  • ARG PYTHON_VERSION moved above the Python COPY so the link RUN sees it.

Both images

  • Goss: path_link_checks and path_link_targets for R (R, Rscript) and Python (python, python3, pip, pip3). In the server image these run for Standard only.
  • pyyaml and nbclient are added to the same base-Python pip install as ipykernel. The ipykernel install --user line is unchanged.
    • Why: the default python3 used to be the system /usr/bin/python3, which has no Jupyter, so quarto check skipped its Jupyter test. Now the default is the managed Python. It has jupyter_core (from ipykernel) but had no yaml/nbclient, so quarto check jupyter failed (ModuleNotFoundError: yaml).
    • With these packages, the existing Verify Quarto goss check passes again, and quarto render of Jupyter docs works with the default python3.
  • /opt/python/default always targets the versioned interpreter, never the /opt/python/jupyter venv. /usr/local/bin/jupyter is unchanged.

workbench-session-complete

  • Inherits the links from its base. Only a stale goss comment was updated.
  • No strict link checks yet: PR builds use the last published session base, which has no links. They can be added after the session images are republished.

Docs

  • workbench-session/README.md and workbench/README.md document the default links and that pip is externally managed.

Notes

  • workbench/template/conf/launcher/launcher-env.jinja2 is not changed. Its PATH=/opt/python/default/bin:$PATH becomes valid again for session images.
  • The rendered files also include one unrelated line from the newer Bakery Jupyter macro: rm -rf .../site-packages/tornado/test. It is harmless.
  • Not changed: workbench-session-init, workbench-positron-init.

Verification

  • bakery build for workbench-session R4.6.2-python3.14.10, Ubuntu 24.04, Minimal, linux/amd64: passed.
  • bakery dgoss run with the same filters: 57/57 passed. This includes the 12 new link checks and Verify Quarto.
    • Before the pyyaml/nbclient fix, the result was 56/57 (only Verify Quarto failed).
  • Manual checks:
    • /usr/bin/python3 (system 3.12) is shadowed by /usr/local/bin/python3 (3.14.10) on the default PATH.
    • su - <user> and docker run -u 4242 both resolve all six binaries to /usr/local/bin, with R home at /opt/R/4.6.2.
    • pip install returns externally-managed-environment.
  • I did not build the server image. I only inspected its rendered RUN lines.

Open risks

  • Workbench and Positron scan /opt/R/*. Their docs don't say whether a symlinked /opt/R/default is de-duplicated, so either may list default as an extra R version.
    • Workbench can disable scanning with r-versions-scan = 0.
    • Positron can hide it with positron.r.interpreters.exclude.
  • A session on a non-default R/Python version that calls bare Rscript or python3 gets the image default. This matters mainly for the server image.
  • pip on the default Python is EXTERNALLY-MANAGED (PEP 668). Users need a venv or --break-system-packages.
  • The root-only ipykernel install --user kernelspec is a separate, pre-existing issue that this PR does not address.
  • workbench-session-complete goss does not assert the links yet (see above).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant