jupyter_core icon indicating copy to clipboard operation
jupyter_core copied to clipboard

jupyter nbextension enable --sys-prefix tries to write in $HOME/.jupyter

Open jdemeyer opened this issue 8 years ago • 5 comments

When executing the command

jupyter nbextension enable --sys-prefix --py widgetsnbextension

I would expect this to only touch system files in sys.prefix. However, this actually tries to create the directory $HOME/.jupyter.

Traceback (most recent call last) when executing the above command as locked-down user with limited access to $HOME:

  File "/home/worker/sage-patchbot/local/bin/jupyter-nbextension", line 6, in <module>
    main()
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-6>", line 2, in initialize
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/application.py", line 239, in initialize
    self.parse_command_line(argv)
  File "<decorator-gen-4>", line 2, in parse_command_line
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 488, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<decorator-gen-3>", line 2, in initialize_subcommand
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 426, in initialize_subcommand
    self.subapp.initialize(argv)
  File "<decorator-gen-6>", line 2, in initialize
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/application.py", line 243, in initialize
    self.migrate_config()
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/application.py", line 169, in migrate_config
    migrate()
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/migrate.py", line 240, in migrate
    ensure_dir_exists(env['jupyter_config'])
  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/home/worker/sage-patchbot/local/lib/python/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/worker/.jupyter'

CC @SylvainCorlay

jdemeyer avatar Sep 02 '16 15:09 jdemeyer

  • enabling the extension with --sys-prefix should require the same privileges as the pip install.
  • indeed it should create a directory in sys.prefix
  • if your sys-prefix is a subdirectory of home, these should not require sudo privileges

I don't know what is going on here. What is the os exactly?

SylvainCorlay avatar Sep 02 '16 15:09 SylvainCorlay

indeed it should create a directory in sys.prefix

Which it does correctly. However, it additionally does something in $HOME.

if your sys-prefix is a subdirectory of home, these should not require sudo privileges

sys.prefix is not inside $HOME in this case. This issue is for the situation where I have access to sys.prefix but not to $HOME. You could correctly argue that this is an unusual situation. Still, when installing stuff as root I don't want Jupyter to create /root/.jupyter.

What is the os exactly?

Linux sage4 3.2.1-gentoo-r2 #15 SMP Tue May 15 10:40:50 CEST 2012 x86_64 Intel(R) Xeon(R) CPU X5660 @ 2.80GHz GenuineIntel GNU/Linux

jdemeyer avatar Sep 02 '16 15:09 jdemeyer

  File "/home/worker/sage-patchbot/local/lib/python2.7/site-packages/jupyter_core/application.py", line 243, in initialize
    self.migrate_config()

It's the base Jupyter application trying to migrate IPython config to Jupyter. It will skip this if either:

  1. ~/.jupyter/migrated exists, or
  2. ~/.ipython does not exist

You could also set JUPYTER_CONFIG_DIR to a writeable scratch directory to have it operate there instead.

takluyver avatar Sep 02 '16 15:09 takluyver

It will skip this if either:

~/.ipython does not exist

No, it does not. In my case, $HOME/.ipython does not exist. In fact, $HOME is almost empty (containing a hand-picked minimal set of things that I need).

jdemeyer avatar Sep 02 '16 16:09 jdemeyer

But since I am guessing you are talking about a sagemath install you may have ~/.sage/ipython and the variable IPYTHONDIR points there in your environment.

kiwifb avatar Sep 02 '16 20:09 kiwifb

closing this due to inactivity, Happy hacking! :bowtie:

ivanov avatar Nov 17 '23 03:11 ivanov