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

Environment of a new notebook #1001

Open
yha opened this issue Apr 19, 2021 · 4 comments
Open

Environment of a new notebook #1001

yha opened this issue Apr 19, 2021 · 4 comments

Comments

@yha
Copy link

yha commented Apr 19, 2021

It seems like creating a new notebook (File->New Notebook) starts it in the same environment as the last open notebook. I'm not sure if this is deliberate, but I find it a bit surprising & confusing (especially since there is no visual indication of the environment in the interface).
I would expect a new notebook to be in the default environment, or perhaps in the same environment that notebook() was called from.
ref #820

@twavv
Copy link
Contributor

twavv commented Apr 19, 2021

IJulia starts notebooks in the environment of the directory where the project and manifest files are (or if they don't exist, in the default environment).

If you have two notebooks in the same directory, they will use the same environment. To circumvent this, just use multiple directories (you have to anyway to create different project and manifest files).

@yha
Copy link
Author

yha commented Apr 19, 2021

IJulia starts notebooks in the environment of the directory where the project and manifest files are

I'm not sure what that means. Which project and manifest files?
My understanding is that if you open an existing notebook, it looks in its directory (where the notebook file is) and its superdirectories, which is fine.
My issue is with new notebooks that were not saved yet (so there is no notebook file). These seem to use the directory/environment of whatever notebook was last open, as far as I can tell.

@twavv
Copy link
Contributor

twavv commented Apr 19, 2021

I think that was a typo -- I think I meant to say

Julia starts notebooks in the environment of the directory where the notebook is (or if the project and manifest files don't exist, in the default environment).

Sorry for that.

My issue is with new notebooks that were not saved yet (so there is no notebook file). These seem to use the directory/environment of whatever notebook was last open, as far as I can tell.

This is probably a JupyterLab behavior. The notebook files always exist (as far as I know) even if you haven't saved them yet (e.g., creating a new notebook will create a file on disk called "Untitled.ipynb" or whatever).

At the end of the day, IJulia is actually not even aware of the notebook files. From IJulia's (and IPython, IRKernel, etc.) perspective, it is started in a particular working directory and then just runs a server that speaks the Jupyter protocol in order to execute code (and the Jupyter protocol is just a fancy REPL - it has no idea about your notebook files).

If creating a new notebook starts it in the same directory as the previous notebook, that's just because Jupyter is spawning the Julia process in that directory. If that's the case, then this would be an upstream issue (with Jupyter Notebook or Jupyter Lab).

@thompsonmj
Copy link

When opening a new notebook with jupyterlab() or notebook(), the Untitled.ipynb file is opened in my home directory rather than in the directory from which the command was given (also where I have a Project.toml and Manifest.toml file which reference IJulia).

At the end of the day, IJulia is actually not even aware of the notebook files. From IJulia's (and IPython, IRKernel, etc.) perspective, it is started in a particular working directory and then just runs a server that speaks the Jupyter protocol in order to execute code (and the Jupyter protocol is just a fancy REPL - it has no idea about your notebook files).

This is still confusing because when running jupyter lab from e.g. an Anaconda prompt, the notebook is opened by Jupyter Lab with the root directory starting in the directory from which the command was issued. Calling the IJulia command juypterlab() should tell Jupyter where it's being called from so Jupyter can open a new notebook in that location.

A better default action would be equivalent to running:
jupyterlab(dir=".") or notebook(dir=".")

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

No branches or pull requests

3 participants