From 32768f392c27a9477ec4eed4582bbbb8bf0b25c9 Mon Sep 17 00:00:00 2001 From: David Birks Date: Fri, 16 Aug 2024 07:17:38 -0400 Subject: [PATCH] Make rye install as the remoteUser --- src/rye/devcontainer-feature.json | 5 +---- src/rye/install.sh | 14 +++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/rye/devcontainer-feature.json b/src/rye/devcontainer-feature.json index 71abd31..12b5fa4 100644 --- a/src/rye/devcontainer-feature.json +++ b/src/rye/devcontainer-feature.json @@ -1,17 +1,14 @@ { "name": "Rye", - "version": "1.2.1", + "version": "1.3.0", "id": "rye", "description": "A Hassle-Free Python Experience", "installsAfter": [ "ghcr.io/devcontainers/features/python" ], "containerEnv": { - "PATH": "/usr/local/lib/rye/shims:${PATH}", - "RYE_HOME": "/usr/local/lib/rye", "RYE_NO_AUTO_INSTALL": "1" }, - "postCreateCommand": "echo 'source \"$HOME/.rye/env\"' >> ~/.profile", "options": { "bashCompletion": { "type": "boolean", diff --git a/src/rye/install.sh b/src/rye/install.sh index f0f273c..0cde3c7 100644 --- a/src/rye/install.sh +++ b/src/rye/install.sh @@ -5,13 +5,25 @@ set -o errexit echo "Activating feature 'rye'" +# https://containers.dev/guide/feature-authoring-best-practices#detect-the-non-root-user +echo "Running the rye install script as the non-root user: $_REMOTE_USER" +su - $_REMOTE_USER << 'EOF' + # https://rye.astral.sh/guide/installation/#customized-installation curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash +echo "Adding 'rye' to the PATH for the non-root user" +echo 'source "$HOME/.rye/env"' >> ~/.bashrc + +EOF + +echo "Adding 'rye' to the PATH for the root user" +echo 'source "/home/$_REMOTE_USER/.rye/env"' >> ~/.bashrc + if [ "$BASHCOMPLETION" = "true" ]; then echo "Activating bash completion for 'rye'" # https://rye.astral.sh/guide/installation/#shell-completion - rye self completion > /etc/bash_completion.d/rye + /home/$_REMOTE_USER/.rye/shims/rye self completion >/etc/bash_completion.d/rye else echo "Skipping setting up bash completion for 'rye'" echo "The value of BASHCOMPLETION is: $BASHCOMPLETION"