We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: Authenticated channels broken when using conda_env create.
<!--
Hi!

This is an issue tracker for conda -- the package manager.  File feature requests
for conda here, as well as bug reports about something conda has messed up.

If your issue is a bug report or feature request for:
  * a specific conda package from Anaconda ('defaults' channel):
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * a specific conda package from conda-forge:
      ==> file at the corresponding feedstock under https://github.com/conda-forge
  * repo.continuum.io access and service:
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * anaconda.org access and service:
      ==> file at https://anaconda.org/contact/report
  * commands under 'conda build':
      ==> file at https://github.com/conda/conda-build
  * commands under 'conda env':
      ==> please file it here!
  * all other conda commands that start with 'conda':
      ==> please file it here!

-->

**I'm submitting a...**
  - [x] bug report
  - [ ] feature request


### Current Behavior
Found two issues in Conda 4.4.x, which I believe are related so I've included them in the same ticket:
* `conda env create` ignores the authentication component of channels (as well as other components).
    * When `conda env create` is run, the authentication component is skipped, causing `PackageNotFound` errors to be generated for private packages.
* `conda env create` does not respect the channel priority flag available in the context (based off of expected behavior defined here: https://conda.io/docs/user-guide/tasks/manage-channels.html#after-conda-4-1-0)
    * When `conda env create` is run, channels with the same name are truncated before they reach the `Solver`; the `Solver` only receives the highest priority channel. This is not consistent with the channel priority behavior outlined above.

The problem appears to be happening with these 3 lines of code in the `conda` installer in the `conda_env`package: https://github.com/conda/conda/blob/master/conda_env/installers/conda.py#L31-L33

In that code, all of the channels retrieved from the `_channel_priority_map` are instantiated to `Channel` classes and then immediately truncated based on canonical name (for authed channels, this is only the channel name, with the token excluded). 

### Steps to Reproduce
For the first issue, using this environment file (`authed.yaml`, NOTE: that you will need to replace the channel with a private channel you control):
```yaml
name: authed_env
channels:
  - https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>
dependencies:
  - private_package
```
Run the following command and get:
```bash
$ conda env create -n authed_env -f authed.yaml
Solving environment: failed

ResolvePackageNotFound:
  - private_package
```

For the second issue, using this environment file (`priority.yaml`)
```yaml
name: priority_env
channels:
  - nextdoor
  - https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>
dependencies:
  - private_package
```
And this `.condarc`
```yaml
channel_priority: false
```
Run this command and get.
```bash
$ conda env create -n priority_env -f priority.yaml
Solving environment: failed

ResolvePackageNotFound:
  - private_package
```
This second is a little hidden because of the authenticated channel issue, but it's again caused by the `canonical_name` truncation.


### Expected Behavior
<!-- What do you think should happen? -->
* `conda env create` should allow environment files and `condarc` files to use authenticated channels (by respecting the full URL). 
* The command should also not truncate channels that it passes to the `Solver`. This is not behavior that is exhibited in other areas where `Solver` is instantiated.

As a note, the expected behavior did successfully occur in the latest 4.3.x release.

##### `conda info`
<!-- between the ticks below, paste the output of 'conda info' -->
```
     active environment : nextdoor
    active env location : /var/lib/conda/envs/nextdoor
            shell level : 1
       user config file : /home/vagrant/.condarc
 populated config files : /home/vagrant/.condarc
          conda version : 4.4.7
    conda-build version : not installed
         python version : 3.6.3.final.0
       base environment : /var/lib/conda  (writable)
           channel URLs : https://repo.continuum.io/pkgs/main/linux-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
          package cache : /var/lib/conda/pkgs
                          /home/vagrant/.conda/pkgs
       envs directories : /var/lib/conda/envs
                          /home/vagrant/.conda/envs
               platform : linux-64
             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.3 Linux/3.8.0-44-generic ubuntu/12.04 glibc/2.19
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
```


##### `conda config --show-sources`
<!-- between the ticks below, paste the output of 'conda config --show-sources' -->
```
==> /home/vagrant/.condarc <==
channel_priority: False
channels:
  - defaults
```


##### `conda list --show-channel-urls`
<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->
```
# packages in environment at /var/lib/conda:
#
asn1crypto                0.23.0           py36h4639342_0    defaults
ca-certificates           2017.08.26           h1d4fec5_0    defaults
certifi                   2017.11.5        py36hf29ccca_0    defaults
cffi                      1.11.2           py36h2825082_0    defaults
chardet                   3.0.4            py36h0f667ec_1    defaults
conda                     4.4.7                    py36_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
cryptography              2.1.4            py36hd09be54_0    defaults
idna                      2.6              py36h82fb2a8_1    defaults
libedit                   3.1                  heed3624_0    defaults
libffi                    3.2.1                hd88cf55_4    defaults
libgcc-ng                 7.2.0                h7cc24e2_2    defaults
libstdcxx-ng              7.2.0                h7a57d05_2    defaults
ncurses                   6.0                  h9df7e31_2    defaults
openssl                   1.0.2n               hb7f436b_0    defaults
pip                       9.0.1            py36h6c6f9ce_4    defaults
pycosat                   0.6.3            py36h0a5515d_0    defaults
pycparser                 2.18             py36hf9f622e_1    defaults
pyopenssl                 17.5.0           py36h20ba746_0    defaults
pysocks                   1.6.7            py36hd97a5b1_1    defaults
python                    3.6.3                h6c0c0dc_5    defaults
readline                  7.0                  ha6073c6_4    defaults
requests                  2.18.4           py36he2e5f8d_1    defaults
ruamel_yaml               0.11.14          py36ha2fb22d_2    defaults
setuptools                36.5.0           py36he42e2e1_0    defaults
six                       1.11.0           py36h372c433_1    defaults
sqlite                    3.20.1               hb898158_2    defaults
tk                        8.6.7                hc745277_3    defaults
urllib3                   1.22             py36hbe7ace6_0    defaults
wheel                     0.30.0           py36hfd4bba0_1    defaults
xz                        5.2.3                h55aa19d_2    defaults
yaml                      0.1.7                had09818_2    defaults
zlib                      1.2.11               ha838bed_2    defaults
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_env/installers/conda.py`
Content:
```
1 from __future__ import absolute_import
2 
3 from os.path import basename
4 
5 from conda._vendor.boltons.setutils import IndexedSet
6 from conda.base.context import context
7 from conda.core.solve import Solver
8 from conda.models.channel import Channel, prioritize_channels
9 
10 
11 def install(prefix, specs, args, env, *_, **kwargs):
12     # TODO: support all various ways this happens
13     # Including 'nodefaults' in the channels list disables the defaults
14     new_specs = []
15     channel_urls = set()
16     for elem in specs:
17         if "::" in elem:
18             channel_urls.add(elem.split("::")[0])
19             new_specs.append(elem.split("::")[-1])
20         else:
21             new_specs.append(elem)
22     specs = new_specs
23     channel_urls = list(channel_urls)
24     # TODO: support all various ways this happens
25     # Including 'nodefaults' in the channels list disables the defaults
26     channel_urls = channel_urls + [chan for chan in env.channels if chan != 'nodefaults']
27     if 'nodefaults' not in env.channels:
28         channel_urls.extend(context.channels)
29     _channel_priority_map = prioritize_channels(channel_urls)
30 
31     channel_names = IndexedSet(Channel(url).canonical_name for url in _channel_priority_map)
32     channels = IndexedSet(Channel(cn) for cn in channel_names)
33     subdirs = IndexedSet(basename(url) for url in _channel_priority_map)
34 
35     solver = Solver(prefix, channels, subdirs, specs_to_add=specs)
36     unlink_link_transaction = solver.solve_for_transaction(prune=getattr(args, 'prune', False))
37 
38     pfe = unlink_link_transaction.get_pfe()
39     pfe.execute()
40     unlink_link_transaction.execute()
41
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/conda_env/installers/conda.py b/conda_env/installers/conda.py
--- a/conda_env/installers/conda.py
+++ b/conda_env/installers/conda.py
@@ -28,8 +28,7 @@
         channel_urls.extend(context.channels)
     _channel_priority_map = prioritize_channels(channel_urls)
 
-    channel_names = IndexedSet(Channel(url).canonical_name for url in _channel_priority_map)
-    channels = IndexedSet(Channel(cn) for cn in channel_names)
+    channels = IndexedSet(Channel(url) for url in _channel_priority_map)
     subdirs = IndexedSet(basename(url) for url in _channel_priority_map)
 
     solver = Solver(prefix, channels, subdirs, specs_to_add=specs)

{"golden_diff": "diff --git a/conda_env/installers/conda.py b/conda_env/installers/conda.py\n--- a/conda_env/installers/conda.py\n+++ b/conda_env/installers/conda.py\n@@ -28,8 +28,7 @@\n         channel_urls.extend(context.channels)\n     _channel_priority_map = prioritize_channels(channel_urls)\n \n-    channel_names = IndexedSet(Channel(url).canonical_name for url in _channel_priority_map)\n-    channels = IndexedSet(Channel(cn) for cn in channel_names)\n+    channels = IndexedSet(Channel(url) for url in _channel_priority_map)\n     subdirs = IndexedSet(basename(url) for url in _channel_priority_map)\n \n     solver = Solver(prefix, channels, subdirs, specs_to_add=specs)\n", "issue": "Bug: Authenticated channels broken when using conda_env create.\n<!--\r\nHi!\r\n\r\nThis is an issue tracker for conda -- the package manager.  File feature requests\r\nfor conda here, as well as bug reports about something conda has messed up.\r\n\r\nIf your issue is a bug report or feature request for:\r\n  * a specific conda package from Anaconda ('defaults' channel):\r\n      ==> file at https://github.com/ContinuumIO/anaconda-issues\r\n  * a specific conda package from conda-forge:\r\n      ==> file at the corresponding feedstock under https://github.com/conda-forge\r\n  * repo.continuum.io access and service:\r\n      ==> file at https://github.com/ContinuumIO/anaconda-issues\r\n  * anaconda.org access and service:\r\n      ==> file at https://anaconda.org/contact/report\r\n  * commands under 'conda build':\r\n      ==> file at https://github.com/conda/conda-build\r\n  * commands under 'conda env':\r\n      ==> please file it here!\r\n  * all other conda commands that start with 'conda':\r\n      ==> please file it here!\r\n\r\n-->\r\n\r\n**I'm submitting a...**\r\n  - [x] bug report\r\n  - [ ] feature request\r\n\r\n\r\n### Current Behavior\r\nFound two issues in Conda 4.4.x, which I believe are related so I've included them in the same ticket:\r\n* `conda env create` ignores the authentication component of channels (as well as other components).\r\n    * When `conda env create` is run, the authentication component is skipped, causing `PackageNotFound` errors to be generated for private packages.\r\n* `conda env create` does not respect the channel priority flag available in the context (based off of expected behavior defined here: https://conda.io/docs/user-guide/tasks/manage-channels.html#after-conda-4-1-0)\r\n    * When `conda env create` is run, channels with the same name are truncated before they reach the `Solver`; the `Solver` only receives the highest priority channel. This is not consistent with the channel priority behavior outlined above.\r\n\r\nThe problem appears to be happening with these 3 lines of code in the `conda` installer in the `conda_env`package: https://github.com/conda/conda/blob/master/conda_env/installers/conda.py#L31-L33\r\n\r\nIn that code, all of the channels retrieved from the `_channel_priority_map` are instantiated to `Channel` classes and then immediately truncated based on canonical name (for authed channels, this is only the channel name, with the token excluded). \r\n\r\n### Steps to Reproduce\r\nFor the first issue, using this environment file (`authed.yaml`, NOTE: that you will need to replace the channel with a private channel you control):\r\n```yaml\r\nname: authed_env\r\nchannels:\r\n  - https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>\r\ndependencies:\r\n  - private_package\r\n```\r\nRun the following command and get:\r\n```bash\r\n$ conda env create -n authed_env -f authed.yaml\r\nSolving environment: failed\r\n\r\nResolvePackageNotFound:\r\n  - private_package\r\n```\r\n\r\nFor the second issue, using this environment file (`priority.yaml`)\r\n```yaml\r\nname: priority_env\r\nchannels:\r\n  - nextdoor\r\n  - https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>\r\ndependencies:\r\n  - private_package\r\n```\r\nAnd this `.condarc`\r\n```yaml\r\nchannel_priority: false\r\n```\r\nRun this command and get.\r\n```bash\r\n$ conda env create -n priority_env -f priority.yaml\r\nSolving environment: failed\r\n\r\nResolvePackageNotFound:\r\n  - private_package\r\n```\r\nThis second is a little hidden because of the authenticated channel issue, but it's again caused by the `canonical_name` truncation.\r\n\r\n\r\n### Expected Behavior\r\n<!-- What do you think should happen? -->\r\n* `conda env create` should allow environment files and `condarc` files to use authenticated channels (by respecting the full URL). \r\n* The command should also not truncate channels that it passes to the `Solver`. This is not behavior that is exhibited in other areas where `Solver` is instantiated.\r\n\r\nAs a note, the expected behavior did successfully occur in the latest 4.3.x release.\r\n\r\n##### `conda info`\r\n<!-- between the ticks below, paste the output of 'conda info' -->\r\n```\r\n     active environment : nextdoor\r\n    active env location : /var/lib/conda/envs/nextdoor\r\n            shell level : 1\r\n       user config file : /home/vagrant/.condarc\r\n populated config files : /home/vagrant/.condarc\r\n          conda version : 4.4.7\r\n    conda-build version : not installed\r\n         python version : 3.6.3.final.0\r\n       base environment : /var/lib/conda  (writable)\r\n           channel URLs : https://repo.continuum.io/pkgs/main/linux-64\r\n                          https://repo.continuum.io/pkgs/main/noarch\r\n                          https://repo.continuum.io/pkgs/free/linux-64\r\n                          https://repo.continuum.io/pkgs/free/noarch\r\n                          https://repo.continuum.io/pkgs/r/linux-64\r\n                          https://repo.continuum.io/pkgs/r/noarch\r\n                          https://repo.continuum.io/pkgs/pro/linux-64\r\n                          https://repo.continuum.io/pkgs/pro/noarch\r\n          package cache : /var/lib/conda/pkgs\r\n                          /home/vagrant/.conda/pkgs\r\n       envs directories : /var/lib/conda/envs\r\n                          /home/vagrant/.conda/envs\r\n               platform : linux-64\r\n             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.3 Linux/3.8.0-44-generic ubuntu/12.04 glibc/2.19\r\n                UID:GID : 1000:1000\r\n             netrc file : None\r\n           offline mode : False\r\n```\r\n\r\n\r\n##### `conda config --show-sources`\r\n<!-- between the ticks below, paste the output of 'conda config --show-sources' -->\r\n```\r\n==> /home/vagrant/.condarc <==\r\nchannel_priority: False\r\nchannels:\r\n  - defaults\r\n```\r\n\r\n\r\n##### `conda list --show-channel-urls`\r\n<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->\r\n```\r\n# packages in environment at /var/lib/conda:\r\n#\r\nasn1crypto                0.23.0           py36h4639342_0    defaults\r\nca-certificates           2017.08.26           h1d4fec5_0    defaults\r\ncertifi                   2017.11.5        py36hf29ccca_0    defaults\r\ncffi                      1.11.2           py36h2825082_0    defaults\r\nchardet                   3.0.4            py36h0f667ec_1    defaults\r\nconda                     4.4.7                    py36_0    defaults\r\nconda-env                 2.6.0                h36134e3_1    defaults\r\ncryptography              2.1.4            py36hd09be54_0    defaults\r\nidna                      2.6              py36h82fb2a8_1    defaults\r\nlibedit                   3.1                  heed3624_0    defaults\r\nlibffi                    3.2.1                hd88cf55_4    defaults\r\nlibgcc-ng                 7.2.0                h7cc24e2_2    defaults\r\nlibstdcxx-ng              7.2.0                h7a57d05_2    defaults\r\nncurses                   6.0                  h9df7e31_2    defaults\r\nopenssl                   1.0.2n               hb7f436b_0    defaults\r\npip                       9.0.1            py36h6c6f9ce_4    defaults\r\npycosat                   0.6.3            py36h0a5515d_0    defaults\r\npycparser                 2.18             py36hf9f622e_1    defaults\r\npyopenssl                 17.5.0           py36h20ba746_0    defaults\r\npysocks                   1.6.7            py36hd97a5b1_1    defaults\r\npython                    3.6.3                h6c0c0dc_5    defaults\r\nreadline                  7.0                  ha6073c6_4    defaults\r\nrequests                  2.18.4           py36he2e5f8d_1    defaults\r\nruamel_yaml               0.11.14          py36ha2fb22d_2    defaults\r\nsetuptools                36.5.0           py36he42e2e1_0    defaults\r\nsix                       1.11.0           py36h372c433_1    defaults\r\nsqlite                    3.20.1               hb898158_2    defaults\r\ntk                        8.6.7                hc745277_3    defaults\r\nurllib3                   1.22             py36hbe7ace6_0    defaults\r\nwheel                     0.30.0           py36hfd4bba0_1    defaults\r\nxz                        5.2.3                h55aa19d_2    defaults\r\nyaml                      0.1.7                had09818_2    defaults\r\nzlib                      1.2.11               ha838bed_2    defaults\r\n```\r\n\n", "before_files": [{"content": "from __future__ import absolute_import\n\nfrom os.path import basename\n\nfrom conda._vendor.boltons.setutils import IndexedSet\nfrom conda.base.context import context\nfrom conda.core.solve import Solver\nfrom conda.models.channel import Channel, prioritize_channels\n\n\ndef install(prefix, specs, args, env, *_, **kwargs):\n    # TODO: support all various ways this happens\n    # Including 'nodefaults' in the channels list disables the defaults\n    new_specs = []\n    channel_urls = set()\n    for elem in specs:\n        if \"::\" in elem:\n            channel_urls.add(elem.split(\"::\")[0])\n            new_specs.append(elem.split(\"::\")[-1])\n        else:\n            new_specs.append(elem)\n    specs = new_specs\n    channel_urls = list(channel_urls)\n    # TODO: support all various ways this happens\n    # Including 'nodefaults' in the channels list disables the defaults\n    channel_urls = channel_urls + [chan for chan in env.channels if chan != 'nodefaults']\n    if 'nodefaults' not in env.channels:\n        channel_urls.extend(context.channels)\n    _channel_priority_map = prioritize_channels(channel_urls)\n\n    channel_names = IndexedSet(Channel(url).canonical_name for url in _channel_priority_map)\n    channels = IndexedSet(Channel(cn) for cn in channel_names)\n    subdirs = IndexedSet(basename(url) for url in _channel_priority_map)\n\n    solver = Solver(prefix, channels, subdirs, specs_to_add=specs)\n    unlink_link_transaction = solver.solve_for_transaction(prune=getattr(args, 'prune', False))\n\n    pfe = unlink_link_transaction.get_pfe()\n    pfe.execute()\n    unlink_link_transaction.execute()\n", "path": "conda_env/installers/conda.py"}], "after_files": [{"content": "from __future__ import absolute_import\n\nfrom os.path import basename\n\nfrom conda._vendor.boltons.setutils import IndexedSet\nfrom conda.base.context import context\nfrom conda.core.solve import Solver\nfrom conda.models.channel import Channel, prioritize_channels\n\n\ndef install(prefix, specs, args, env, *_, **kwargs):\n    # TODO: support all various ways this happens\n    # Including 'nodefaults' in the channels list disables the defaults\n    new_specs = []\n    channel_urls = set()\n    for elem in specs:\n        if \"::\" in elem:\n            channel_urls.add(elem.split(\"::\")[0])\n            new_specs.append(elem.split(\"::\")[-1])\n        else:\n            new_specs.append(elem)\n    specs = new_specs\n    channel_urls = list(channel_urls)\n    # TODO: support all various ways this happens\n    # Including 'nodefaults' in the channels list disables the defaults\n    channel_urls = channel_urls + [chan for chan in env.channels if chan != 'nodefaults']\n    if 'nodefaults' not in env.channels:\n        channel_urls.extend(context.channels)\n    _channel_priority_map = prioritize_channels(channel_urls)\n\n    channels = IndexedSet(Channel(url) for url in _channel_priority_map)\n    subdirs = IndexedSet(basename(url) for url in _channel_priority_map)\n\n    solver = Solver(prefix, channels, subdirs, specs_to_add=specs)\n    unlink_link_transaction = solver.solve_for_transaction(prune=getattr(args, 'prune', False))\n\n    pfe = unlink_link_transaction.get_pfe()\n    pfe.execute()\n    unlink_link_transaction.execute()\n", "path": "conda_env/installers/conda.py"}]}