Repository: conda/conda

Issue:
Conda Not Running
_From @sanghaisubham on May 2, 2018 8:24_

<!--
Thanks for opening an issue! A few things to keep in mind:

- This issue tracker is for issues with installing Anaconda or Miniconda or 
with packages built by Anaconda, Inc. like Anaconda Navigator. It is also a 
place to request packages or other enhancements of the Anaconda Distribution.

For conda issues, you should open an issue at https://github.com/conda/conda/issues
For conda-build issues, you should open an issue at https://github.com/conda/conda-build
For an issue with a particular conda-forge package, you should open an issue on the 
corresponding feedstock: https://github.com/conda-forge
-->

### Actual Behavior
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\cli\main.py", line 97, in main
        from ..activate import main as activator_main
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\activate.py", line 12, in <module>
        context.__init__()  # oOn import, context does not include SEARCH_PATH. This line fixes that.
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\base\context.py", line 236, in __init__
        argparse_args=argparse_args)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 722, in __init__
        self._set_search_path(search_path)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 728, in _set_search_path
        self._set_raw_data(load_file_configs(search_path))
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 369, in load_file_configs
        raw_data = odict(kv for kv in chain.from_iterable(load_paths))
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 369, in <genexpr>
        raw_data = odict(kv for kv in chain.from_iterable(load_paths))
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 344, in _file_yaml_loader
        yield fullpath, YamlRawParameter.make_raw_parameters_from_file(fullpath)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\configuration.py", line 332, in make_raw_parameters_from_file
        ruamel_yaml = yaml_load(fh)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\conda\common\serialize.py", line 54, in yaml_load
        return yaml.load(string, Loader=yaml.RoundTripLoader, version="1.2")
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\main.py", line 73, in load
        loader = Loader(stream, version, preserve_quotes=preserve_quotes)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\loader.py", line 56, in __init__
        Reader.__init__(self, stream)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\reader.py", line 98, in __init__
        self.determine_encoding()
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\reader.py", line 149, in determine_encoding
        self.update(1)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\reader.py", line 189, in update
        self.check_printable(data)
      File "C:\Users\Subham\Anaconda3\lib\site-packages\ruamel_yaml\reader.py", line 160, in check_printable
        'unicode', "special characters are not allowed")
    ruamel_yaml.reader.ReaderError: unacceptable character #x0000: special characters are not allowed
      in "C:\Users\Subham\.condarc", position 0

`$ C:\Users\Subham\Anaconda3\Scripts\conda shell.cmd.exe activate activate C:\Users\Subham\Anaconda3`

  environment variables:
                 CIO_TEST=<not set>
               CONDA_ROOT=C:\Users\Subham\Anaconda3
                 HOMEPATH=\Users\Subham
                     PATH=C:\Users\Subham\Anaconda3\Library\bin;C:\Program Files
                          (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\oracle
                          xe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\jav
                          apath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDO
                          WS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows
                          Live\Shared;C:\Program Files\Microsoft SQL
                          Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Program
                          Files\MATLAB\R2017a\runtime\win64;C:\Program
                          Files\MATLAB\R2017a\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program
                          Files\Common Files\Intel\WirelessCommon\;C:\Program
                          Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program
                          Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files
                          (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files
                          (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Users\Subham\
                          AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\Subham\App
                          Data\Local\Programs\Python\Python35-32\;C:\Users\Subham\AppData\Local\
                          Microsoft\WindowsApps;C:\Users\Subham\AppData\Local\GitHubDesktop\bin;
                          C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common
                          Files\Intel\WirelessCommon\;C:\texlive\2015\bin\win32
             PSMODULEPATH=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : C:\Users\Subham\.condarc
 populated config files :
          conda version : 4.5.1
    conda-build version : not installed
         python version : 3.6.1.final.0
       base environment : C:\Users\Subham\Anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\Subham\Anaconda3\pkgs
                          C:\Users\Subham\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\Subham\Anaconda3\envs
                          C:\Users\Subham\AppData\Local\conda\conda\envs
                          C:\Users\Subham\.conda\envs
               platform : win-64
             user-agent : conda/4.5.1 requests/2.14.2 CPython/3.6.1 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
<!-- What actually happens? -->

### Expected Behavior

<!-- What do you think should happen? -->

### Steps to Reproduce

<!-- Steps to reproduce issue. -->


##### Anaconda or Miniconda version:

##### Operating System:

##### `conda info`
<!-- between the ticks below, paste the output of 'conda info' -->
```

```

##### `conda list --show-channel-urls`
<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->
```

```


_Copied from original issue: ContinuumIO/anaconda-issues#9284_


Discussion:
You have incorrect yaml in one of your configuration files.  Probably `C:\Users\Subham\.condarc`.

Edit: Yes, it's `C:\Users\Subham\.condarc`.  You'll need to manually fix the yaml syntax in that file.
Moved here as an open issue so that we can give a proper user error instead of the stack trace.


Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -21,8 +21,8 @@
 from .._vendor.boltons.setutils import IndexedSet
 from .._vendor.frozendict import frozendict
 from ..common.compat import NoneType, iteritems, itervalues, odict, on_win, string_types
-from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
-                                    SequenceParameter, ValidationError)
+from ..common.configuration import (Configuration, ConfigurationLoadError, MapParameter,
+                                    PrimitiveParameter, SequenceParameter, ValidationError)
 from ..common.disk import conda_bld_ensure_dir
 from ..common.path import expand
 from ..common.os.linux import linux_get_libc_version
@@ -1161,7 +1161,7 @@ def get_prefix(ctx, args, search=True):  # pragma: no cover
 
 try:
     context = Context((), None)
-except LoadError as e:  # pragma: no cover
-    print(e, file=sys.stderr)
+except ConfigurationLoadError as e:  # pragma: no cover
+    print(repr(e), file=sys.stderr)
     # Exception handler isn't loaded so use sys.exit
     sys.exit(1)
diff --git a/conda/common/configuration.py b/conda/common/configuration.py
--- a/conda/common/configuration.py
+++ b/conda/common/configuration.py
@@ -64,9 +64,11 @@ def __call__(self, *args, **kwargs):
                 return self.handler(e)
 try:  # pragma: no cover
     from ruamel_yaml.comments import CommentedSeq, CommentedMap
+    from ruamel_yaml.reader import ReaderError
     from ruamel_yaml.scanner import ScannerError
 except ImportError:  # pragma: no cover
     from ruamel.yaml.comments import CommentedSeq, CommentedMap  # pragma: no cover
+    from ruamel.yaml.reader import ReaderError
     from ruamel.yaml.scanner import ScannerError
 
 log = getLogger(__name__)
@@ -87,19 +89,17 @@ def pretty_map(dictionary, padding='  '):
     return '\n'.join("%s%s: %s" % (padding, key, value) for key, value in iteritems(dictionary))
 
 
-class LoadError(CondaError):
-    def __init__(self, message, filepath, line, column):
-        self.line = line
-        self.filepath = filepath
-        self.column = column
-        msg = "Load Error: in %s on line %s, column %s. %s" % (filepath, line, column, message)
-        super(LoadError, self).__init__(msg)
-
-
 class ConfigurationError(CondaError):
     pass
 
 
+class ConfigurationLoadError(ConfigurationError):
+    def __init__(self, path, message_addition='', **kwargs):
+        message = "Unable to load configuration file.\n  path: %(path)s\n"
+        super(ConfigurationLoadError, self).__init__(message + message_addition, path=path,
+                                                     **kwargs)
+
+
 class ValidationError(ConfigurationError):
 
     def __init__(self, parameter_name, parameter_value, source, msg=None, **kwargs):
@@ -351,8 +351,17 @@ def make_raw_parameters_from_file(cls, filepath):
                 ruamel_yaml = yaml_load(fh)
             except ScannerError as err:
                 mark = err.problem_mark
-                raise LoadError("Invalid YAML", filepath, mark.line, mark.column)
-        return cls.make_raw_parameters(filepath, ruamel_yaml) or EMPTY_MAP
+                raise ConfigurationLoadError(
+                    filepath,
+                    "  reason: invalid yaml at line %(line)s, column %(column)s",
+                    line=mark.line,
+                    column=mark.column
+                )
+            except ReaderError as err:
+                raise ConfigurationLoadError(filepath,
+                                             "  reason: invalid yaml at position %(position)s",
+                                             position=err.position)
+            return cls.make_raw_parameters(filepath, ruamel_yaml) or EMPTY_MAP
 
 
 def load_file_configs(search_path):


Test patch:
diff --git a/tests/cli/test_config.py b/tests/cli/test_config.py
--- a/tests/cli/test_config.py
+++ b/tests/cli/test_config.py
@@ -8,7 +8,7 @@
 
 from conda.base.context import context, reset_context
 from conda.cli.python_api import Commands, run_command
-from conda.common.configuration import LoadError
+from conda.common.configuration import ConfigurationLoadError
 from conda.common.serialize import yaml_load
 from conda.gateways.disk.delete import rm_rf
 
@@ -54,11 +54,8 @@ def test_invalid_config():
         with make_temp_condarc(condarc) as rc:
             rc_path = rc
             run_command(Commands.CONFIG, '--file', rc, '--add', 'channels', 'test')
-    except LoadError as err:
-        error1 = "Load Error: in "
-        error2 = "on line 1, column 8. Invalid YAML"
-        assert error1 in err.message
-        assert error2 in err.message
+    except ConfigurationLoadError as err:
+        assert "reason: invalid yaml at line" in err.message, err.message
 
 # Tests for the conda config command
 # FIXME This shoiuld be multiple individual tests
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -832,7 +832,7 @@ def test_create_only_deps_flag(self):
                 assert package_is_installed(prefix, 'openssl')
             assert package_is_installed(prefix, 'itsdangerous')
 
-    @pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="TODO")
+    @pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="TODO")
     def test_install_update_deps_only_deps_flags(self):
         raise NotImplementedError()
 
@@ -1260,7 +1260,7 @@ def test_conda_pip_interop_dependency_satisfied_by_pip(self):
             assert json_obj['exception_name'] == 'PackagesNotFoundError'
             assert not len(json_obj.keys()) == 0
 
-    @pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="TODO")
+    @pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="TODO")
     def test_conda_pip_interop_pip_clobbers_conda(self):
         # 1. conda install old six
         # 2. pip install -U six
@@ -1268,16 +1268,16 @@ def test_conda_pip_interop_pip_clobbers_conda(self):
         # 4. probably need to purge something with the history file too?
         assert False
 
-    @pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="TODO")
+    @pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="TODO")
     def test_conda_pip_interop_conda_updates_pip_package(self):
         assert False
 
-    @pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="TODO")
+    @pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="TODO")
     def gittest_conda_pip_interop_conda_doesnt_update_ancient_distutils_package(self):
         # probably easiest just to use a conda package and remove the conda-meta record
         assert False
 
-    @pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="TODO")
+    @pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="TODO")
     def test_conda_pip_interop_conda_doesnt_update_editable_package(self):
         assert False
 
diff --git a/tests/test_resolve.py b/tests/test_resolve.py
--- a/tests/test_resolve.py
+++ b/tests/test_resolve.py
@@ -1004,7 +1004,7 @@ def test_no_features():
     ]
 
 
-@pytest.mark.skipif(datetime.now() < datetime(2018, 8, 1), reason="bogus test; talk with @mcg1969")
+@pytest.mark.skipif(datetime.now() < datetime(2018, 9, 1), reason="bogus test; talk with @mcg1969")
 def test_multiple_solution():
     index2 = index.copy()
     fn = 'pandas-0.11.0-np16py27_1.tar.bz2'