Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codespace unable to start in Jupyter using python feature with option "installJupyterLab": true #1199

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/python/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "python",
"version": "1.6.5",
"version": "1.7.0",
"name": "Python",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
"description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.",
Expand Down Expand Up @@ -67,7 +67,7 @@
"PYTHON_PATH": "/usr/local/python/current",
"PIPX_HOME": "/usr/local/py-utils",
"PIPX_BIN_DIR": "/usr/local/py-utils/bin",
"PATH": "/usr/local/python/current/bin:/usr/local/py-utils/bin:${PATH}"
"PATH": "/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/jupyter:${PATH}"
},
"customizations": {
"vscode": {
Expand All @@ -78,14 +78,14 @@
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/python/current/bin/python",
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}
}
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/oryx"
]
}
}
20 changes: 7 additions & 13 deletions src/python/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -912,21 +912,15 @@ if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then
install_user_package $INSTALL_UNDER_ROOT jupyterlab
install_user_package $INSTALL_UNDER_ROOT jupyterlab-git

# Create a symlink to the JupyterLab binary for non root users
if [ "$INSTALL_UNDER_ROOT" = false ]; then
# JupyterLab would have installed into /home/${USERNAME}/.local/bin
# Adding it to default path for Codespaces which use non-login shells
SUDOERS_FILE="/etc/sudoers.d/$USERNAME"
SEARCH_STR="Defaults secure_path="
REPLACE_STR="Defaults secure_path=/home/${USERNAME}/.local/bin"

if grep -qs ${SEARCH_STR} ${SUDOERS_FILE}; then
# string found and file is present
sed -i "s|${SEARCH_STR}|${REPLACE_STR}:|g" "${SUDOERS_FILE}"
else
# either string is not found, or file is not present
# In either case take same action, note >> places at end of file
echo "${REPLACE_STR}:${PATH}" >> ${SUDOERS_FILE}
JUPYTER_INPATH=/home/${USERNAME}/.local/bin
if [ ! -d "$JUPYTER_INPATH" ]; then
echo "Error: $JUPYTER_INPATH does not exist."
exit 1
fi
JUPYTER_PATH=/usr/local/jupyter
ln -s "$JUPYTER_INPATH" "$JUPYTER_PATH"
fi

# Configure JupyterLab if needed
Expand Down
4 changes: 2 additions & 2 deletions test/python/install_jupyterlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ check "jupyterlab_git" grep jupyterlab_git <<< "$packages"
# Check for correct JupyterLab configuration
check "config" grep ".*.allow_origin = '*'" /home/vscode/.jupyter/jupyter_server_config.py

# Check for PATH modification
check "default path has jupyterlab" sudo grep "/home/${user}/.local/bin" /etc/sudoers.d/$user
#check "default path has jupyterlab symlink"
check "default path has jupyterlab" test -L "/usr/local/jupyter"

# Report result
reportResults

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions test/python/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@
}
}
},
"install_jupyterlab_existing_sudoers_file": {
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "vscode",
"features": {
"python": {
"version": "latest",
"installJupyterlab": true,
"configureJupyterlabAllowOrigin": "*"
}
}
},
"install_jupyterlab_rhel_family": {
"image": "almalinux:8",
"remoteUser": "vscode",
Expand Down
Loading