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"