Skip to content

Commit

Permalink
Make rye install as the remoteUser
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirks committed Aug 16, 2024
1 parent e85e1d2 commit 32768f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/rye/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 13 additions & 1 deletion src/rye/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 32768f3

Please sign in to comment.