Repository: conda/conda

Issue:
file:// URLs don't work anymore with conda 4.1.3
Conda 4.1.3 does not work anymore with **file://** URLs:

```
(E:\Anaconda3) C:\Windows\system32>conda update --override-channels --channel file:///A:/pkgs/free --all
Fetching package metadata ....Error: Could not find URL: file:///A:/pkgs/free/win-64/
```

But `A:\pkgs\free\win-64` really exists:

```
(E:\Anaconda3) C:\Windows\system32>dir A:\pkgs\free\win-64
 Volume in drive A is Software
 Volume Serial Number is 4546-3CD9

 Directory of A:\pkgs\free\win-64

06/24/2016  12:31 AM    <DIR>          .
01/23/2016  06:27 PM    <DIR>          ..
06/24/2016  12:28 AM           259,605 repodata.json.bz2
07/07/2015  12:54 AM            85,764 argcomplete-0.9.0-py34_0.tar.bz2
```

Before upgrading from 4.0.8-py35_0 everything worked fine. The same happened to the Linux version.



Discussion:
@mcg1969 I think I was going to write an integration test for this but obviously let it slip.

ARGH! No, actually, we have integration tests for file URLs and for file-based channels. This is madness! :-( @ciupicri, I apologize.

Hold on! @ciupicri, can you please create an _uncompressed_ `repodata.json` in that channel directory?

(You do recall, do you not, @kalefranz, that you removed the `bzip2` support from my test...)

:facepalm:

> On Jun 23, 2016, at 7:09 PM, Michael C. Grant notifications@github.com wrote:
> 
> (You do recall, do you not, @kalefranz, that you removed the bzip2 support from my test...)
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

Looks like we need to refer to `bzip2` for file:// base URLs. Should be a simple fix, not quite one-character :-)

@mcg1969, I've uncompresses the `repodata.json.bz2` that I had, and now conda fails at the next stage:

```
    unicodecsv:       0.14.1-py35_0      --> 0.14.1-py35_0     file:///A:/pkgs/free
    vs2015_runtime:   14.00.23026.0-0    --> 14.00.23026.0-0   file:///A:/pkgs/free
    wheel:            0.29.0-py35_0      --> 0.29.0-py35_0     file:///A:/pkgs/free

Proceed ([y]/n)? y

DEBUG:conda.instructions: PREFIX('E:\\Anaconda3')
DEBUG:conda.instructions: PRINT('Fetching packages ...')
Fetching packages ...
INFO:print:Fetching packages ...
DEBUG:conda.instructions: FETCH('file:///A:/pkgs/free::libdynd-0.7.2-0')
DEBUG:requests.packages.urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None)
DEBUG:conda.fetch:url='file:///A:/pkgs/free/win-64/libdynd-0.7.2-0.tar.bz2'
DEBUG:conda.fetch:HTTPError: 404 Client Error: None for url: file:///A:/pkgs/free/win-64/libdynd-0.7.2-0.tar.bz2: file:///A:/pkgs/free/win-64/libdynd-0.7.2-0.tar.bz2

Error: HTTPError: 404 Client Error: None for url: file:///A:/pkgs/free/win-64/libdynd-0.7.2-0.tar.bz2: file:///A:/pkgs/free/win-64/libdynd-0.7.2-0.tar.bz2
```

`conda list` show that I already have libdynd-0.7.2.


Resolving patch:
diff --git a/conda/fetch.py b/conda/fetch.py
--- a/conda/fetch.py
+++ b/conda/fetch.py
@@ -98,7 +98,7 @@ def fetch_repodata(url, cache_dir=None, use_cache=False, session=None):
     if "_mod" in cache:
         headers["If-Modified-Since"] = cache["_mod"]
 
-    if 'repo.continuum.io' in url:
+    if 'repo.continuum.io' in url or url.startswith("file://"):
         filename = 'repodata.json.bz2'
     else:
         headers['Accept-Encoding'] = 'gzip, deflate, compress, identity'


Test patch:
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -260,8 +260,8 @@ def test_tarball_install_and_bad_metadata(self):
                 os.makedirs(subchan)
                 tar_new_path = join(subchan, flask_fname)
                 copyfile(tar_old_path, tar_new_path)
-                with open(join(subchan, 'repodata.json'), 'w') as f:
-                    f.write(json.dumps(repodata))
+                with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f:
+                    f.write(json.dumps(repodata).encode('utf-8'))
                 run_command(Commands.INSTALL, prefix, '-c', channel, 'flask')
                 assert_package_is_installed(prefix, channel + '::' + 'flask-')