Repository: conda/conda

Issue:
Add a warning when creating environments with spaces
From https://github.com/ContinuumIO/navigator/issues/1000.

```
(root) 0316-gpena-castellanos:navigator gpena-castellanos$ conda install -n "test space" qtconsole
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /Users/gpena-castellanos/anaconda/envs/test space:

The following NEW packages will be INSTALLED:

    appnope:          0.1.0-py36_0 
    decorator:        4.0.11-py36_0
    icu:              54.1-0       
    ipykernel:        4.5.2-py36_0 
    ipython:          5.3.0-py36_0 
    ipython_genutils: 0.1.0-py36_0 
    jupyter_client:   5.0.0-py36_0 
    jupyter_core:     4.3.0-py36_0 
    path.py:          10.1-py36_0  
    pexpect:          4.2.1-py36_0 
    pickleshare:      0.7.4-py36_0 
    prompt_toolkit:   1.0.13-py36_0
    ptyprocess:       0.5.1-py36_0 
    pygments:         2.2.0-py36_0 
    pyqt:             5.6.0-py36_2 
    python-dateutil:  2.6.0-py36_0 
    pyzmq:            16.0.2-py36_0
    qt:               5.6.2-0      
    qtconsole:        4.2.1-py36_1 
    simplegeneric:    0.8.1-py36_1 
    sip:              4.18-py36_0  
    six:              1.10.0-py36_0
    tornado:          4.4.2-py36_0 
    traitlets:        4.3.2-py36_0 
    wcwidth:          0.1.7-py36_0 

Proceed ([y]/n)? y

ERROR conda.core.link:_execute_actions(335): An error occurred while installing package 'defaults::qt-5.6.2-0'.
LinkError: post-link script failed for package defaults::qt-5.6.2-0
running your command again with `-v` will provide additional information
location of failed script: /Users/gpena-castellanos/anaconda/envs/test space/bin/.qt-post-link.sh
==> script messages <==
<None>


Attempting to roll back.



LinkError: post-link script failed for package defaults::qt-5.6.2-0
running your command again with `-v` will provide additional information
location of failed script: /Users/gpena-castellanos/anaconda/envs/test space/bin/.qt-post-link.sh
==> script messages <==
<None>
```

A warning with something like this to point the cause of the problem for the user to fix:
"Warning: Conda environments with spaces are not supported"

Add a warning when creating environments with spaces
From https://github.com/ContinuumIO/navigator/issues/1000.

```
(root) 0316-gpena-castellanos:navigator gpena-castellanos$ conda install -n "test space" qtconsole
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /Users/gpena-castellanos/anaconda/envs/test space:

The following NEW packages will be INSTALLED:

    appnope:          0.1.0-py36_0 
    decorator:        4.0.11-py36_0
    icu:              54.1-0       
    ipykernel:        4.5.2-py36_0 
    ipython:          5.3.0-py36_0 
    ipython_genutils: 0.1.0-py36_0 
    jupyter_client:   5.0.0-py36_0 
    jupyter_core:     4.3.0-py36_0 
    path.py:          10.1-py36_0  
    pexpect:          4.2.1-py36_0 
    pickleshare:      0.7.4-py36_0 
    prompt_toolkit:   1.0.13-py36_0
    ptyprocess:       0.5.1-py36_0 
    pygments:         2.2.0-py36_0 
    pyqt:             5.6.0-py36_2 
    python-dateutil:  2.6.0-py36_0 
    pyzmq:            16.0.2-py36_0
    qt:               5.6.2-0      
    qtconsole:        4.2.1-py36_1 
    simplegeneric:    0.8.1-py36_1 
    sip:              4.18-py36_0  
    six:              1.10.0-py36_0
    tornado:          4.4.2-py36_0 
    traitlets:        4.3.2-py36_0 
    wcwidth:          0.1.7-py36_0 

Proceed ([y]/n)? y

ERROR conda.core.link:_execute_actions(335): An error occurred while installing package 'defaults::qt-5.6.2-0'.
LinkError: post-link script failed for package defaults::qt-5.6.2-0
running your command again with `-v` will provide additional information
location of failed script: /Users/gpena-castellanos/anaconda/envs/test space/bin/.qt-post-link.sh
==> script messages <==
<None>


Attempting to roll back.



LinkError: post-link script failed for package defaults::qt-5.6.2-0
running your command again with `-v` will provide additional information
location of failed script: /Users/gpena-castellanos/anaconda/envs/test space/bin/.qt-post-link.sh
==> script messages <==
<None>
```

A warning with something like this to point the cause of the problem for the user to fix:
"Warning: Conda environments with spaces are not supported"



Discussion:
Shouldn't the package's post link script quote the `$PREFIX` variable properly, instead of assuming that the environment path will not have a space in it?
Yes it should and I will fix that today but we should also warn since a large amount of critical software (e.g. GNU make) cannot handle spaces very well.
Shouldn't the package's post link script quote the `$PREFIX` variable properly, instead of assuming that the environment path will not have a space in it?
Yes it should and I will fix that today but we should also warn since a large amount of critical software (e.g. GNU make) cannot handle spaces very well.

Resolving patch:
diff --git a/conda/cli/install.py b/conda/cli/install.py
--- a/conda/cli/install.py
+++ b/conda/cli/install.py
@@ -8,7 +8,7 @@
 
 from difflib import get_close_matches
 import errno
-import logging
+from logging import getLogger
 import os
 from os.path import abspath, basename, exists, isdir, join
 import re
@@ -29,7 +29,8 @@
 from ..plan import (display_actions, execute_actions, get_pinned_specs, install_actions_list,
                     is_root_prefix, nothing_to_do, revert_actions)
 
-log = logging.getLogger(__name__)
+log = getLogger(__name__)
+stderr = getLogger('stderr')
 
 
 def check_prefix(prefix, json=False):
@@ -47,6 +48,11 @@ def check_prefix(prefix, json=False):
     if error:
         raise CondaValueError(error, json)
 
+    if ' ' in prefix:
+        stderr.warn("WARNING: A space was detected in your requested environment path\n"
+                    "'%s'\n"
+                    "Spaces in paths can sometimes be problematic." % prefix)
+
 
 def clone(src_arg, dst_prefix, json=False, quiet=False, index_args=None):
     if os.sep in src_arg:


Test patch: