-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
[MRG] Don't use shellEnv when launched from terminal #1906
Conversation
|
display_name: "python (nteract)", | ||
language: "python", | ||
env: { | ||
ELECTRON_RUN_AS_NODE: "1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You won't need this here since this was just something we passed through to enable our embedded JS kernel.
spec: { | ||
argv: ["python", "-m", "ipykernel_launcher", "-f", "{connection_file}"], | ||
display_name: "python (nteract)", | ||
language: "python", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need this to get merged successfully in with the user's default python if they happen to be the same path as you'll want the notebook to point to the right kernelspec in the document (here it would identify as python_nteract
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checking: You mean we should set the language to something else aka python_nteract
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to say that if this kernelspec is exactly the same as their python
kernelspec (by name -- folder on disk, key in the overall kernelspecs object here).
However, I'm thinking that naming it by env and only populating it when we know we're launched from the terminal may be a better approach (see below).
Sounds about right. |
For a random user with a standalone install on a mac who is using anaconda, their flow might end up looking like this:
I'm not actually sure so I think this could be destructive at the moment. I think there's a decent way to do this that is going to involve checking some environment variables as well as seeing which version of ipython is installed (I did some of this in a branch I closed a while ago). However... I think there's a way to do this for today in a way that makes the Special case CLI launchesWhen the nteract app is started from the CLI, set a special environment variable that says Generally that would make me a little more comfortable for one of these semi-generated kernelspecs. |
Wouldn't checking for |
👍
Combine these two questions/statements and this is why I'm suggesting you set a var to communicate the intent of launching from the CLI. You can make the "Python (current env)" spec use whatever Python is on the path here. |
|
I'm going to add some notes to that file to state why we're doing certain things before they're lost to time. 😛 |
Damn it, I just committed straight to master in the GitHub UI instead of making a PR like I meant to for the the comments on the env prep. See the updated version here: https://github.com/nteract/nteract/blob/d84fcc3d2ac3b16987ba3b6548fdeda76feda91d/packages/desktop/src/main/prepare-env.js |
Some notes to (mainly) self: when launching the app by double click
This is also what I get if I start a new terminal. So far so good. Start from terminal, shellEnv gives me:
this somehow duplicates stuff. As a result the conda env path is towards the back and get's shadowed by the So I (currently) think that all that needs to happen is to not use shellEnv when we detect that nteract was started from a terminal. If I by hand comment out the relevant bit in |
Checking if The detection works for me on Mac. 🎉 |
Codecov Report
@@ Coverage Diff @@
## master #1906 +/- ##
=======================================
Coverage 79.62% 79.62%
=======================================
Files 116 116
Lines 4859 4859
=======================================
Hits 3869 3869
Misses 990 990 |
I think |
@@ -10,7 +10,9 @@ import "rxjs/add/operator/publishReplay"; | |||
const env$ = Observable.fromPromise(shellEnv()) | |||
.first() | |||
.do(env => { | |||
Object.assign(process.env, env); | |||
if (!process.env.TERM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with merging this if it's working on your mac if you make the conditional process.platform !== 'darwin' || !process.env.TERM
(or you can DeMorgan's Law this and do !(process.platform === 'darwin' && process.env.TERM)
)
If nteract was launched from a terminal there is no need to use shellEnv.
52af39c
to
7e6cd75
Compare
Waiting for travis, then good to go. |
I got the following three values for launch with and when double clicking The last two cases are the ones we'd want to tell apart, so sad panda. |
@@ -10,7 +10,10 @@ import "rxjs/add/operator/publishReplay"; | |||
const env$ = Observable.fromPromise(shellEnv()) | |||
.first() | |||
.do(env => { | |||
Object.assign(process.env, env); | |||
// no need to change the env if started from the terminal on Mac | |||
if (process.platform !== "darwin" || !process.env.TERM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks for tackling this and going back+forth on it Tim to find the simplest way to solve this. |
Years of physics training make me be unhappy if the solution is too complex :p |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
Related to #620
This is pretty hacky but does mean you get a kernel that corresponds to the conda environment in which you typed
npm run start
. There are two things that puzzle me:the
process.env
print out I inserted shows various custom env variables I set in my terminal, as well asCONDA_blah
variables that belong to the current conda env, but it shows a different PATH. So it seems to inherit some variables but does something special to PATH. Any ideas where that is happening?only seems to work with
ipykernel~=4.6.x
, at least in some of my envs where the version is 4.3.x executing a cell never completes. Just seems to hang and I can't find an error message anywhere.If we can track down when/where PATH gets modified maybe we can prevent it from removing (or re-add) the path for the current conda environment. Maybe the real way to do this is to add a kernel spec like this if we detect that we are in either a virtualenv or a conda env and do "the right thing" for either to work.
WDYT?