Skip to content

Commit ecd644a

Browse files
committed
Refactor debugging setup: use wrapper env var and update which_r for rpath
1 parent 8d169f3 commit ecd644a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"r.lsp.diagnostics": false,
1717
"r.plot.useHttpgd": true,
1818
"r.rterm.linux": "/workspaces/r-dev-env/scripts/launch_r.sh",
19-
"r.rpath.linux": "/workspaces/r-dev-env/build/r-devel/bin/R",
19+
"r.rpath.linux": "/usr/bin/R",
20+
"terminal.integrated.env.linux": {
21+
"R_RPATH_LINUX": "${config:r.rpath.linux}"
22+
},
2023
"terminal.integrated.sendKeybindingsToShell": true,
2124
"svn.multipleFolders.enabled": true,
2225
"workbench.editorAssociations": {
@@ -36,5 +39,5 @@
3639
]
3740
}
3841
},
39-
"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"
40-
}
42+
"postCreateCommand": "find . -wholename '.git*' -type d -prune -o -type f -exec chown vscode:vscode {} \\; && sh ./scripts/localscript.sh"
43+
}

scripts/localscript.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ local_script(){
99
WORK_DIR=$PWD
1010
VSCODE_DIR="$WORK_DIR/.vscode"
1111
DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json"
12+
SCRIPTS_DIR="$WORK_DIR/scripts"
1213

1314
# Create patch directory in workspace root ($PWD at start)
1415
PATCHDIR="$WORK_DIR/patches"
1516
mkdir -p $PATCHDIR
1617
mkdir -p $VSCODE_DIR
1718

1819
# Copy the which_r and set_build_r function definitions to .bashrc
19-
cat $WORK_DIR/scripts/which_r.sh >> ~/.bashrc
20-
cat $WORK_DIR/scripts/set_build_r.sh >> ~/.bashrc
20+
cat $SCRIPTS_DIR/which_r.sh >> ~/.bashrc
21+
cat $SCRIPTS_DIR/set_build_r.sh >> ~/.bashrc
2122

2223
# Copy over the welcome message script to be run when bash terminal starts
23-
cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc
24+
cat $SCRIPTS_DIR/welcome_msg.sh >> ~/.bashrc
2425

2526
#bash ~/.bashrc
2627

@@ -41,4 +42,10 @@ local_script
4142

4243
# Remove the .vscode/settings.json file if it exists so that
4344
# it does not interfere with the devcontainer.json
44-
rm -f .vscode/settings.json
45+
rm -f "$WORK_DIR/.vscode/settings.json"
46+
47+
# 1. Build the ptrace helper library
48+
gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c"
49+
50+
# 2. Mark the wrapper executable
51+
chmod +x "$SCRIPTS_DIR/launch_r.sh"

scripts/which_r.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ which_r() {
6060
fi
6161

6262
# Update settings.json with the chosen R path
63-
updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rterm.linux"=$subdir | ."r.rpath.linux"=$subdir')
63+
updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rpath.linux"=$subdir')
6464
echo "$updated_settings_data" > "$settings_file_path"
6565

6666
echo "R terminal will now use version: $selected_version"

0 commit comments

Comments
 (0)