Skip to content

Commit 8e8e14f

Browse files
authored
Codespace unable to start in Jupyter using python feature with option "installJupyterLab": true (#1199)
* Add path for JupyterLab * Remove unwanted code
1 parent f8e7e27 commit 8e8e14f

File tree

6 files changed

+15
-41
lines changed

6 files changed

+15
-41
lines changed

src/python/devcontainer-feature.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "1.6.5",
3+
"version": "1.7.0",
44
"name": "Python",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
66
"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 @@
6767
"PYTHON_PATH": "/usr/local/python/current",
6868
"PIPX_HOME": "/usr/local/py-utils",
6969
"PIPX_BIN_DIR": "/usr/local/py-utils/bin",
70-
"PATH": "/usr/local/python/current/bin:/usr/local/py-utils/bin:${PATH}"
70+
"PATH": "/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/jupyter:${PATH}"
7171
},
7272
"customizations": {
7373
"vscode": {
@@ -78,14 +78,14 @@
7878
],
7979
"settings": {
8080
"python.defaultInterpreterPath": "/usr/local/python/current/bin/python",
81-
"[python]": {
82-
"editor.defaultFormatter": "ms-python.autopep8"
83-
}
81+
"[python]": {
82+
"editor.defaultFormatter": "ms-python.autopep8"
83+
}
8484
}
8585
}
8686
},
8787
"installsAfter": [
8888
"ghcr.io/devcontainers/features/common-utils",
8989
"ghcr.io/devcontainers/features/oryx"
9090
]
91-
}
91+
}

src/python/install.sh

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -912,21 +912,15 @@ if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then
912912
install_user_package $INSTALL_UNDER_ROOT jupyterlab
913913
install_user_package $INSTALL_UNDER_ROOT jupyterlab-git
914914

915+
# Create a symlink to the JupyterLab binary for non root users
915916
if [ "$INSTALL_UNDER_ROOT" = false ]; then
916-
# JupyterLab would have installed into /home/${USERNAME}/.local/bin
917-
# Adding it to default path for Codespaces which use non-login shells
918-
SUDOERS_FILE="/etc/sudoers.d/$USERNAME"
919-
SEARCH_STR="Defaults secure_path="
920-
REPLACE_STR="Defaults secure_path=/home/${USERNAME}/.local/bin"
921-
922-
if grep -qs ${SEARCH_STR} ${SUDOERS_FILE}; then
923-
# string found and file is present
924-
sed -i "s|${SEARCH_STR}|${REPLACE_STR}:|g" "${SUDOERS_FILE}"
925-
else
926-
# either string is not found, or file is not present
927-
# In either case take same action, note >> places at end of file
928-
echo "${REPLACE_STR}:${PATH}" >> ${SUDOERS_FILE}
917+
JUPYTER_INPATH=/home/${USERNAME}/.local/bin
918+
if [ ! -d "$JUPYTER_INPATH" ]; then
919+
echo "Error: $JUPYTER_INPATH does not exist."
920+
exit 1
929921
fi
922+
JUPYTER_PATH=/usr/local/jupyter
923+
ln -s "$JUPYTER_INPATH" "$JUPYTER_PATH"
930924
fi
931925

932926
# Configure JupyterLab if needed

test/python/install_jupyterlab.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ check "jupyterlab_git" grep jupyterlab_git <<< "$packages"
2222
# Check for correct JupyterLab configuration
2323
check "config" grep ".*.allow_origin = '*'" /home/vscode/.jupyter/jupyter_server_config.py
2424

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

2828
# Report result
2929
reportResults

test/python/install_jupyterlab_existing_sudoers_file/Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/python/install_jupyterlab_existing_sudoers_file/sudoers.test

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/python/scenarios.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@
6868
}
6969
}
7070
},
71-
"install_jupyterlab_existing_sudoers_file": {
72-
"build": {
73-
"dockerfile": "Dockerfile"
74-
},
75-
"remoteUser": "vscode",
76-
"features": {
77-
"python": {
78-
"version": "latest",
79-
"installJupyterlab": true,
80-
"configureJupyterlabAllowOrigin": "*"
81-
}
82-
}
83-
},
8471
"install_jupyterlab_rhel_family": {
8572
"image": "almalinux:8",
8673
"remoteUser": "vscode",

0 commit comments

Comments
 (0)