Repository: conda/conda

Issue:
Misfeature with non-installed ipython
**I'm submitting a...**
  - [X] bug report
  - [ ] feature request


## Current Behavior

In an environment that does not have `ipython` installed, the base version of `ipython` is still available.  However, this runs in the base environment, and does not see packages specific to the local environment.  This has bitten me **many** times by wasting time figuring out why an import isn't working (or why the package doesn't match the API of the version in the current environment, but rather of the version in the base environment).

### Steps to Reproduce

```
% conda create -n no-ipython humidity -c davidmertz -y  # Silly example package
[... creating ...]
% conda activate no-ipython
(no-ipython) % ipython
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import humidity
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5cdf29aced62> in <module>()
----> 1 import humidity
ModuleNotFoundError: No module named 'humidity'
In [2]:
Do you really want to exit ([y]/n)? y
(no-ipython) % which ipython
/Users/dmertz/anaconda3/bin/ipython
(no-ipython) % conda install ipython -y
[... installing ...]
(no-ipython) % which ipython
/Users/dmertz/anaconda3/envs/no-ipython/bin/ipython
(no-ipython) % ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import humidity
In [2]:
```


## Expected Behavior

```
(no-ipython) % ipython  # When ipython is not installed in the environment
-bash: ipython: command not found
```

## Environment Information

As created in sample code... or any other environment without ipython installed.



Discussion:
You can do

    conda config --set max_shlvl 1

The default value in conda 4.4 is `2` for `max_shlvl` because it emulates what had effectively been the behavior in conda 4.3 and below, where the base environment is put on `PATH` by manually setting e.g. `export PATH="/opt/conda/bin:$PATH"` rather than `source /opt/conda/bin/activate root`.  After that, `source activate` would add one additional environment on top of the base environment, but not more.  That behavior was preserved in conda 4.4.
`max_shlvl=1` could under certain situations (i.e. cmd.exe shell) run into issues until we have https://github.com/conda/conda/issues/6810
I guess this is more of a "mis-feature" than a bug per se.  Thanks for the info on how I can fix it for myself.  But I'm sure I'm not the only person to encounter this.

I wonder if there's any way we could make a warning be emitted when users run a tool (but especially `ipython`) in a path in a non-local environment.  I know the tool itself is just on the path, but it feels like some bash magic might be possible... something along the lines of creating an "emulated root" that spat out something to STDERR when it was accessed.

Of course, I can see immediately that this is tricky.  For standalone executables that don't themselves provide environment-specific shells the warning would be distracting.  But even then, it's *possible* I actually mean to be using a different version of e.g. `curl` or `dot` (tools that have nothing to do with Python that are conda packages, but whose behavior might change subtly between versions), but missed that I'm actually running the "non-local" version.

The intermediate situation is with `my_command_util.py` that doesn't interpret arbitrary Python statements, but *is* written in Python with imports of modules with different versions.  My initial expectation would still be that I would import the "local environment" version, but that might be wrong if I forgot to include `my_command_util` in my `environment.yml` or my `conda create` line.
Actually, I *cannot* do what you suggest:

```bash
% conda --version; conda config --set max_shlvl 1
conda 4.4.10

CondaValueError: Key 'max_shlvl' is not a known primitive parameter.
```

Is there a typo in your command or something?
Ohhh maybe I never documented that parameter.  Which means you can't use `conda config --set` with it.  That's for sure a bug.

Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -587,7 +587,6 @@ def list_parameters(self):
             'error_upload_url',  # should remain undocumented
             'force_32bit',
             'ignore_pinned',
-            'max_shlvl',
             'migrated_custom_channels',
             'only_dependencies',
             'prune',
@@ -773,6 +772,9 @@ def get_help_dict():
             header. Any other positive integer values is the number of seconds to locally
             cache repodata before checking the remote server for an update.
             """),
+        'max_shlvl': dals("""
+            The maximum number of stacked active conda environments.
+            """),
         'migrated_channel_aliases': dals("""
             A list of previously-used channel_alias values, useful for example when switching
             between different Anaconda Repository instances.


Test patch: