Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
75c44f8
changes to devconatiner.json
avinab-neogy Aug 11, 2025
1aeca18
added launch configuration and changed script to move the file to .vs…
avinab-neogy Aug 11, 2025
22b804d
made a correction to the referencing of the launch.json file in the s…
avinab-neogy Aug 11, 2025
95f6509
added step to set cflags in building r tutorial
avinab-neogy Aug 11, 2025
08934b8
added allow_ptrace script
avinab-neogy Aug 11, 2025
615558e
added launch_r script to load the wrapper
avinab-neogy Aug 11, 2025
22b740f
updated local script to build the library and make the wrapper execut…
avinab-neogy Aug 11, 2025
9b2b1f0
updated which_r to execute launch_r and update it
avinab-neogy Aug 11, 2025
921324c
removed vscode,devocntainer and scripts dir from files exclude beacus…
avinab-neogy Aug 11, 2025
6542a19
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Aug 11, 2025
bb7fc01
merged with the latest devel
avinab-neogy Aug 28, 2025
314983c
removed absolute paths
avinab-neogy Aug 28, 2025
bccf15b
updated allow ptrace to remove printing multiple times when the wrapp…
avinab-neogy Aug 28, 2025
0f93b02
updated building r documentation to include the cflags step into the …
avinab-neogy Aug 28, 2025
5bc250b
Update r.rterm.linux setting to use the launch_r.sh script with full …
avinab-neogy Aug 28, 2025
17591ff
move the launch_script variable definition in which_r script
avinab-neogy Aug 28, 2025
d04f11e
[pre-commit.ci] Fixing issues with pre-commit
pre-commit-ci[bot] Sep 9, 2025
9c3aee5
updated which_r.sh
avinab-neogy Sep 9, 2025
6f40896
updated devcontainer.json
avinab-neogy Sep 9, 2025
95f5729
updated devcontainer.json
avinab-neogy Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "R-Dev-Env",
"image": "ghcr.io/r-devel/r-dev-env:devel",
"runArgs": ["--cap-add=SYS_PTRACE"],
"hostRequirements": {
"cpus": 4
},
Expand All @@ -9,8 +10,6 @@
"settings": {
"git.ignoredRepositories": ["."],
"files.exclude": {
"**/.vscode": true,
"**/.devcontainer": true,
"**/.git": true,
"**/.github": true,
"**/.gitignore": true,
Expand All @@ -19,16 +18,15 @@
"**/.markdownlint-cli2.yaml": true,
"**/.pre-commit-config.yaml": true,
"**/Dockerfile": true,
"**/mkdocs.yml": true,
"**/scripts": true
"**/mkdocs.yml": true
},
"editor.tabSize": 8,
"editor.indentSize": 4,
"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",
"terminal.integrated.sendKeybindingsToShell": true,
"svn.multipleFolders.enabled": true,
"workbench.editorAssociations": {
Expand All @@ -43,7 +41,8 @@
"johnstoncode.svn-scm",
"ms-vscode.cpptools",
"MS-vsliveshare.vsliveshare",
"natqe.reload"
"natqe.reload",
"vadimcn.vscode-lldb"
]
}
},
Expand Down
12 changes: 12 additions & 0 deletions .devcontainer/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Attach to R",
"type": "lldb",
"request": "attach",
"pid": "${command:pickMyProcess}",
"stopOnEntry": false
}
]
}
25 changes: 20 additions & 5 deletions docs/tutorials/building_r.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,22 @@ 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"
```

- 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**

- After we change directory, we must run the configure script from the source
directory. This step takes ~1 minute on the codespace.
Expand All @@ -80,7 +95,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.
Expand All @@ -89,7 +104,7 @@ codespace.
make
```

**7) Check R**
**8) Check R**

Check that the build of R passes R's standard checks:

Expand All @@ -101,7 +116,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`
Expand All @@ -125,7 +140,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.
Expand Down
7 changes: 7 additions & 0 deletions scripts/allow_ptrace.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <sys/prctl.h>
#include <stdio.h>

__attribute__((constructor)) void allow_ptrace() {
prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
fprintf(stderr, "allow_ptrace: called\n");
}
4 changes: 4 additions & 0 deletions scripts/launch_r.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
export LD_PRELOAD=/workspaces/r-dev-env/scripts/allow_ptrace.so
# exec /workspaces/r-dev-env/build/r-devel/bin/R "$@"
exec /usr/bin/R "$@"
10 changes: 10 additions & 0 deletions scripts/localscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc
# Remove git directory if it exists
#rm -rf .git

# copy launch.json for debugging config if present
if [ -f "$WORK_DIR/.devcontainer/launch.json" ]; then
cp "$WORK_DIR/.devcontainer/launch.json" "$VSCODE_DIR/launch.json"
fi

# copying vscode extension settings from devcontainer json to vscode settings json using jq
if [ -f "$DEVCONTAINER_JSON" ]; then
jq '.customizations.vscode.settings' "$DEVCONTAINER_JSON" > "$VSCODE_DIR/settings.json"
fi

# Build the ptrace helper library
gcc -shared -fPIC -o "$WORK_DIR/scripts/allow_ptrace.so" "$WORK_DIR/scripts/allow_ptrace.c"

# Mark the wrapper executable
chmod +x "$WORK_DIR/scripts/launch_r.sh"

}

Expand Down
17 changes: 15 additions & 2 deletions scripts/which_r.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
which_r() {
# Specify the parent directory
parent_dir="$WORK_DIR/build"
launch_script="$WORK_DIR/scripts/launch_r.sh"

# Path to the settings.json file
settings_file_path=$WORK_DIR/.vscode/settings.json
Expand Down Expand Up @@ -59,9 +60,21 @@ which_r() {
selected_version="/usr/bin/R"
fi

# Update launch_r.sh to call the selected R binary
if [ -f "$launch_script" ]; then
sed -i "s|^exec .*/R|exec $selected_version|" "$launch_script"
else
echo "Warning: launch_r.sh script not found, skipping update."
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')
echo "$updated_settings_data" > "$settings_file_path"
if [ -f "$settings_file_path" ]; then
tmpfile="${settings_file_path}.tmp.$$"
jq --arg r "$selected_version" '."r.rpath.linux"=$r' "$settings_file_path" > "$tmpfile" && mv "$tmpfile" "$settings_file_path"
else
echo "Warning: VS Code settings.json not found, skipping update."
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."
Expand Down