Repository: conda/conda

Issue:
repodata AssertionError
```
error: AssertionError()
command: /opt/intel/intelpython3/bin/conda update --all -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.9.49-moby debian/9 glibc/2.24
_messageid: -9223372036843625573
_messagetime: 1514424955743 / 2017-12-27 19:35:55

Traceback (most recent call last):
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/repodata.py", line 211, in _load
    mod_etag_headers.get('_mod'))
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/repodata.py", line 411, in fetch_repodata_remote_request
    raise Response304ContentUnchanged()
conda.core.repodata.Response304ContentUnchanged

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
    return func(*args, **kwargs)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
    exit_code = do_call(args, p)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/cli/main_update.py", line 14, in execute
    install(args, parser, 'update')
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/cli/install.py", line 236, in install
    force_reinstall=context.force,
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/solve.py", line 504, in solve_for_transaction
    force_remove, force_reinstall)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/solve.py", line 437, in solve_for_diff
    final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/solve.py", line 178, in solve_final_state
    index, r = self._prepare(prepared_specs)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/solve.py", line 560, in _prepare
    self.subdirs, prepared_specs)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/index.py", line 214, in get_reduced_index
    new_records = query_all(spec)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/index.py", line 187, in query_all
    return tuple(concat(future.result() for future in as_completed(futures)))
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/repodata.py", line 99, in query
    self.load()
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/repodata.py", line 143, in load
    _internal_state = self._load()
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/core/repodata.py", line 215, in _load
    touch(self.cache_path_json)
  File "/opt/intel/intelpython3/lib/python3.6/site-packages/conda/gateways/disk/update.py", line 80, in touch
    assert isdir(dirname(path))
AssertionError
```


Discussion:

Resolving patch:
diff --git a/conda/core/repodata.py b/conda/core/repodata.py
--- a/conda/core/repodata.py
+++ b/conda/core/repodata.py
@@ -10,7 +10,6 @@
 import json
 from logging import DEBUG, getLogger
 from mmap import ACCESS_READ, mmap
-from os import makedirs
 from os.path import dirname, isdir, join, splitext
 import re
 from textwrap import dedent
@@ -30,7 +29,7 @@
 from ..gateways.connection import (ConnectionError, HTTPError, InsecureRequestWarning,
                                    InvalidSchema, SSLError)
 from ..gateways.connection.session import CondaSession
-from ..gateways.disk import mkdir_p
+from ..gateways.disk import mkdir_p, mkdir_p_sudo_safe
 from ..gateways.disk.delete import rm_rf
 from ..gateways.disk.update import touch
 from ..models.channel import Channel, all_channel_urls
@@ -640,8 +639,5 @@ def add_http_value_to_dict(resp, http_key, d, dict_key):
 
 def create_cache_dir():
     cache_dir = join(PackageCache.first_writable(context.pkgs_dirs).pkgs_dir, 'cache')
-    try:
-        makedirs(cache_dir)
-    except OSError:
-        pass
+    mkdir_p_sudo_safe(cache_dir)
     return cache_dir


Test patch: