Repository: conda/conda

Issue:
Local filesystem channel fails with conda 4.6
## Current Behavior

After updating to conda 4.6.1, using a local channel with for example `conda search -c file:///some/path '*'` fails with an `UnavailableInvalidChannel` error, while it worked as expected with conda 4.5.12.


### Steps to Reproduce

```
$ tree /opt/conda/conda-bld
/opt/conda/conda-bld
└── noarch
    └── mypkg-1.0.0-py_0.tar.bz2

$ conda index /opt/conda/conda-bld
$ conda search -c file:///opt/conda/conda-bld '*'

UnavailableInvalidChannel: The channel is not accessible or is invalid.
  channel name: opt/conda/conda-bld
  channel url: file:///opt/conda/conda-bld
  error code: 404

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.

As of conda 4.3, a valid channel must contain a `noarch/repodata.json` and
associated `noarch/repodata.json.bz2` file, even if `noarch/repodata.json` is
empty. Use `conda index /opt/conda/conda-bld`, or create `noarch/repodata.json`
and associated `noarch/repodata.json.bz2`.
```

When switching back to conda 4.5.12 it works as expected:
```
$ conda install -y conda==4.5.12
$ conda search -c file:///opt/conda/conda-bld '*'
Loading channels: done
# Name                  Version           Build  Channel
mypkg                    1.0.0            py_0  conda-bld
```

## Expected Behavior

The local channel should be used successfully as with conda 4.5.12.


## Environment Information

conda: 4.5.12
conda-build: 3.17.8
python: 3.7.1


Discussion:
Thanks for reporting.  conda-build 3.17.8 was built with 4.6.1 (https://ci.appveyor.com/project/conda-forge/conda-build-feedstock/builds/21915370), so I don't think it's 4.6.1 itself.  Probably something subtle went wrong with conda-build 3.17.8 in its interaction with conda.
I see the same issues on my windows machines when using conda 4.6 but also for channels which are not related to the local conda-bld channel. In my case these are channels on network shares.
I'm getting this error for local channels accessed through HTTP. Exact same error message. Downgrading to 4.5.12 fixes this issue.
It appears as if conda 4.6.1 is expecting the presence of a `repodata.json` file in both the noarch directory and the directory of the current platform (for example linux-64).  Conda 4.5.12 only required the noarch repodata.json file to exist.  

I'll prepare a patch to restore the previous behavior. Until then creating an empty linux-64/win-64/osx-64 directory in the conda-bld directory and then running `conda index` will create the necessary files.
Good find, thanks @jjhelmus 

Resolving patch:
diff --git a/conda/core/subdir_data.py b/conda/core/subdir_data.py
--- a/conda/core/subdir_data.py
+++ b/conda/core/subdir_data.py
@@ -448,15 +448,15 @@ def fetch_repodata_remote_request(url, etag, mod_stamp):
         status_code = getattr(e.response, 'status_code', None)
         if status_code in (403, 404):
             if not url.endswith('/noarch'):
+                log.info("Unable to retrieve repodata (%d error) for %s", status_code, url)
+                return None
+            else:
                 if context.allow_non_channel_urls:
                     stderrlog.warning("Unable to retrieve repodata (%d error) for %s",
                                       status_code, url)
                     return None
                 else:
                     raise UnavailableInvalidChannel(Channel(dirname(url)), status_code)
-            else:
-                log.info("Unable to retrieve repodata (%d error) for %s", status_code, url)
-                return None
 
         elif status_code == 401:
             channel = Channel(url)


Test patch:
diff --git a/tests/core/test_repodata.py b/tests/core/test_repodata.py
--- a/tests/core/test_repodata.py
+++ b/tests/core/test_repodata.py
@@ -12,7 +12,7 @@
 from conda.common.io import env_var
 from conda.core.index import get_index
 from conda.core.subdir_data import Response304ContentUnchanged, cache_fn_url, read_mod_and_etag, \
-    SubdirData
+    SubdirData, fetch_repodata_remote_request, UnavailableInvalidChannel
 from conda.models.channel import Channel
 
 try:
@@ -163,6 +163,24 @@ def test_cache_fn_url_repo_anaconda_com(self):
         assert hash4 != hash6
 
 
+class FetchLocalRepodataTests(TestCase):
+
+    def test_fetch_repodata_remote_request_invalid_arch(self):
+        # see https://github.com/conda/conda/issues/8150
+        url = 'file:///fake/fake/fake/linux-64'
+        etag = None
+        mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
+        result = fetch_repodata_remote_request(url, etag, mod_stamp)
+        assert result is None
+
+    def test_fetch_repodata_remote_request_invalid_noarch(self):
+        url = 'file:///fake/fake/fake/noarch'
+        etag = None
+        mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
+        with pytest.raises(UnavailableInvalidChannel):
+            result = fetch_repodata_remote_request(url, etag, mod_stamp)
+
+
 # @pytest.mark.integration
 # class SubdirDataTests(TestCase):
 #