diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 8937b4ee..6c0fe4c2 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,45 +1,31 @@
-// For format details, see https://aka.ms/devcontainer.json. For config options, see the
-// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
- "name": "R-Dev-Env",
- "image": "ghcr.io/r-devel/r-dev-env:main",
- "hostRequirements": {
- "cpus": 4
- },
-
- "customizations": {
- "vscode": {
- "settings": {
- "r.lsp.diagnostics": false,
- "r.plot.useHttpgd": true,
- "r.rpath.linux": "/usr/bin/R",
- "r.rterm.linux": "/usr/bin/R",
- "terminal.integrated.sendKeybindingsToShell": true,
- "svn.multipleFolders.enabled": true,
+ "name": "R-Dev-Env",
+ "image": "ghcr.io/r-devel/r-dev-env:main",
+ "hostRequirements": {
+ "cpus": 4
+ },
+ "customizations": {
+ "vscode": {
+ "settings": {
+ "r.lsp.diagnostics": false,
+ "r.plot.useHttpgd": true,
+ "r.rpath.linux": "/usr/bin/R",
+ "r.rterm.linux": "/usr/bin/R",
+ "terminal.integrated.sendKeybindingsToShell": true,
+ "svn.multipleFolders.enabled": true,
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
},
"workbench.welcomePage.walkthroughs.openOnInstall": false
- },
- "extensions": [
- "REditorSupport.r",
- "mads-hartmann.bash-ide-vscode",
- "johnstoncode.svn-scm",
- "ms-vscode.cpptools",
- "MS-vsliveshare.vsliveshare"
- ]
- }
-
- },
- "postCreateCommand":"cat /workspaces/r-dev-env/scripts/welcome_msg.sh >> ~/.bashrc && cat /workspaces/r-dev-env/scripts/set_build_r.sh >> ~/.bashrc && bash /workspaces/r-dev-env/scripts/localscript.sh"
- // Features to add to the dev container. More info: https://containers.dev/features.
- // "features": {},
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- // "forwardPorts": [],
- // Use 'postCreateCommand' to run commands after the container is created.
- // "postCreateCommand": "gcc -v",
- // Configure tool-specific properties.
- // "customizations": {},
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
- // "remoteUser": "root"
+ },
+ "extensions": [
+ "REditorSupport.r",
+ "mads-hartmann.bash-ide-vscode",
+ "johnstoncode.svn-scm",
+ "ms-vscode.cpptools",
+ "MS-vsliveshare.vsliveshare"
+ ]
+ }
+ },
+ "postCreateCommand": "chown -R vscode:vscode /workspaces/r-dev-env && sh /workspaces/r-dev-env/scripts/localscript.sh"
}
diff --git a/.github/workflows/build-gitpod-image.yml b/.github/workflows/build-gitpod-image.yml
new file mode 100644
index 00000000..03e04995
--- /dev/null
+++ b/.github/workflows/build-gitpod-image.yml
@@ -0,0 +1,69 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+name: Build and publish Gitpod Docker image
+
+on:
+ workflow_dispatch:
+ pull_request:
+ branches: ["main","devel"]
+ types: [closed]
+ paths:
+ - '.github/workflows/build-gitpod-image.yml'
+ - '.gitpod.Dockerfile'
+ - '.gitpod.yml'
+ - 'reinstall-cmake.sh'
+ - 'VERSION'
+
+
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+ build-and-push-image:
+ if: ${{github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true}}
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Extract version number
+ run: |
+ VER=$(cat VERSION)
+ echo "VERSION=$VER" >> $GITHUB_ENV
+
+ - name: Log in to the Container registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ github.repository }}
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{ env.VERSION }}
+ type=sha
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: .gitpod.Dockerfile
+ push: true
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:gitpod.${{ github.ref_name }}
+ build-args: |
+ CONTAINER_VERSION=${{ env.VERSION }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/optimize-docs-images.yml b/.github/workflows/optimize-docs-images.yml
new file mode 100644
index 00000000..2d024ec2
--- /dev/null
+++ b/.github/workflows/optimize-docs-images.yml
@@ -0,0 +1,44 @@
+name: Optimize Docs Images
+
+on:
+ pull_request:
+ branches: ["main","devel"]
+ types: [closed]
+ paths:
+ - 'docs/assets/**'
+
+jobs:
+ optimize-images:
+ if: ${{github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true}}
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Setup R
+ uses: r-lib/actions/setup-r@v2
+
+ - name: Install system dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libmagick++-dev libcurl4-openssl-dev
+
+ - name: Install R packages
+ run: |
+ R -e 'install.packages(c("magick"), repos = "https://cloud.r-project.org/")'
+
+ - name: Optimize images
+ run: |
+ Rscript ./scripts/optimize.R
+
+ - name: Commit and push optimized images
+ if: github.ref == 'refs/heads/devel' && github.event_name == 'push'
+ run: |
+ git config --global user.name "github-actions[bot]"
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
+ git add docs/assets
+ git commit -m 'Optimize docs images'
+ git push
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile
new file mode 100644
index 00000000..1a4d0f99
--- /dev/null
+++ b/.gitpod.Dockerfile
@@ -0,0 +1,34 @@
+FROM gitpod/workspace-full:latest
+
+USER root
+
+ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
+
+# Optionally install the cmake for vcpkg
+COPY ./reinstall-cmake.sh /tmp/
+
+RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
+ chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
+ fi \
+ && rm -f /tmp/reinstall-cmake.sh
+
+RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \
+ && echo "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" >> /etc/apt/sources.list \
+ && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \
+ && apt update \
+ && apt -y install subversion \
+ && apt -y build-dep r-base-dev \
+ && apt -y install r-base-dev \
+ && apt -y install valgrind \
+ && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \
+ && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')"
+
+RUN apt install -y shellcheck
+RUN apt install -y ccache
+RUN apt install -y rsync
+#RUN /usr/sbin/update-ccache-symlinks
+#RUN echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a /home/vscode/.bashrc
+
+
+ARG CONTAINER_VERSION
+ENV CONTAINER_VERSION ${CONTAINER_VERSION}
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 00000000..2862777b
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,13 @@
+image: ghcr.io/r-devel/r-dev-env:gitpod.devel
+
+tasks:
+ - name: Initial Setup for R-dev-env Gitpod Workspace
+ before: |
+ bash /workspace/r-dev-env/scripts/localscript.sh
+ source ~/.bashrc
+
+
+vscode:
+ extensions:
+ - REditorSupport.r
+ - johnstoncode.svn-scm
diff --git a/CITATION.cff b/CITATION.cff
index 08028606..62f8c9e1 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -1,15 +1,20 @@
-cff-version: 1.2.0
-message: "If you use this software, please cite it as below."
-authors:
- - family-names: Shirdhankar
- given-names: Atharva
- - family-names: Turner
- given-names: Heather
- - family-names: Tripp
- given-names: James
- - family-name: Emsley
- given-names: Iain
-title: "R Development Container"
-version: 0.2.0
-doi:
-date-released: 28-06-2024
+cff-version: 1.2.0
+message: "If you use this software, please cite it as below."
+authors:
+ - family-names: Shirdhankar
+ given-names: Atharva
+ - family-names: Turner
+ given-names: Heather
+ - family-names: Tripp
+ given-names: James
+ - family-name: Emsley
+ given-names: Iain
+ - family-names: Crespo
+ given-names: Lorena
+ - family-names: Campitelli
+ given-names: Elio
+
+title: "R Development Container"
+version: 0.3.0
+doi:
+date-released: 04-09-2024
diff --git a/Dockerfile b/Dockerfile
index 1804eaa5..93f13364 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -26,8 +26,6 @@ RUN apt install -y ccache
#RUN echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a /home/vscode/.bashrc
-ENV BUILDDIR="/workspaces/r-dev-env/build/r-devel"
-ENV TOP_SRCDIR="/workspaces/r-dev-env/svn/r-devel"
-ENV PATCHDIR='/workspaces/r-dev-env/patches'
+
ARG CONTAINER_VERSION
ENV CONTAINER_VERSION ${CONTAINER_VERSION}
diff --git a/INDEX.md b/INDEX.md
index 777fcf98..1ec62c11 100644
--- a/INDEX.md
+++ b/INDEX.md
@@ -3,9 +3,27 @@
If you haven't seen them yet, you can find the
[R Dev Container Docs](https://contributor.r-project.org/r-dev-env/) online.
+This index links to underlying markdown files for key sections of the docs, so you can preview them right here in VS Code.
+
+## Working with the container
+
+The links below give more information on using the container via GitHub Codespaces or Gitpod Workspaces.
+Take a moment to review how to stop and restart your container, so you can continue your work.
+If you are collaborating with others, you may want to use Live Share so that you can share the same workspace.
+
+### Github Codespace
+
+- [Stopping and Restarting Codespace](docs/container_setup/github_codespace/codespacestartstop.md)
+- [Collaborating with Live Share](docs/container_setup/github_codespace/live_share.md)
+
+### Gitpod Workspace
+
+- [Stopping and Restarting Codespace](docs/container_setup/gitpod_workspace/workspacestop_and_restart.md)
+- [Collaborating with Live Share](docs/container_setup/gitpod_workspace/live_share.md)
+
## Tutorials
-You can also preview the tutorials right here in VSCode, making them easier to work through.
+Learn how to use the container with these mini tutorials.
If you have used R in VSCode before, you can skip Tutorial 1.
Tutorials 2 and 3 are the minimum to get started with R development.
You can run through these in about 30 minutes.
@@ -19,9 +37,6 @@ You can refer to the remaining sections as needed!
6. [Multiple R versions](docs/tutorials/multi_r_compilation.md)
7. [SVN Help](docs/tutorials/svn_help.md)
-## Other Docs
+## Further docs
-- [Restarting And Stopping Codespace](docs/container_setup/codespacestartstop.md)
-- [Collaborating with Live Share]((docs/container_setup/live_share.md))
-- [Using R Dev Container Locally](docs/container_setup/localsetup.md)
-- [Useful Resources](docs/resources.md)
\ No newline at end of file
+See the [full documentation](https://contributor.r-project.org/r-dev-env/) for background information on this project, how to contribute to the [documentation](docs/contributor_guide/contributing_to_docs.md) or the [codebase](docs/contributor_guide/contributing_to_codebase.md), [external resources](docs/resources.md) and [troubleshooting](docs/troubleshoot.md).
diff --git a/NEWS.md b/NEWS.md
index 8c0d9411..548f8394 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,13 @@
+## R Development Container 0.3
+
+- Implemented Gitpod setup with GitHub Actions workflow to build Docker images for the Gitpod workspace.
+- Improved `which_r` script with version choice validation and updated both `which_r` and `set_build_r` scripts for enhanced functionality.
+- Resolved local setup permission issues to ensure smoother operation within the devcontainer environment on Linux.
+- Restructured documentation to incorporate Gitpod alternative setup.
+- Implemented a workflow to optimize images so that documentation files are more lightweight.
+
+
+
## R Development Container 0.2
- Documentation split into set of markdown files. These are used to create the documentation website https://contributor.r-project.org/r-dev-env/ and the user-focused pages can be accessed directly within the codespace, linked from an index that opens when the codespace first starts. New documentation pages/topics:
diff --git a/VERSION b/VERSION
index 0ea3a944..0d91a54c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.0
+0.3.0
diff --git a/docs/assets/gitpod1.png b/docs/assets/gitpod1.png
new file mode 100644
index 00000000..7a2f2271
Binary files /dev/null and b/docs/assets/gitpod1.png differ
diff --git a/docs/assets/gitpod2.png b/docs/assets/gitpod2.png
new file mode 100644
index 00000000..c8227290
Binary files /dev/null and b/docs/assets/gitpod2.png differ
diff --git a/docs/assets/gitpod3.png b/docs/assets/gitpod3.png
new file mode 100644
index 00000000..232bd5c6
Binary files /dev/null and b/docs/assets/gitpod3.png differ
diff --git a/docs/assets/gitpod4.png b/docs/assets/gitpod4.png
new file mode 100644
index 00000000..dc6cb7c2
Binary files /dev/null and b/docs/assets/gitpod4.png differ
diff --git a/docs/assets/gitpod5.png b/docs/assets/gitpod5.png
new file mode 100644
index 00000000..d1157b2e
Binary files /dev/null and b/docs/assets/gitpod5.png differ
diff --git a/docs/assets/gitpod6.png b/docs/assets/gitpod6.png
new file mode 100644
index 00000000..736a961d
Binary files /dev/null and b/docs/assets/gitpod6.png differ
diff --git a/docs/assets/manage_codespace.png b/docs/assets/manage_codespace.png
new file mode 100644
index 00000000..ef8ba884
Binary files /dev/null and b/docs/assets/manage_codespace.png differ
diff --git a/docs/assets/manage_workspace.png b/docs/assets/manage_workspace.png
new file mode 100644
index 00000000..225f5bc9
Binary files /dev/null and b/docs/assets/manage_workspace.png differ
diff --git a/docs/container_setup/codespacestartstop.md b/docs/container_setup/codespacestartstop.md
deleted file mode 100644
index e0124bbd..00000000
--- a/docs/container_setup/codespacestartstop.md
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-#### How to Stop Codespaces?
-- To stop codespaces we just need to navigate to the Codespaces option in the bottom left of the Codespace panel.
-
- ![stop codespace](../assets/rdev14.png)
-
-- After clicking on codespaces option we will get a drop down above something like this👇
-
- ![stop codespace](../assets/rdev15.png)
-
-- Click on "Stop Current Codespace". It will stop the codespaces you are currently using or running.
-
-- You will be redirected to a Restart Codespaces page. The page shows a link to restart the codespace you just stopped.
-
- ![stop codespace](../assets/rdev16.png)
-
-
-#### Idle timeout:
-If you do not interact with the codespace, it will close automatically when it reaches the idle timeout limit. By default, this is 30 minutes, but you can [set a personal timeout](https://docs.github.com/en/codespaces/setting-your-user-preferences/setting-your-timeout-period-for-github-codespaces#setting-your-default-timeout-period) limit in your GitHub settings.
-
-The code changes and operations we have performed inside the codespace will still be inside the stopped codespace. If your codespace is stopped then you can restart it as shown below.
-
-#### How to Restart Codespaces again?
-
-- Go to [github.com/codespaces](https://github.com/codespaces)
-- Here we can see a list of the codespaces we have created
- ![stop codespace](../assets/rdev17.png)
-- To restart it, we can just click on the codespaces we wanted to use and it will start the codespaces again for us.
-- You can also see an active label added to the codespaces we just started
- ![stop codespace](../assets/rdev18.png)
diff --git a/docs/container_setup/github_codespace/codespacestartstop.md b/docs/container_setup/github_codespace/codespacestartstop.md
new file mode 100644
index 00000000..34293adc
--- /dev/null
+++ b/docs/container_setup/github_codespace/codespacestartstop.md
@@ -0,0 +1,70 @@
+
+
+#### How to Stop Codespaces?
+- To stop codespaces we just need to navigate to the Codespaces option in the bottom left of the Codespace panel.
+
+ ![stop codespace](../../assets/rdev14.png)
+
+- After clicking on codespaces option we will get a drop down above something like this👇
+
+ ![stop codespace](../../assets/rdev15.png)
+
+- Click on "Stop Current Codespace". It will stop the codespaces you are currently using or running.
+
+- You will be redirected to a Restart Codespaces page. The page shows a link to restart the codespace you just stopped.
+
+ ![stop codespace](../../assets/rdev16.png)
+
+
+#### Idle timeout:
+If you do not interact with the codespace, it will close automatically when it reaches the idle timeout limit. By default, this is 30 minutes, but you can [set a personal timeout](https://docs.github.com/en/codespaces/setting-your-user-preferences/setting-your-timeout-period-for-github-codespaces#setting-your-default-timeout-period) limit in your GitHub settings.
+
+The code changes and operations we have performed inside the codespace will still be inside the stopped codespace. If your codespace is stopped then you can restart it as shown below.
+
+#### How to Restart Codespaces again?
+
+- Go to [github.com/codespaces](https://github.com/codespaces)
+- Here we can see a list of the codespaces we have created
+ ![stop codespace](../../assets/rdev17.png)
+- To restart it, we can just click on the codespaces we wanted to use and it will start the codespaces again for us.
+- You can also see an active label added to the codespaces we just started
+ ![stop codespace](../../assets/rdev18.png)
+
+
+#### Managing and Sustaining Codespaces
+
+##### Setting a Default Retention Period for Your Codespaces
+
+**Access Settings:**
+
+- Click your profile photo in the upper-right corner of any GitHub page.
+- Click "Settings."
+
+**Navigate to Codespaces Settings:**
+
+- In the sidebar, under "Code, planning, and automation," click "Codespaces."
+
+**Set Retention Period:**
+
+- Under "Default retention period," enter the number of days (between 0 and 30) for which you want your codespaces to be retained after they have been stopped.
+Example: Setting it to 30 days.
+![retain codespace](../../assets/manage_codespace.png)
+
+**Warning:**
+
+- Setting the retention period to 0 days will result in immediate deletion of codespaces when stopped or when they timeout due to inactivity.
+For more details, refer to "Setting your timeout period for GitHub Codespaces."
+
+**Save Changes:**
+
+- Click "Save" to apply the new retention period.
+
+
+This allows you to customize how long your codespaces are kept before automatic deletion, balancing convenience and storage management.
+
+**Auto Delete Codespace:**
+
+- Go to the "Your codespaces" page at [github.com/codespaces](https://github.com/codespaces).
+- Find the codespace you want to exempt from deletion.
+- Click the options menu (three dots) to the right of the codespace.
+- Select "Auto Delete Codespace" from the dropdown menu. The bookmarked codespaces will not be auto-deleted.
\ No newline at end of file
diff --git a/docs/container_setup/creating_codespace.md b/docs/container_setup/github_codespace/creating_codespace.md
similarity index 93%
rename from docs/container_setup/creating_codespace.md
rename to docs/container_setup/github_codespace/creating_codespace.md
index 79528ada..f81134bb 100644
--- a/docs/container_setup/creating_codespace.md
+++ b/docs/container_setup/github_codespace/creating_codespace.md
@@ -1,6 +1,6 @@
1. From the main branch of the [r-dev-env repo](https://github.com/r-devel/r-dev-env/tree/main), click on the 'Open in GitHub Codespaces' button and then click the green 'Create Codespace' button.
-![create codespace](../assets/rdev1.png)
+![create codespace](../../assets/rdev1.png)
!!! Note
You will see the message "Codespace usage for this repository is paid for by ...", with your username. Don't panic!
@@ -15,6 +15,6 @@
2. The codespace setup screen will then be shown. Starting the container may take a minute or so.
3. You will be taken to a VSCode editor within your browser.
-![codespace](../assets/rdev3.png)
+![codespace](../../assets/rdev3.png)
diff --git a/docs/container_setup/live_share.md b/docs/container_setup/github_codespace/live_share.md
similarity index 93%
rename from docs/container_setup/live_share.md
rename to docs/container_setup/github_codespace/live_share.md
index c9b6107a..e2fc1d99 100644
--- a/docs/container_setup/live_share.md
+++ b/docs/container_setup/github_codespace/live_share.md
@@ -8,10 +8,10 @@ Live Share is a powerful feature that allows you to collaborate with others in r
1. **Click the "Live Share" button** in the status bar.
Alternatively you can go to Live Share extension tab and select from the options to share with read/write permission or share with read-only permission.
-![alt text](../assets/live-share.png)
+![alt text](../../assets/live-share.png)
2. **Share the Link**: A sharing link will be generated and copied to the clipboard for sharing with your collaborators. From the pop-up dialog, you can copy the link again or switch the permissions from read/write to read-only (or vice versa).
-![alt text](../assets/live-share2.png)
+![alt text](../../assets/live-share2.png)
### Join a Live Share Session
@@ -20,7 +20,7 @@ Alternatively you can go to Live Share extension tab and select from the options
- **Open the link in a web browser**: click the link to open it in your web browser. If you have VS Code installed locally, a pop-up dialog will give you the choice of continuing in the web or opening the session in VS Code. You can join the session anonymously or sign in with your Microsoft or GitHub account.
- **Copy the link into VSCode or the R Dev Container Codespace**: From the Live share extension tab, click the "Join" button. If you are using VS Code locally, you can choose to join the session anonymously or sign in with your Microsoft or GitHub account. If you are using the Codespace, you will already be signed in with your GitHub account. A pop-up at the top of the VSCode window will ask for the Live Share session link. Paste the link and click 'Enter'.
-![alt text](../assets/live-share3.png).
+![alt text](../../assets/live-share3.png).
3. **Wait to be accepted by the host**. The host will receive a pop-up message where they can accept your request to join.
@@ -31,8 +31,8 @@ Once joined, you can:
- **Edit Code Together**: Both the host and guests can edit files, and changes will be synchronized in real-time.
- **Share Terminals**: The host can share bash or R terminals. Guests can see the terminal output and, if granted permission, type commands.
- **Live Chat**: Session chat can be opened from the Live share extension tab.
-![alt text](../assets/live-share6.png)
-![alt text](../assets/live-share5.png)
+![alt text](../../assets/live-share6.png)
+![alt text](../../assets/live-share5.png)
### Manage control
@@ -46,7 +46,7 @@ You can rejoin a session if disconnected, and your previous state will be restor
### Close a Live Share Session
When you want to close the live share session, you can go to Live Share Extension tab and click on stop icon.
-![alt text](../assets/live-share4.png).
+![alt text](../../assets/live-share4.png).
If you are a guest, the live share session will continue to run without you. If you are the host this will close the session for everyone.
diff --git a/docs/container_setup/gitpod_workspace/live_share.md b/docs/container_setup/gitpod_workspace/live_share.md
new file mode 100644
index 00000000..365e88eb
--- /dev/null
+++ b/docs/container_setup/gitpod_workspace/live_share.md
@@ -0,0 +1,11 @@
+## Gitpod Live Share Alternative
+1. Gitpod live share can be started from dashboard itself by clicking on `Share` option on dashboard.
+
+ ![liveshare](../../assets/gitpod5.png)
+
+2. After that whenever you open Gitpod Workspace the live share is enabled and ready to share workspace with others.
+
+
+ ![liveshare](../../assets/gitpod6.png)
+
+ !!! Note: The live share will be enabled even if you close the workspace.
\ No newline at end of file
diff --git a/docs/container_setup/gitpod_workspace/workspacestart.md b/docs/container_setup/gitpod_workspace/workspacestart.md
new file mode 100644
index 00000000..167c263d
--- /dev/null
+++ b/docs/container_setup/gitpod_workspace/workspacestart.md
@@ -0,0 +1,21 @@
+
+### Starting a Gitpod Workspace
+
+1. **Log In:**
+Go to the [Gitpod login page](https://gitpod.io/login/) and sign in with your GitHub, GitLab, or Bitbucket account. This allows Gitpod to create workspaces from your repositories.
+
+2. **Create a workspace using the R Dev Container repo:**
+Click the Gitpod badge below to open the Gitpod workspace creation dialog with the relevant options pre-filled:
+
+
+ [![Open in Gitpod](https://img.shields.io/badge/Gitpod-Open%20in%20Gitpod-blue?logo=gitpod&style=for-the-badge)](https://gitpod.io/github.com/r-devel/r-dev-env/tree/main){:target="_blank"}
+
+
+
+ ![start gitpod workspace](../../assets/gitpod1.png){width="70%"}
+
+
+ Click the "Continue" button in the Gitpod dialog to create a workspace. It will take approximately 15-20 minutes to create the workspace for the first time. The environment will be cached for faster startup in the future.
+
+ !!! Note
+ Changing the resource option from Standard to Large will reduce the free monthly Gitpod usage, which is 50 hours per month of Standard workspace usage. See the [billing](https://www.gitpod.io/docs/configure/billing) docs for more information.
\ No newline at end of file
diff --git a/docs/container_setup/gitpod_workspace/workspacestop_and_restart.md b/docs/container_setup/gitpod_workspace/workspacestop_and_restart.md
new file mode 100644
index 00000000..8927fb02
--- /dev/null
+++ b/docs/container_setup/gitpod_workspace/workspacestop_and_restart.md
@@ -0,0 +1,45 @@
+### Stopping a Gitpod Workspace
+
+1. **Locate the Gitpod Command Palette Button:**
+To stop the current workspace, look for the orange Gitpod command palette button in the bottom left corner of the workspace.
+
+ ![stop gitpod workspace](../../assets/gitpod2.png)
+2. **Open the Command Palette and Stop the Workspace:**
+After clicking on the Gitpod command palette button, a pop-up will appear from the top of the screen. Select the Gitpod: Stop Workspace option to stop the current workspace.
+
+ ![stop gitpod workspace](../../assets/gitpod3.png)
+
+
+ !!! Note
+ Stopping a workspace will save its state, so you can resume later without losing your progress.
+
+
+### Restarting a Gitpod Workspace
+
+1. **Open Gitpod Dashboard:**
+Once you're in the Gitpod dashboard, navigate to the "Workspaces" section. In the "Workspaces" section, you will see a list of your current and past workspaces. Locate the workspace you want to restart. Stopped workspaces will have an indicator showing they are not running.
+
+ ![restart gitpod workspace](../../assets/gitpod4.png)
+2. **Restart the Workspace:**
+To restart a workspace, click on the workspace in the list you want to restart. This will launch the workspace, restoring it to the state it was in when it was last stopped.
+
+
+### Managing and Sustaining Codespaces
+
+**Gitpod Workspace Pinning**
+
+**Purpose:** Workspace pinning prevents important workspaces from being automatically deleted.
+
+**Pinned Workspace:** A workspace that has been pinned will never be deleted, regardless of inactivity or other automated processes.
+
+**How to Pin:**
+
+- Navigate to your workspace list in the Gitpod dashboard.
+- Identify the workspace you want to keep permanently.
+- Pin the workspace to ensure it remains available and is not subject to deletion.
+![manage gitpod workspace](../../assets/manage_workspace.png)
+
+**Benefits:**
+
+Protects critical projects or environments from accidental loss.
+Ensures long-term availability of specific workspaces that you frequently use or need to preserve.
\ No newline at end of file
diff --git a/docs/container_setup/index.md b/docs/container_setup/index.md
new file mode 100644
index 00000000..c4d096da
--- /dev/null
+++ b/docs/container_setup/index.md
@@ -0,0 +1,11 @@
+# Container Setup
+
+You can run the R Dev Container in one of the ways:
+
+- **GitHub Codespaces**: Offers 60 hours per month of free usage for 2-core set-ups and 15GB of free storage. The R Dev Container codespace is set up to use 4 cores by default, which gives users 30 hours per month of free usage. Check out the [Codespace pricing docs](https://docs.github.com/en/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#about-github-codespaces-pricing) for more information.
+
+- **Gitpod Workspaces**: Offers 50 hours per month of free usage. Check out the [Gitpod pricing docs](https://www.gitpod.io/pricing) for more information.
+
+- **Local Setup**: Currently recommended for Linux users only.
+
+Explore the sub-sections for detailed instructions on setting up and using the container for each option.
\ No newline at end of file
diff --git a/docs/container_setup/localsetup.md b/docs/container_setup/local_setup/localsetup.md
similarity index 93%
rename from docs/container_setup/localsetup.md
rename to docs/container_setup/local_setup/localsetup.md
index 97bd1786..3459533b 100644
--- a/docs/container_setup/localsetup.md
+++ b/docs/container_setup/local_setup/localsetup.md
@@ -34,11 +34,11 @@ systemctl start docker
6. We can see pop-up at the bottom right of the VSCode editor which says reopen in Dev Container.
Click on `Reopen in DevContainer` button.
-![start localsetup](../assets/rdev13.png)
+![start localsetup](../../assets/rdev13.png)
7. After clicking on that button we will see our container is getting ready. It will take some time. So till that time you can have coffee :)
-![start localsetup](../assets/rdev24.png)
+![start localsetup](../../assets/rdev24.png)
8. We can also test whether the dev container is working or not by just printing the environment variables mentioned in the welcome message on the terminal. And there we go!!! We have setup our R Dev Container locally.
-![start localsetup](../assets/rdev25.png)
+![start localsetup](../../assets/rdev25.png)
9. The container will be closed when you close VSCode. To reopen the container, open the `r-dev-env` directory in VSCode.
\ No newline at end of file
diff --git a/docs/troubleshoot.md b/docs/troubleshoot.md
new file mode 100644
index 00000000..410d9494
--- /dev/null
+++ b/docs/troubleshoot.md
@@ -0,0 +1,15 @@
+While working with an R Dev Container, you may encounter some known errors. Here are a few common ones:
+
+1. #### Error: Rsync Connection Limit Reached, Preventing New Connections
+
+ **Description :** When attempting to use rsync, you may encounter the following error message:
+
+ ```
+ $TOP_SRCDIR/tools/rsync-recommended @ERROR: max connections (59) reached -- try again later rsync error: error starting client-server protocol (code 5) at main.c(1863) [Receiver=3.2.7] *** rsync failed to update Recommended files ***
+ ```
+ **Cause :** This error occurs because the rsync server has reached its maximum allowed number of simultaneous connections, which is set to 59. As a result, new connection attempts are rejected until some of the existing connections are closed.
+
+ **Solutions :**
+ 1. Retry After Some Time : Wait for a few minutes and try running the rsync command again. The number of active connections may decrease, allowing you to connect.
+ 2. Restart Codespace : Sometimes, simply restarting your Codespace can resolve temporary connection issues. Try restarting your Codespace and then attempt the rsync command again.
+
diff --git a/docs/tutorials/building_r.md b/docs/tutorials/building_r.md
index f0f980d2..7a68113e 100644
--- a/docs/tutorials/building_r.md
+++ b/docs/tutorials/building_r.md
@@ -5,18 +5,18 @@
- `TOP_SRCDIR` defines the source directory: `/workspaces/r-dev-env/svn/r-devel`
- The environment variables are set in the codespace image and are available when the codespace starts.
- ![alt text](../assets/rdev6.png)
+ ![alt text](../assets/rdev6.png)
**2) svn checkout**
- The svn checkout command lets us create a local copy of a specific tag/branch of a repository.
- We can check out the latest version of the trunk (the main branch) of the R sources to $TOP_SRCDIR as follows:
-```bash
- svn checkout https://svn.r-project.org/R/trunk/ $TOP_SRCDIR
-```
+ ```bash
+ svn checkout https://svn.r-project.org/R/trunk/ $TOP_SRCDIR
+ ```
- Output : We get file structure something like this after checking out R source code from R svn repository.
- ![alt text](../assets/rdev8.png)
+ ![alt text](../assets/rdev8.png)
**3) Download recommended packages for R**
@@ -45,14 +45,17 @@ cd $BUILDDIR
- After we change directory, we must run the configure script from the source directory.
This step takes ~1 minute on the codespace.
```bash
-$TOP_SRCDIR/configure
+$TOP_SRCDIR/configure --with-valgrind-instrumentation=1
```
+ !!! Note
+ The `--with-valgrind-instrumentation` option is set to 1 for effective use of valgrind. See the [Using valgrind](https://cran.r-project.org/doc/manuals/R-exts.html#Using-valgrind) section of the R-admin manual for more information.
+
- The configure cmd prepares for building R, creating files and folders inside the BUILDDIR directory.
- Output : We get file structure something like this after using configure command.
- ![alt text](../assets/rdev7.png)
+ ![alt text](../assets/rdev7.png)
**6) Build R**
diff --git a/docs/tutorials/live_share.md b/docs/tutorials/live_share.md
deleted file mode 100644
index 6e5c7381..00000000
--- a/docs/tutorials/live_share.md
+++ /dev/null
@@ -1,74 +0,0 @@
-Github Codespaces (VS Code) Live Share is a powerful feature that allows you to collaborate with others in real-time directly within the editor. You can share your code, terminal, debugging sessions, and more with your collaborators. Here’s a step-by-step guide on how to use Live Share with VS Code:
-
-### Step 1: Install Live Share Extension
-It's already install on R-dev-env codespaces.
-But if you want to install it on Local VSCode Editor and collaborate with developer working on R-Dev-Env Workspace you can install using below steps.
-
-1. **Open VS Code**.
-2. **Go to the Extensions View** by clicking the Extensions icon in the Activity Bar on the side of the window or pressing `Ctrl+Shift+X`.
-3. **Search for "Live Share"** in the Extensions marketplace.
-4. **Install the Live Share Extension** (Visual Studio Live Share by Microsoft).
-
-### Step 2: Sign In to Live Share
-
-1. **After installing the extension**, you’ll see a "Live Share" button on the status bar at the bottom of the VS Code window.
-2. **Click the "Live Share" button**.
-3. **Sign in** using your Microsoft or GitHub account.
-
-### Step 3: Start a Live Share Session
-
-1. **Open a Project** or folder that you want to share.
-2. **Click the "Live Share" button** in the status bar or press `Ctrl+Shift+P` and then type and select `Live Share: Start Collaboration Session`.
-Alternatively you can go to Live Share extension tab and select the option to start Live share with read/write permission or just read only permission.
-![alt text](../assets/live-share.png)
-
-3. **Copy the Link**: A sharing link will be generated. You can copy this link and share it with your collaborators.
-![alt text](../assets/live-share2.png)
-
-### Step 4: Join a Live Share Session
-
-1. **Receive the Link** from the host. The link will be something in this form `https://prod.liveshare.vsengsaas.visualstudio.com/join?[37 alphanumberic characters]`
-2. **Click on the Link**: It will open VS Code and join the Live Share session automatically.
-3. Alternatively, you can **press `Ctrl+Shift+P`**, type `Live Share: Join Collaboration Session`, and then paste the link. Or you can again use the Live share extension tab and join the session using Join option. This will give a pop-up on the top of the VSCode window asking for Live Share session link. Enter link and click 'Enter'.
-![alt text](../assets/live-share3.png).
-
-### Step 5: Close Live Share Session
-When you want to close live share session, you can go to Live Share Extension tab and click on stop icon. This will close the live share session.
-![alt text](../assets/live-share4.png).
-
-### Step 6: Collaborate in Real-Time
-
-Once joined, you can:
-
-- **Edit Code Together**: Both the host and guests can edit files, and changes will be synchronized in real-time.
-- **Share Terminals**: The host can share a terminal with guests. Guests can see the terminal output and, if granted permission, type commands.
-- **Debug Together**: Start debugging sessions that all participants can see and interact with.
-- **Share Servers**: If you’re running a local web server, you can share it with guests so they can access it in their browsers.
-
-Live Chat using Live Share
-![alt text](../assets/live-share6.png)
-![alt text](../assets/live-share5.png)
-
-### Step 7: Manage Permissions
-
-The host has control over the session and can manage permissions:
-
-1. **Sharing Terminals**: When you share a terminal, you can choose to make it read-only or give guests write access.
-2. **Read-Only Access**: You can start a session in read-only mode where guests can only view the files but not edit them.
-3. **Follow Mode**: Both the host and guests can enable "Follow Mode" to follow each other’s cursor and view.
-
-### Step 8: End the Live Share Session
-
-1. **Click the "Live Share" button** again in the status bar.
-2. Select **"End Collaboration Session"** to stop sharing your environment.
-
-### Tips for Effective Collaboration
-
-- **Use Voice/Video Chat**: Combine Live Share with a voice or video call (e.g., Zoom, Teams, etc.) for better communication.
-- **Share Comments**: Use comments in the code to communicate specific points or suggestions.
-- **Debug Together**: Utilize the shared debugging capabilities to troubleshoot issues collaboratively.
-
-### Additional Features
-
-- **Session Persistence**: You can rejoin a session if disconnected, and your previous state will be restored.
-- **Guest Invitations**: You can invite specific people to join your session from the Live Share extension.
diff --git a/mkdocs.yml b/mkdocs.yml
index 736881a5..8c564526 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,73 +1,81 @@
-site_name: R Devel Container Docs
-repo_name: r-devel/r-dev-env
-repo_url: https://github.com/r-devel/r-dev-env
-nav:
- - 'Home': index.md
- - 'Container Setup':
- - 'Starting Codespace': 'container_setup/creating_codespace.md'
- - 'Restarting and Stopping' : 'container_setup/codespacestartstop.md'
- - 'Collaborating with Live Share' : 'container_setup/live_share.md'
- - 'Local Setup' : 'container_setup/localsetup.md'
- - 'Tutorials':
- - 'Running R' : 'tutorials/running_r.md'
- - 'Building R': 'tutorials/building_r.md'
- - 'R Contribution Workflow' : 'tutorials/contribution_workflow.md'
- - 'Updating Source Code' : 'tutorials/update_source.md'
- - 'Creating a Patch File' : 'tutorials/patch_update.md'
- - 'Multiple R Versions' : 'tutorials/multi_r_compilation.md'
- - 'SVN Help' : 'tutorials/svn_help.md'
- - 'Contributor Guide' :
- - 'contributor_guide/contributing_to_docs.md'
- - 'contributor_guide/contributing_to_codebase.md'
- - 'Resources' : resources.md
-theme:
- name: material
- features:
- - navigation.tabs
- - navigation.sections
- - toc.integrate
- - navigation.top
- - search.suggest
- - search.highlight
- - content.tabs.link
- - content.code.annotation
- - content.code.copy
-
-
- palette:
- - scheme: default
- toggle:
- icon: material/brightness-7
- name: Switch to dark mode
- primary: indigo
- accent: blue
- - scheme: slate
- toggle:
- icon: material/brightness-4
- name: Switch to light mode
- primary: indigo
- accent: blue
-
-plugins:
- - social
-
-extra:
- social:
- - icon: fontawesome/brands/github
- link: https://github.com/r-devel/r-dev-env/
- - icon: fontawesome/brands/slack
- link: https://r-contributors.slack.com/
-
-markdown_extensions:
- - pymdownx.highlight:
- anchor_linenums: true
- - pymdownx.inlinehilite
- - pymdownx.snippets
- - admonition
- - pymdownx.arithmatex:
- generic: true
- - footnotes
- - pymdownx.details
- - pymdownx.superfences
- - pymdownx.mark
- - attr_list
+site_name: R Devel Container Docs
+repo_name: r-devel/r-dev-env
+repo_url: https://github.com/r-devel/r-dev-env
+nav:
+ - 'Home': 'index.md'
+ - 'Container Setup':
+ - 'Overview': 'container_setup/index.md'
+ - 'Github Codespace':
+ - 'Starting Codespace': 'container_setup/github_codespace/creating_codespace.md'
+ - 'Stopping and Restarting' : 'container_setup/github_codespace/codespacestartstop.md'
+ - 'Collaborating with Live Share' : 'container_setup/github_codespace/live_share.md'
+ - 'Gitpod Workspace':
+ - 'Start Workspace': 'container_setup/gitpod_workspace/workspacestart.md'
+ - 'Stopping and Restarting' : 'container_setup/gitpod_workspace/workspacestop_and_restart.md'
+ - 'Collaborating with Live Share' : 'container_setup/gitpod_workspace/live_share.md'
+ - 'Local Setup' :
+ - 'Docker': 'container_setup/local_setup/localsetup.md'
+ - 'Tutorials':
+ - 'Running R' : 'tutorials/running_r.md'
+ - 'Building R': 'tutorials/building_r.md'
+ - 'R Contribution Workflow' : 'tutorials/contribution_workflow.md'
+ - 'Updating Source Code' : 'tutorials/update_source.md'
+ - 'Creating a Patch File' : 'tutorials/patch_update.md'
+ - 'Multiple R Versions' : 'tutorials/multi_r_compilation.md'
+ - 'SVN Help' : 'tutorials/svn_help.md'
+ - 'Contributor Guide' :
+ - 'contributor_guide/contributing_to_docs.md'
+ - 'contributor_guide/contributing_to_codebase.md'
+ - 'Resources' : 'resources.md'
+ - 'Troubleshooting Info' : 'troubleshoot.md'
+theme:
+ name: material
+ features:
+ - navigation.tabs
+ - navigation.sections
+ - toc.integrate
+ - navigation.top
+ - search.suggest
+ - search.highlight
+ - content.tabs.link
+ - content.code.annotation
+ - content.code.copy
+
+
+ palette:
+ - scheme: default
+ toggle:
+ icon: material/brightness-7
+ name: Switch to dark mode
+ primary: indigo
+ accent: blue
+ - scheme: slate
+ toggle:
+ icon: material/brightness-4
+ name: Switch to light mode
+ primary: indigo
+ accent: blue
+
+plugins:
+ - social
+
+extra:
+ social:
+ - icon: fontawesome/brands/github
+ link: https://github.com/r-devel/r-dev-env/
+ - icon: fontawesome/brands/slack
+ link: https://r-contributors.slack.com/
+
+markdown_extensions:
+ - pymdownx.highlight:
+ anchor_linenums: true
+ - pymdownx.inlinehilite
+ - pymdownx.snippets
+ - admonition
+ - pymdownx.arithmatex:
+ generic: true
+ - footnotes
+ - pymdownx.details
+ - pymdownx.superfences
+ - pymdownx.mark
+ - attr_list
diff --git a/scripts/localscript.sh b/scripts/localscript.sh
index e7b685ca..b8b793f6 100644
--- a/scripts/localscript.sh
+++ b/scripts/localscript.sh
@@ -1,13 +1,38 @@
+# This script is run after the workspace is created
#!/bin/bash
-mkdir -p /home/vscode/.local/bin
+local_script(){
+
+# Workspace root is $PWD at the start
+WORK_DIR=$PWD
+VSCODE_DIR="$WORK_DIR/.vscode"
+DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json"
+
+# Create patch directory in workspace root ($PWD at start)
+PATCHDIR="$WORK_DIR/patches"
mkdir -p $PATCHDIR
+mkdir -p $VSCODE_DIR
-chmod +x /workspaces/r-dev-env/scripts/which_r.sh
-chmod +x /workspaces/r-dev-env/scripts/set_build_r.sh
+# 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
-cp /workspaces/r-dev-env/scripts/which_r.sh /home/vscode/.local/bin/which_r
-# cp /workspaces/r-dev-env/scripts/set_build_r.sh /home/vscode/.local/bin/set_build_r
+# Copy over the welcome message script to be run when bash terminal starts
+cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc
-# remove git directory
+#bash ~/.bashrc
+
+# Remove git directory if it exists
rm -rf .git
+
+# 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
+
+
+}
+
+
+# Run the main function
+local_script
diff --git a/scripts/optimize.R b/scripts/optimize.R
new file mode 100644
index 00000000..6158f144
--- /dev/null
+++ b/scripts/optimize.R
@@ -0,0 +1,34 @@
+library(magick)
+library(tools)
+
+# Define the directory containing images
+image_dir <- file.path("docs", "assets")
+
+# Get all photos in the directory with specified extensions
+files <- dir(image_dir, pattern = "\\.(jpeg|jpg|png)$", ignore.case = TRUE)
+
+# Process each file
+for (i in seq_along(files)) {
+ # Read the image
+ file_path <- file.path(image_dir, files[i])
+ img <- tryCatch({
+ image_read(file_path)
+ }, error = function(e) {
+ message("Error reading image: ", file_path)
+ next
+ })
+
+ # Resize the image to 1000 px width using Lanczos filter for resampling
+ img <- image_resize(img, geometry_size_pixels(width = 1000), filter = "Lanczos")
+
+ # Define the output path, changing the extension to .png
+ output_path <- file_path_sans_ext(file_path)
+ output_path <- paste0(output_path, ".png")
+
+ # Write the optimized image (overwrite original image) as PNG with compression
+ tryCatch({
+ image_write(img, output_path, format = "png", compression = "Zip")
+ }, error = function(e) {
+ message("Error writing image: ", output_path)
+ })
+}
diff --git a/scripts/set_build_r.sh b/scripts/set_build_r.sh
index 608833b2..0ff9d879 100644
--- a/scripts/set_build_r.sh
+++ b/scripts/set_build_r.sh
@@ -5,8 +5,8 @@ set_build_r() {
echo "TOP_SRCDIR is currently set to $TOP_SRCDIR"
else
NAME=$1
- export BUILDDIR="/workspaces/r-dev-env/build/$NAME"
- export TOP_SRCDIR="/workspaces/r-dev-env/svn/$NAME"
+ export BUILDDIR="$WORK_DIR/build/$NAME"
+ export TOP_SRCDIR="$WORK_DIR/svn/$NAME"
echo "BUILDDIR is now set to $BUILDDIR"
echo "TOP_SRCDIR is now set to $TOP_SRCDIR"
fi
diff --git a/scripts/welcome_msg.sh b/scripts/welcome_msg.sh
index 673b892d..a6dde17f 100755
--- a/scripts/welcome_msg.sh
+++ b/scripts/welcome_msg.sh
@@ -1,5 +1,12 @@
+# This script is run everytime workspace is started (when bash terminal started)
#!/bin/bash
+# define helper environment variables based on workspace root ($PWD at start)
+export WORK_DIR=$PWD
+export BUILDDIR="$WORK_DIR/build/r-devel"
+export TOP_SRCDIR="$WORK_DIR/svn/r-devel"
+export PATCHDIR="$WORK_DIR/patches"
+
# clear the screen before displaying welcome message
clear
diff --git a/scripts/which_r.sh b/scripts/which_r.sh
index 3b584b2b..d5e10f61 100644
--- a/scripts/which_r.sh
+++ b/scripts/which_r.sh
@@ -1,66 +1,67 @@
-#!/bin/bash
-# Specify the parent directory
-parent_dir="/workspaces/r-dev-env/build" # need to change to dynamic afterwards //TODO
-# Path to the settings.json file
-settings_file_path="/home/vscode/.vscode-remote/data/Machine/settings.json"
+which_r() {
+ # Specify the parent directory
+ parent_dir="$WORK_DIR/build"
-built_in_r_version=$(R --version | grep "^R version" | awk '{print $3}')
+ # Path to the settings.json file
+ settings_file_path=$WORK_DIR/.vscode/settings.json
-# 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)"
+ built_in_r_version=$(R --version | grep "^R version" | awk '{print $3}')
-# Check for additional R versions in subdirectories
-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"
- ((counter++))
- fi
- done
-
-fi
+ # 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)"
-# 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
+ # Check for additional R versions in subdirectories
+ if [ -d "$parent_dir" ]; then
+ # Create an array to store subdirectory names
+ subdirs=()
-# Get user choice
-read -p "Enter the number corresponding to the selected version: " choice
+ # 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"
+ ((counter++))
+ fi
+ done
+ fi
-# 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"
-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."
+ # If no additional R builds were found
+ if [ ${#subdirs[@]} -eq 0 ]; then
+ range=1
+ echo "No additional R builds available."
else
- echo "Invalid choice, please select options between 1 to $range. Defaulting to built-in R version."
+ range=$((counter - 1))
+ fi
+
+ # Get user choice
+ read -p "Enter the number corresponding to the selected version: " 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"
+ 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"
fi
- selected_version="/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.rterm.linux"=$subdir')
-echo "$updated_settings_data" > "$settings_file_path"
+ # Update settings.json with the chosen R path
+ updated_settings_data=$(cat "$settings_file_path" | jq --arg subdir "$selected_version" '."r.rterm.linux"=$subdir')
+ echo "$updated_settings_data" > "$settings_file_path"
-echo "R terminal will now use version: $selected_version"
+ echo "R terminal will now use version: $selected_version"
+}