Closed ateucher closed 5 months ago
I've been trying out the quarto extension with a locally built image with these changes. It wants to write to $HOME/.cache/
, but it belongs to root? In the hub however, ~/.cache
belongs to jovyan (which I assume is how it should be). I don't see how these changes would cause that... any ideas @betolink?
I just ran the image built from main, and it also has ~/.cache
owned by root... that must be fixed when it's deployed. So maybe that's not an issue here...
@ateucher Thanks for your help today! For your reference here is my final script. Has some extra error checking.
#!/bin/bash
# Required User: NB_USER
# Install VSCode extensions.
# These get installed to $CONDA_PREFIX/envs/notebook/share/code-server/extensions/
# Check if a filename argument is provided
if [ -z "$1" ]; then
echo "Error: install-vscode-extensions.sh requires an input file of extension names (typically called vscode-extensions.txt)." >&2
echo "Usage: RUN /pyrocket_scripts/install-vscode-extensions.sh <filename>"
exit 1
fi
# Check if running as root and switch to NB_USER if needed
if [[ $(id -u) -eq 0 ]]; then
echo "Switching to ${NB_USER} to run install-vscode-extensions.sh"
exec su "${NB_USER}" -c "/bin/bash $0 $1" # Pass along the filename argument
fi
echo "Running install-vscode-extensions.sh as ${NB_USER}"
ext_file="$1"
# Verify that ext_file exists and is a file
if [ ! -f "${ext_file}" ]; then
echo " Error: Specified file '$ext_file' does not exist."
exit 1
fi
# Install each extension listed in the file
while IFS= read -r EXT; do
if code-server --install-extension "$EXT"; then
echo " Successfully installed extension: $EXT"
else
echo " Failed to install extension: $EXT" >&2
fi
done < "$ext_file"
echo " Success! install-vscode-extensions.sh"
Initially we assumed that extensions would be default be installed in
$HOME
, which we wanted to avoid (#30, #31). But it turns out thatcode-server
from conda-forge sets the--extensions-dir
flag to${CONDA_PREFIX}/share/code-server/extensions
, which resolves to/srv/conda/envs/notebook/share/code-server/extensions
- i.e., outside of$HOME
. So I don't think we need to configure anything; we should just be able to install the extensions we want in the Dockerfile.I tested this locally (macOS arm), and it worked:
I had to remove the
postBuild
, as the awsv2 install was failing (on macOS).