From b686781be905719e08d501e390edcdc8061038b8 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 09:24:02 +0530 Subject: [PATCH 01/18] changes to devcontainer.json --- .devcontainer/devcontainer.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ca2376a64..28ed03896 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,6 +4,9 @@ "hostRequirements": { "cpus": 4 }, + "runArgs": [ + "--cap-add=SYS_PTRACE" + ], "customizations": { "vscode": { "settings": { @@ -12,8 +15,8 @@ "editor.detectIndentation": false, "r.lsp.diagnostics": false, "r.plot.useHttpgd": true, - "r.rpath.linux": "/usr/bin/R", - "r.rterm.linux": "/usr/bin/R", + "r.rterm.linux": "/workspaces/r-dev-env/scripts/launch_r.sh", + "r.rpath.linux": "/workspaces/r-dev-env/build/r-devel/bin/R", "terminal.integrated.sendKeybindingsToShell": true, "svn.multipleFolders.enabled": true, "workbench.editorAssociations": { @@ -28,9 +31,10 @@ "johnstoncode.svn-scm", "ms-vscode.cpptools", "MS-vsliveshare.vsliveshare", - "natqe.reload" + "natqe.reload", + "vadimcn.vscode-lldb" ] } }, - "postCreateCommand": "find . -wholename '*.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && sh /workspaces/r-dev-env/scripts/localscript.sh" + "postCreateCommand": "find . -wholename '.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && \\\n gcc -shared -fPIC -o /workspaces/r-dev-env/scripts/allow_ptrace.so /workspaces/r-dev-env/scripts/allow_ptrace.c && \\\n chmod +x /workspaces/r-dev-env/scripts/launch_r.sh && \\\n sh /workspaces/r-dev-env/scripts/localscript.sh" } From 5200db35810feca632a6dccac21ca5e3b8740a33 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 09:29:55 +0530 Subject: [PATCH 02/18] added launch.json --- .devcontainer/launch.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .devcontainer/launch.json diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json new file mode 100644 index 000000000..f608b874e --- /dev/null +++ b/.devcontainer/launch.json @@ -0,0 +1,12 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(lldb) Attach to R", + "type": "lldb", + "request": "attach", + "pid": "${command:pickMyProcess}", + "stopOnEntry": false + } + ] +} From 7131f5309cb2e0c8d3ab646404d12b6e293e076d Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 09:37:53 +0530 Subject: [PATCH 03/18] added wrapper and launch_r scripts --- scripts/allow_ptrace.c | 6 ++++++ scripts/launch_r.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 scripts/allow_ptrace.c create mode 100644 scripts/launch_r.sh diff --git a/scripts/allow_ptrace.c b/scripts/allow_ptrace.c new file mode 100644 index 000000000..f730619f0 --- /dev/null +++ b/scripts/allow_ptrace.c @@ -0,0 +1,6 @@ +#include + +__attribute__((constructor)) +static void allow_ptrace(void) { + prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); +} diff --git a/scripts/launch_r.sh b/scripts/launch_r.sh new file mode 100644 index 000000000..ee037cae6 --- /dev/null +++ b/scripts/launch_r.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +export LD_PRELOAD=/workspaces/r-dev-env/scripts/allow_ptrace.so + +# If the first argument is a file, use that as R_BINARY; otherwise default. +if [ -x "$1" ]; then + R_BINARY="$1" + shift +else + R_BINARY="/usr/bin/R" +fi + +# Exec R with all remaining arguments +exec "$R_BINARY" "$@" From 0aafb3d1bdfe7e47a7646f2c0508c7961f444417 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 09:47:34 +0530 Subject: [PATCH 04/18] updated documentation to include flags for debugging --- docs/tutorials/building_r.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/building_r.md b/docs/tutorials/building_r.md index 85f68146a..6af16b04d 100644 --- a/docs/tutorials/building_r.md +++ b/docs/tutorials/building_r.md @@ -55,7 +55,19 @@ mkdir -p $BUILDDIR cd $BUILDDIR ``` -**5) Configure the build** +**5) Set CFLAGS (Optional—For Debugging C Code)** + +- **This step is optional and recommended for those who want to debug C code.** +- Set the `CFLAGS` environment variable before running configure: + +```bash +CFLAGS="-g -O0" +``` + +- After running this command, the CFLAGS setting will apply only to the +current terminal session. + +**6) Configure the build** - After we change directory, we must run the configure script from the source directory. This step takes ~1 minute on the codespace. @@ -80,7 +92,7 @@ $TOP_SRCDIR/configure --with-valgrind-instrumentation=1 ![alt text](../assets/rdev7.png) -**6) Build R** +**7) Build R** Having configured R, we run `make` to build R. This take 5-10 minutes on the codespace. @@ -89,7 +101,7 @@ codespace. make ``` -**7) Check R** +**8) Check R** Check that the build of R passes R's standard checks: @@ -101,7 +113,7 @@ This takes a couple of minutes in the codespace. The check will stop with a error message if any of the tests fail. If this happens, see [SVN Help](./svn_help.md) for how to revert to a version that passes check. -**8) Make R terminals use the built R** +**9) Make R terminals use the built R** Run the `which_r` script to set which R to use for R terminals in VSCode. When prompted, enter the number corresponding to `r-devel` @@ -125,7 +137,7 @@ built![^1] selected version is saved in the VSCode settings, so will be saved when you stop and restart the codespace. -**9) Make contributions** +**10) Make contributions** - After having built the current development version of R, we can now make changes to the source code and contribute to the project. From 12e95fdb1756370b50befeadf11ee1e98e31c59a Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 16:50:30 +0530 Subject: [PATCH 05/18] removed settings.json since it overwrites devcontainer.json --- scripts/localscript.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/localscript.sh b/scripts/localscript.sh index 3797814b7..e7880689a 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -38,3 +38,7 @@ fi # Run the main function local_script + +# Remove the .vscode/settings.json file if it exists so that +# it does not interfere with the devcontainer.json +rm -f .vscode/settings.json \ No newline at end of file From 8d169f3e0a3edd0554b4a0ed0b9a236381726b76 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Wed, 30 Jul 2025 16:55:48 +0530 Subject: [PATCH 06/18] Change R debug config to launch through wrapper script --- .devcontainer/launch.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json index f608b874e..e0102c367 100644 --- a/.devcontainer/launch.json +++ b/.devcontainer/launch.json @@ -2,11 +2,16 @@ "version": "0.2.0", "configurations": [ { - "name": "(lldb) Attach to R", - "type": "lldb", - "request": "attach", - "pid": "${command:pickMyProcess}", - "stopOnEntry": false + "name": "Debug R (C debugging)", + "type": "cppdbg", + "request": "launch", + "program": "/workspaces/r-dev-env/scripts/launch_r.sh", + "args": ["/workspaces/r-dev-env/build/r-devel/bin/R"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" } ] } From ecd644a60348e5ddcf22777f4365d287db8f90c4 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Thu, 31 Jul 2025 09:11:28 +0530 Subject: [PATCH 07/18] Refactor debugging setup: use wrapper env var and update which_r for rpath --- .devcontainer/devcontainer.json | 9 ++++++--- scripts/localscript.sh | 15 +++++++++++---- scripts/which_r.sh | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 28ed03896..f8bbd74f5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,7 +16,10 @@ "r.lsp.diagnostics": false, "r.plot.useHttpgd": true, "r.rterm.linux": "/workspaces/r-dev-env/scripts/launch_r.sh", - "r.rpath.linux": "/workspaces/r-dev-env/build/r-devel/bin/R", + "r.rpath.linux": "/usr/bin/R", + "terminal.integrated.env.linux": { + "R_RPATH_LINUX": "${config:r.rpath.linux}" + }, "terminal.integrated.sendKeybindingsToShell": true, "svn.multipleFolders.enabled": true, "workbench.editorAssociations": { @@ -36,5 +39,5 @@ ] } }, - "postCreateCommand": "find . -wholename '.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && \\\n gcc -shared -fPIC -o /workspaces/r-dev-env/scripts/allow_ptrace.so /workspaces/r-dev-env/scripts/allow_ptrace.c && \\\n chmod +x /workspaces/r-dev-env/scripts/launch_r.sh && \\\n sh /workspaces/r-dev-env/scripts/localscript.sh" -} +"postCreateCommand": "find . -wholename '.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && sh ./scripts/localscript.sh" +} \ No newline at end of file diff --git a/scripts/localscript.sh b/scripts/localscript.sh index e7880689a..a4a39ae76 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -9,6 +9,7 @@ local_script(){ WORK_DIR=$PWD VSCODE_DIR="$WORK_DIR/.vscode" DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json" +SCRIPTS_DIR="$WORK_DIR/scripts" # Create patch directory in workspace root ($PWD at start) PATCHDIR="$WORK_DIR/patches" @@ -16,11 +17,11 @@ mkdir -p $PATCHDIR mkdir -p $VSCODE_DIR # Copy the which_r and set_build_r function definitions to .bashrc -cat $WORK_DIR/scripts/which_r.sh >> ~/.bashrc -cat $WORK_DIR/scripts/set_build_r.sh >> ~/.bashrc +cat $SCRIPTS_DIR/which_r.sh >> ~/.bashrc +cat $SCRIPTS_DIR/set_build_r.sh >> ~/.bashrc # Copy over the welcome message script to be run when bash terminal starts -cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc +cat $SCRIPTS_DIR/welcome_msg.sh >> ~/.bashrc #bash ~/.bashrc @@ -41,4 +42,10 @@ local_script # Remove the .vscode/settings.json file if it exists so that # it does not interfere with the devcontainer.json -rm -f .vscode/settings.json \ No newline at end of file +rm -f "$WORK_DIR/.vscode/settings.json" + +# 1. Build the ptrace helper library +gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c" + +# 2. Mark the wrapper executable +chmod +x "$SCRIPTS_DIR/launch_r.sh" \ No newline at end of file diff --git a/scripts/which_r.sh b/scripts/which_r.sh index 689aecf60..ce291ef30 100644 --- a/scripts/which_r.sh +++ b/scripts/which_r.sh @@ -60,7 +60,7 @@ which_r() { fi # Update settings.json with the chosen R path - updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rterm.linux"=$subdir | ."r.rpath.linux"=$subdir') + updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rpath.linux"=$subdir') echo "$updated_settings_data" > "$settings_file_path" echo "R terminal will now use version: $selected_version" From 13a94cd45147023b53f51aab4a796db8bcce2e91 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 03:59:46 +0000 Subject: [PATCH 08/18] [pre-commit.ci] Fixing issues with pre-commit --- .devcontainer/devcontainer.json | 2 +- scripts/localscript.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f8bbd74f5..91070f6e8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -40,4 +40,4 @@ } }, "postCreateCommand": "find . -wholename '.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && sh ./scripts/localscript.sh" -} \ No newline at end of file +} diff --git a/scripts/localscript.sh b/scripts/localscript.sh index a4a39ae76..e3a7f3037 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -48,4 +48,4 @@ rm -f "$WORK_DIR/.vscode/settings.json" gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c" # 2. Mark the wrapper executable -chmod +x "$SCRIPTS_DIR/launch_r.sh" \ No newline at end of file +chmod +x "$SCRIPTS_DIR/launch_r.sh" From e31cb45f6a689a3f1faf671afcea255a37c2721c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Jul 2025 11:29:25 +0000 Subject: [PATCH 09/18] [pre-commit.ci] Fixing issues with pre-commit --- docs/tutorials/building_r.md | 7 +++++-- scripts/localscript.sh | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/building_r.md b/docs/tutorials/building_r.md index 6af16b04d..c49ca60e5 100644 --- a/docs/tutorials/building_r.md +++ b/docs/tutorials/building_r.md @@ -64,8 +64,11 @@ cd $BUILDDIR CFLAGS="-g -O0" ``` -- After running this command, the CFLAGS setting will apply only to the -current terminal session. +- These flags modify the configuration defined in the next step, +so that when R is built, C code will be compiled with debugging +symbols (`-g`) and compiler optimizations will be disabled +(`-O0`) so that the structure of the code closely matches the +original source. **6) Configure the build** diff --git a/scripts/localscript.sh b/scripts/localscript.sh index e3a7f3037..a0fcdc10c 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -42,6 +42,7 @@ local_script # Remove the .vscode/settings.json file if it exists so that # it does not interfere with the devcontainer.json +<<<<<<< HEAD rm -f "$WORK_DIR/.vscode/settings.json" # 1. Build the ptrace helper library @@ -49,3 +50,6 @@ gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c # 2. Mark the wrapper executable chmod +x "$SCRIPTS_DIR/launch_r.sh" +======= +rm -f .vscode/settings.json +>>>>>>> 964acc0 ([pre-commit.ci] Fixing issues with pre-commit) From 10bb76eeb50bf1aa7a39c436c5e1759f6a2e922a Mon Sep 17 00:00:00 2001 From: Avinab Neogy <72705235+avinab-neogy@users.noreply.github.com> Date: Thu, 31 Jul 2025 08:14:25 +0530 Subject: [PATCH 10/18] update docs/tutorials/building_r.md modify the step for setting CFLAGS for a better explanation Co-authored-by: Heather Turner --- scripts/launch_r.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/launch_r.sh b/scripts/launch_r.sh index ee037cae6..608ff888f 100644 --- a/scripts/launch_r.sh +++ b/scripts/launch_r.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash -export LD_PRELOAD=/workspaces/r-dev-env/scripts/allow_ptrace.so +# Preload helper for ptrace +export LD_PRELOAD="$(dirname "$0")/allow_ptrace.so" -# If the first argument is a file, use that as R_BINARY; otherwise default. -if [ -x "$1" ]; then - R_BINARY="$1" - shift +# VS Code sets the env var R_RPATH_LINUX to the path from r.rpath.linux +if [ -n "${R_RPATH_LINUX:-}" ] && [ -x "$R_RPATH_LINUX" ]; then + R_BINARY="$R_RPATH_LINUX" else R_BINARY="/usr/bin/R" fi -# Exec R with all remaining arguments exec "$R_BINARY" "$@" From 0ded05f2bb0190d745bcd9026e1a4b65f8131df5 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Thu, 31 Jul 2025 09:58:41 +0530 Subject: [PATCH 11/18] updated launch config to remove hard coded r version --- .devcontainer/launch.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json index e0102c367..ef10a6682 100644 --- a/.devcontainer/launch.json +++ b/.devcontainer/launch.json @@ -6,10 +6,15 @@ "type": "cppdbg", "request": "launch", "program": "/workspaces/r-dev-env/scripts/launch_r.sh", - "args": ["/workspaces/r-dev-env/build/r-devel/bin/R"], + "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", - "environment": [], + "environment": [ + { + "name": "R_RPATH_LINUX", + "value": "${config:r.rpath.linux}" + } + ], "externalConsole": false, "MIMode": "lldb" } From aa3881daaf68e882f2695f4c20b84aa6b8e83493 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Thu, 31 Jul 2025 10:11:49 +0530 Subject: [PATCH 12/18] modified local script --- scripts/localscript.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/localscript.sh b/scripts/localscript.sh index a0fcdc10c..7a9ba8cfd 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -24,7 +24,6 @@ cat $SCRIPTS_DIR/set_build_r.sh >> ~/.bashrc cat $SCRIPTS_DIR/welcome_msg.sh >> ~/.bashrc #bash ~/.bashrc - # Remove git directory if it exists rm -rf .git @@ -42,7 +41,6 @@ local_script # Remove the .vscode/settings.json file if it exists so that # it does not interfere with the devcontainer.json -<<<<<<< HEAD rm -f "$WORK_DIR/.vscode/settings.json" # 1. Build the ptrace helper library @@ -50,6 +48,3 @@ gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c # 2. Mark the wrapper executable chmod +x "$SCRIPTS_DIR/launch_r.sh" -======= -rm -f .vscode/settings.json ->>>>>>> 964acc0 ([pre-commit.ci] Fixing issues with pre-commit) From c511d20dc495e9587c799f9bdac6c3bd3233bd17 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Fri, 1 Aug 2025 12:05:19 +0530 Subject: [PATCH 13/18] changes to scripts --- .devcontainer/devcontainer.json | 3 --- scripts/allow_ptrace.so | Bin 0 -> 15656 bytes scripts/launch_r.sh | 15 +++------------ scripts/localscript.sh | 4 ---- 4 files changed, 3 insertions(+), 19 deletions(-) create mode 100755 scripts/allow_ptrace.so diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 91070f6e8..8a68d05e7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,9 +17,6 @@ "r.plot.useHttpgd": true, "r.rterm.linux": "/workspaces/r-dev-env/scripts/launch_r.sh", "r.rpath.linux": "/usr/bin/R", - "terminal.integrated.env.linux": { - "R_RPATH_LINUX": "${config:r.rpath.linux}" - }, "terminal.integrated.sendKeybindingsToShell": true, "svn.multipleFolders.enabled": true, "workbench.editorAssociations": { diff --git a/scripts/allow_ptrace.so b/scripts/allow_ptrace.so new file mode 100755 index 0000000000000000000000000000000000000000..961d1d6f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 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/launch_r.sh b/scripts/launch_r.sh index 5f361300a..336919f15 100644 --- a/scripts/launch_r.sh +++ b/scripts/launch_r.sh @@ -1,3 +1,3 @@ #!/bin/bash export LD_PRELOAD=/workspaces/r-dev-env/scripts/allow_ptrace.so -exec /usr/bin/R "$@" \ No newline at end of file +exec /usr/bin/R "$@" From c6e3c7454fe049d6dbec0575530e1ad4573a626b Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Fri, 1 Aug 2025 14:24:00 +0530 Subject: [PATCH 15/18] updated which_r using sed as suggested by heather --- scripts/which_r.sh | 83 +++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/scripts/which_r.sh b/scripts/which_r.sh index ce291ef30..748aeb44b 100644 --- a/scripts/which_r.sh +++ b/scripts/which_r.sh @@ -1,68 +1,53 @@ - +#!/usr/bin/env bash which_r() { - # Specify the parent directory - parent_dir="$WORK_DIR/build" - - # Path to the settings.json file - settings_file_path=$WORK_DIR/.vscode/settings.json + parent_dir="$PWD/build" + settings_file_path="$PWD/.vscode/settings.json" + launch_script="$PWD/scripts/launch_r.sh" - built_in_r_version=$(R --version | grep "^R version" | awk '{print $3}') + built_in_r_version=$(R --version | awk '/^R version/ {print $3}') - # Ask user which R version to use echo "Which version of R should be used in new R terminals?" - echo " 1. R $built_in_r_version (release version built into this container)" + echo " 1. R $built_in_r_version (built-in)" - # Check for additional R versions in subdirectories + # Detect additional R builds + subdirs=() + counter=2 if [ -d "$parent_dir" ]; then - # Create an array to store subdirectory names - subdirs=() - - # Loop through subdirectories and print numbered list - counter=2 # Start counter at 2 to avoid conflict with built-in R for dir in "$parent_dir"/*; do - if [ -d "$dir/bin" ] && [ -x "$dir/bin/R" ]; then - subdir=$(basename "$dir") - subdirs+=("$subdir") # Populate subdirs array - echo " $counter. $subdir" + if [ -x "$dir/bin/R" ]; then + subdirs+=("$(basename "$dir")") + echo " $counter. ${subdirs[-1]}" ((counter++)) fi done fi - # If no additional R builds were found - if [ ${#subdirs[@]} -eq 0 ]; then - range=1 - echo "No additional R builds available." - else - range=$((counter - 1)) - fi + range=$((counter - 1)) + [ "${#subdirs[@]}" -eq 0 ] && echo "No additional R builds found." - # Get user choice - read -p "Enter the number corresponding to the selected version: " choice + read -p "Enter number (1–$range): " choice - # Define selected version based on choice - if [[ "$choice" -eq 1 ]]; then - # Use built-in R - selected_version="/usr/bin/R" - elif [[ "$choice" -ge 2 ]] && [[ "$choice" -lt "$counter" ]]; then - # Use R from chosen subdirectory - chosen_subdir="${subdirs[((choice - 2))]}" - selected_version="$parent_dir/$chosen_subdir/bin/R" + if [ "$choice" -eq 1 ] 2>/dev/null; then + selected="/usr/bin/R" + elif [ "$choice" -ge 2 ] && [ "$choice" -le "$range" ] 2>/dev/null; then + idx=$((choice - 2)) + selected="$parent_dir/${subdirs[$idx]}/bin/R" else - # Invalid choice, default to built-in R - if [[ $range -eq 1 ]]; then - echo "Invalid choice, please enter 1. Defaulting to built-in R version." - else - echo "Invalid choice, please select options between 1 to $range. Defaulting to built-in R version." - fi - selected_version="/usr/bin/R" + echo "Invalid choice; defaulting to built-in" + selected="/usr/bin/R" fi - # Update settings.json with the chosen R path - updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rpath.linux"=$subdir') - echo "$updated_settings_data" > "$settings_file_path" + # Update launch_r.sh to call the selected R + sed -i "s|^exec .*/R|exec $selected|" "$launch_script" + + # Update VS Code setting if it exists + if [ -f "$settings_file_path" ]; then + jq --arg r "$selected" '."r.rpath.linux"=$r' \ + "$settings_file_path" > "${settings_file_path}.tmp" \ + && mv "${settings_file_path}.tmp" "$settings_file_path" + fi - echo "R terminal will now use version: $selected_version" - echo "To update the HTML help, click \"Reload\" in the VS Code status bar (bottom right) to reload your VS Code window." -} + echo "Now using R at: $selected" + echo "Reload VS Code to apply updates." +} \ No newline at end of file From 3023bdbd259c9dc88536f4084a4ec603ecd03849 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 08:55:46 +0000 Subject: [PATCH 16/18] [pre-commit.ci] Fixing issues with pre-commit --- scripts/which_r.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/which_r.sh b/scripts/which_r.sh index 748aeb44b..f9002f9b7 100644 --- a/scripts/which_r.sh +++ b/scripts/which_r.sh @@ -50,4 +50,4 @@ which_r() { echo "Now using R at: $selected" echo "Reload VS Code to apply updates." -} \ No newline at end of file +} From 16aab2e327e6cec1c2e840c50850d4b31f4486d3 Mon Sep 17 00:00:00 2001 From: avinab-neogy Date: Thu, 7 Aug 2025 16:01:12 +0530 Subject: [PATCH 17/18] Updated launch.json --- .devcontainer/launch.json | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json index ef10a6682..0fa2b45a5 100644 --- a/.devcontainer/launch.json +++ b/.devcontainer/launch.json @@ -1,22 +1,12 @@ { - "version": "0.2.0", - "configurations": [ +"version": "0.2.0", +"configurations": [ { - "name": "Debug R (C debugging)", - "type": "cppdbg", - "request": "launch", - "program": "/workspaces/r-dev-env/scripts/launch_r.sh", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [ - { - "name": "R_RPATH_LINUX", - "value": "${config:r.rpath.linux}" - } - ], - "externalConsole": false, - "MIMode": "lldb" + "name": "(lldb) Attach to R", + "type": "lldb", + "request": "attach", + "pid": "${command:pickMyProcess}", + "stopOnEntry": false } ] -} +} \ No newline at end of file From 8449b169a17f61fe15108e7cb078d65ac5ee14bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 10:40:02 +0000 Subject: [PATCH 18/18] [pre-commit.ci] Fixing issues with pre-commit --- .devcontainer/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/launch.json b/.devcontainer/launch.json index 0fa2b45a5..210901430 100644 --- a/.devcontainer/launch.json +++ b/.devcontainer/launch.json @@ -9,4 +9,4 @@ "stopOnEntry": false } ] -} \ No newline at end of file +}