Unverified Commit 8e8e14f6 authored by Mathiyarasy's avatar Mathiyarasy Committed by GitHub

Codespace unable to start in Jupyter using python feature with option...

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

* Add path for JupyterLab

* Remove unwanted code
parent f8e7e275
{
"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.",
......@@ -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": {
......@@ -78,9 +78,9 @@
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/python/current/bin/python",
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}
}
}
},
......@@ -88,4 +88,4 @@
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/oryx"
]
}
}
\ No newline at end of file
......@@ -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
......
......@@ -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
# Builds an image with a preconfigured SUDOERS file
# Used to test the install script for JupyterLab which modifies this file
FROM mcr.microsoft.com/devcontainers/base:focal
COPY --chown=root sudoers.test /etc/sudoers.d/vscode
# Sudoers File for testing, after install script runs the Defaults secure_path should be appended to
Defaults secure_path=/original_content_of_sudoers_file
\ No newline at end of file
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment