Repository: conda/conda

Issue:
Conda package update error
Hi, 
I am having this error while trying to upgrade scikit-learn package:
```
$ conda update scikit-learn
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/ivan/anaconda:

The following packages will be UPDATED:

    conda:        4.3.4-py27_0       --> 4.3.9-py27_0      
    mkl:          11.3.3-0           --> 2017.0.1-0        
    numexpr:      2.5.2-np110py27_1  --> 2.6.1-np111py27_2 
    numpy:        1.10.4-py27_2      --> 1.11.3-py27_0     
    scikit-learn: 0.17.1-np110py27_2 --> 0.18.1-np111py27_1
    scipy:        0.17.1-np110py27_1 --> 0.18.1-np111py27_1

Proceed ([y]/n)? y

CondaError: dist_name is not a valid conda package: rfoo
```


Discussion:
By the way I have a similar error anytime I invoke conda:
```
[ivan@mbp ~]$ conda upgrade conda
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/ivan/anaconda:

The following packages will be UPDATED:

    conda: 4.3.4-py27_0 --> 4.3.16-py27_0

Proceed ([y]/n)? y

CondaError: dist_name is not a valid conda package: rfoo
```
Any idea?
There's something corrupted in your environment.  Can you attach the file created from

    conda update -y conda -vvv | tee output.txt
Hi, 
there is a problem with the command you provided: only the first part before it
ask for confirmation goes to output.txt, the remaining goes to the console. I've also tried 
`conda update -y conda -vvv > output.txt`
same problem.
Here is the output: [output.txt](https://github.com/conda/conda/files/979110/output.txt)

Oh right my mistake

    conda update -y conda -vvv 2>&1 | tee output.txt

Try that, then post the file.
Thanks (I am not bash-fluent...), here it is.
[output.txt](https://github.com/conda/conda/files/980979/output.txt)

Try

    conda clean --packages --tarballs
Current `conda info` is

```
Current conda install:

               platform : osx-64
          conda version : 4.3.4
       conda is private : False
      conda-env version : 4.3.4
    conda-build version : 2.0.1
         python version : 2.7.12.final.0
       requests version : 2.12.4
       root environment : /Users/ivan/anaconda  (writable)
    default environment : /Users/ivan/anaconda
       envs directories : /Users/ivan/anaconda/envs
          package cache : /Users/ivan/anaconda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/osx-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/osx-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/osx-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.4 requests/2.12.4 CPython/2.7.12 Darwin/16.5.0 OSX/10.12.4
                UID:GID : 501:20
```

Resolving patch:
diff --git a/conda/core/package_cache.py b/conda/core/package_cache.py
--- a/conda/core/package_cache.py
+++ b/conda/core/package_cache.py
@@ -262,6 +262,8 @@ def _add_entry(__packages_map, pkgs_dir, package_filename):
             if not package_filename.endswith(CONDA_TARBALL_EXTENSION):
                 package_filename += CONDA_TARBALL_EXTENSION
 
+            log.trace("adding to package cache %s", join(pkgs_dir, package_filename))
+
             dist = first(self.urls_data, lambda x: basename(x) == package_filename,
                          apply=Dist)
             if not dist:


Test patch: