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

uncaught error in directory ownership check #334

Closed
edavidaja opened this issue Jan 19, 2023 · 2 comments · Fixed by #335
Closed

uncaught error in directory ownership check #334

edavidaja opened this issue Jan 19, 2023 · 2 comments · Fixed by #335
Labels

Comments

@edavidaja
Copy link

edavidaja commented Jan 19, 2023

If Jupyter content is executed in a container image where there is no guarantee that the UID of the executing user will be mapped in /etc/passwd, a KeyError that is not caught will be raised by p.owner :

2023/01/17 18:02:24.481533600   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_core/paths.py", line 82, in _do_i_own
2023/01/17 18:02:24.481543233     return p.owner() == os.getlogin()
2023/01/17 18:02:24.481566456   File "/opt/python/3.10.4/lib/python3.10/pathlib.py", line 1101, in owner
2023/01/17 18:02:24.481568740     return self._accessor.owner(self)
2023/01/17 18:02:24.481576809   File "/opt/python/3.10.4/lib/python3.10/pathlib.py", line 343, in owner
2023/01/17 18:02:24.481577833     return pwd.getpwuid(self.stat(path).st_uid).pw_name
2023/01/17 18:02:24.481594757 KeyError: 'getpwuid(): uid not found: 999'
2023/01/17 18:02:22.875059195 Creating kernel spec: python3
2023/01/17 18:02:24.481240664 Traceback (most recent call last):
2023/01/17 18:02:24.481256953   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/traitlets/traitlets.py", line 656, in get
2023/01/17 18:02:24.481304225     value = obj._trait_values[self.name]
2023/01/17 18:02:24.481305903 KeyError: 'kernel_dirs'
2023/01/17 18:02:24.481318923 
2023/01/17 18:02:24.481321030 During handling of the above exception, another exception occurred:
2023/01/17 18:02:24.481335566 
2023/01/17 18:02:24.481336717 Traceback (most recent call last):
2023/01/17 18:02:24.481346126   File "/opt/python/3.10.4/lib/python3.10/runpy.py", line 196, in _run_module_as_main
2023/01/17 18:02:24.481348053     return _run_code(code, main_globals, None,
2023/01/17 18:02:24.481356437   File "/opt/python/3.10.4/lib/python3.10/runpy.py", line 86, in _run_code
2023/01/17 18:02:24.481357206     exec(code, run_globals)
2023/01/17 18:02:24.481366608   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/ipykernel/__main__.py", line 5, in <module>
2023/01/17 18:02:24.481367576     app.launch_new_instance()
2023/01/17 18:02:24.481376613   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/traitlets/config/application.py", line 1041, in launch_instance
2023/01/17 18:02:24.481378866     app.start()
2023/01/17 18:02:24.481390458   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 708, in start
2023/01/17 18:02:24.481391271     return self.subapp.start()
2023/01/17 18:02:24.481400293   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/ipykernel/kernelspec.py", line 232, in start
2023/01/17 18:02:24.481401365     dest = install(
2023/01/17 18:02:24.481409086   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/ipykernel/kernelspec.py", line 152, in install
2023/01/17 18:02:24.481409880     dest = kernel_spec_manager.install_kernel_spec(
2023/01/17 18:02:24.481419040   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_client/kernelspec.py", line 397, in install_kernel_spec
2023/01/17 18:02:24.481420001     if kernel_dir not in self.kernel_dirs:
2023/01/17 18:02:24.481429041   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/traitlets/traitlets.py", line 703, in __get__
2023/01/17 18:02:24.481430015     return self.get(obj, cls)
2023/01/17 18:02:24.481437625   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/traitlets/traitlets.py", line 659, in get
2023/01/17 18:02:24.481438454     default = obj.trait_defaults(self.name)
2023/01/17 18:02:24.481446305   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/traitlets/traitlets.py", line 1872, in trait_defaults
2023/01/17 18:02:24.481447059     return self._get_trait_default_generator(names[0])(self)
2023/01/17 18:02:24.481455345   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_client/kernelspec.py", line 198, in _kernel_dirs_default
2023/01/17 18:02:24.481456009     dirs = jupyter_path("kernels")
2023/01/17 18:02:24.481474309   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_core/paths.py", line 276, in jupyter_path
2023/01/17 18:02:24.481475197     if prefer_environment_over_user():
2023/01/17 18:02:24.481490154   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_core/paths.py", line 105, in prefer_environment_over_user
2023/01/17 18:02:24.481491080     if sys.prefix != sys.base_prefix and _do_i_own(sys.prefix):
2023/01/17 18:02:24.481533600   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.10/site-packages/jupyter_core/paths.py", line 82, in _do_i_own
2023/01/17 18:02:24.481543233     return p.owner() == os.getlogin()
2023/01/17 18:02:24.481566456   File "/opt/python/3.10.4/lib/python3.10/pathlib.py", line 1101, in owner
2023/01/17 18:02:24.481568740     return self._accessor.owner(self)
2023/01/17 18:02:24.481576809   File "/opt/python/3.10.4/lib/python3.10/pathlib.py", line 343, in owner
2023/01/17 18:02:24.481577833     return pwd.getpwuid(self.stat(path).st_uid).pw_name
2023/01/17 18:02:24.481594757 KeyError: 'getpwuid(): uid not found: 999'
2023/01/17 18:03:16.986492009 ipykernel install failed with exit code 1

It appears as though this behavior was introduced in #323

@blink1073
Copy link
Contributor

cc @minrk

@minrk
Copy link
Member

minrk commented Jan 23, 2023

Sorry! #335 should catch any error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants