internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: conda/conda

Issue:
--mkdir no longer works
After upgrading to `conda=4.2`:

```
C:\> conda install --mkdir -n name python=3.5
CondaEnvironmentNotFoundError: Could not find environment: name .
You can list all discoverable environments with `conda info --envs`.
```

--mkdir no longer works
After upgrading to `conda=4.2`:

```
C:\> conda install --mkdir -n name python=3.5
CondaEnvironmentNotFoundError: Could not find environment: name .
You can list all discoverable environments with `conda info --envs`.
```



Discussion:

Resolving patch:
diff --git a/conda/cli/install.py b/conda/cli/install.py
--- a/conda/cli/install.py
+++ b/conda/cli/install.py
@@ -142,7 +142,7 @@ def install(args, parser, command='install'):
     isinstall = bool(command == 'install')
     if newenv:
         common.ensure_name_or_prefix(args, command)
-    prefix = context.prefix if newenv else context.prefix_w_legacy_search
+    prefix = context.prefix if newenv or args.mkdir else context.prefix_w_legacy_search
     if newenv:
         check_prefix(prefix, json=context.json)
     if context.force_32bit and is_root_prefix(prefix):


Test patch:
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -20,6 +20,7 @@
 from conda.cli.main_remove import configure_parser as remove_configure_parser
 from conda.cli.main_search import configure_parser as search_configure_parser
 from conda.cli.main_update import configure_parser as update_configure_parser
+from conda.common.disk import rm_rf
 from conda.common.io import captured, disable_logger, replace_log_streams, stderr_log_level
 from conda.common.url import path_to_url
 from conda.common.yaml import yaml_load
@@ -801,3 +802,18 @@ def test_clean_index_cache(self):
         # now clear it
         run_command(Commands.CLEAN, prefix, "--index-cache")
         assert not glob(join(index_cache_dir, "*.json"))
+
+    def test_install_mkdir(self):
+        try:
+            prefix = make_temp_prefix()
+            assert isdir(prefix)
+            run_command(Commands.INSTALL, prefix, "python=3.5", "--mkdir")
+            assert_package_is_installed(prefix, "python-3.5")
+
+            rm_rf(prefix)
+            assert not isdir(prefix)
+            run_command(Commands.INSTALL, prefix, "python=3.5", "--mkdir")
+            assert_package_is_installed(prefix, "python-3.5")
+
+        finally:
+            rmtree(prefix, ignore_errors=True)
Repository: conda/conda

Issue:
conda info exposing tokens
Hi, the conda info command is exposing tokens again. Por ejemplo:

```
Current conda install:

               platform : win-64
          conda version : 4.2.9
       conda is private : False
      conda-env version : 4.2.9
    conda-build version : 2.0.2
         python version : 2.7.12.final.0
       requests version : 2.11.1
       root environment : C:\Anaconda2  (writable)
    default environment : C:\Anaconda2
       envs directories : C:\Anaconda2\envs
          package cache : C:\Anaconda2\pkgs
           channel URLs : https://conda.anaconda.org/t/**EXPOSED TOKEN**/topper/win-64/
                          https://conda.anaconda.org/t/**EXPOSED TOKEN**/topper/noarch/
                          https://repo.continuum.io/pkgs/free/win-64/
                          https://repo.continuum.io/pkgs/free/noarch/
                          https://repo.continuum.io/pkgs/pro/win-64/
                          https://repo.continuum.io/pkgs/pro/noarch/
                          https://repo.continuum.io/pkgs/msys2/win-64/
                          https://repo.continuum.io/pkgs/msys2/noarch/
            config file : d:\Usuarios\108630\.condarc
           offline mode : False
```



Discussion:
Definitely a bug. Thanks for the report. 


Resolving patch:
diff --git a/conda/cli/main_info.py b/conda/cli/main_info.py
--- a/conda/cli/main_info.py
+++ b/conda/cli/main_info.py
@@ -11,6 +11,7 @@
 import re
 import sys
 from collections import OrderedDict
+from conda.common.url import mask_anaconda_token
 from os import listdir
 from os.path import exists, expanduser, join
 
@@ -225,6 +226,7 @@ def execute(args, parser):
     if not context.json:
         channels = [c + ('' if offline_keep(c) else '  (offline)')
                     for c in channels]
+    channels = [mask_anaconda_token(c) for c in channels]
 
     info_dict = dict(
         platform=context.subdir,
diff --git a/conda/common/url.py b/conda/common/url.py
--- a/conda/common/url.py
+++ b/conda/common/url.py
@@ -135,6 +135,11 @@ def strip_scheme(url):
     return url.split('://', 1)[-1]
 
 
+def mask_anaconda_token(url):
+    _, token = split_anaconda_token(url)
+    return url.replace(token, "<TOKEN>", 1) if token else url
+
+
 def split_anaconda_token(url):
     """
     Examples:


Test patch:
Repository: conda/conda

Issue:
conda env create giving ImportError for yaml package
`conda env create` suddenly started giving `"ImportError: No module named 'yaml'"` with latest miniconda on my TravisCI builbs: https://travis-ci.org/leouieda/website/builds/170917743

I changed nothing significant in my code. Tried rebuilding previous passing builds and started getting the same error. 

Is this something from a recent release?

conda env create giving ImportError for yaml package
`conda env create` suddenly started giving `"ImportError: No module named 'yaml'"` with latest miniconda on my TravisCI builbs: https://travis-ci.org/leouieda/website/builds/170917743

I changed nothing significant in my code. Tried rebuilding previous passing builds and started getting the same error. 

Is this something from a recent release?



Discussion:
Wow.  Thanks for the report.  I thought we had patched conda_env to use `ruamel_yaml`.  I guess not.

If you want to fix your build until we get this patched, you can add `conda install pyyaml`.

Wow.  Thanks for the report.  I thought we had patched conda_env to use `ruamel_yaml`.  I guess not.

If you want to fix your build until we get this patched, you can add `conda install pyyaml`.


Resolving patch:
diff --git a/conda_env/yaml.py b/conda_env/yaml.py
--- a/conda_env/yaml.py
+++ b/conda_env/yaml.py
@@ -5,7 +5,9 @@
 """
 from __future__ import absolute_import, print_function
 from collections import OrderedDict
-import yaml
+
+from conda.common.yaml import get_yaml
+yaml = get_yaml()
 
 
 def represent_ordereddict(dumper, data):


Test patch:
Repository: conda/conda

Issue:
local install create file: folder
Hi,

A folder named `file:` is always created if I installed conda package locally.
`conda install /local/path/bz2`

related to: https://github.com/conda/conda/issues/3770

```bash
$ conda info
Current conda install:

               platform : linux-64
          conda version : 4.2.11
       conda is private : False
      conda-env version : 4.2.11
    conda-build version : 2.0.7
         python version : 3.5.1.final.0
       requests version : 2.9.1
       root environment : /home/haichit/anaconda3  (writable)
    default environment : /home/haichit/anaconda3
       envs directories : /home/haichit/anaconda3/envs
          package cache : /home/haichit/anaconda3/pkgs
           channel URLs : https://conda.anaconda.org/conda-canary/linux-64
                          https://conda.anaconda.org/conda-canary/noarch
                          https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/ambermd/linux-64
                          https://conda.anaconda.org/ambermd/noarch
            config file : /home/haichit/.condarc
           offline mode : False
```


Discussion:

Resolving patch:
diff --git a/conda/misc.py b/conda/misc.py
--- a/conda/misc.py
+++ b/conda/misc.py
@@ -77,17 +77,17 @@ def explicit(specs, prefix, verbose=False, force_extract=True, index_args=None,
         # is_local: if the tarball is stored locally (file://)
         # is_cache: if the tarball is sitting in our cache
         is_local = not is_url(url) or url.startswith('file://')
-        prefix = cached_url(url) if is_local else None
-        is_cache = prefix is not None
+        url_prefix = cached_url(url) if is_local else None
+        is_cache = url_prefix is not None
         if is_cache:
             # Channel information from the cache
-            schannel = DEFAULTS if prefix == '' else prefix[:-2]
+            schannel = DEFAULTS if url_prefix == '' else url_prefix[:-2]
         else:
             # Channel information from the URL
             channel, schannel = Channel(url).url_channel_wtf
-            prefix = '' if schannel == DEFAULTS else schannel + '::'
+            url_prefix = '' if schannel == DEFAULTS else schannel + '::'
 
-        fn = prefix + fn
+        fn = url_prefix + fn
         dist = Dist(fn[:-8])
         # Add explicit file to index so we'll be sure to see it later
         if is_local:


Test patch:
Repository: conda/conda

Issue:
Make http timeouts configurable
http://docs.python-requests.org/en/master/user/advanced/#timeouts

Also set defaults to 2x current defaults.

CC @quasiben 


Discussion:

Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -79,6 +79,8 @@ class Context(Configuration):
     _channel_alias = PrimitiveParameter(DEFAULT_CHANNEL_ALIAS,
                                         aliases=('channel_alias',),
                                         validation=channel_alias_validation)
+    http_connect_timeout_secs = PrimitiveParameter(6.1)
+    http_read_timeout_secs = PrimitiveParameter(60.)
 
     # channels
     channels = SequenceParameter(string_types, default=('defaults',))
diff --git a/conda/core/index.py b/conda/core/index.py
--- a/conda/core/index.py
+++ b/conda/core/index.py
@@ -130,8 +130,9 @@ def fetch_repodata(url, cache_dir=None, use_cache=False, session=None):
         filename = 'repodata.json'
 
     try:
+        timeout = context.http_connect_timeout_secs, context.http_read_timeout_secs
         resp = session.get(join_url(url, filename), headers=headers, proxies=session.proxies,
-                           timeout=(3.05, 60))
+                           timeout=timeout)
         if log.isEnabledFor(DEBUG):
             log.debug(stringify(resp))
         resp.raise_for_status()
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
@@ -321,7 +321,8 @@ def download(url, dst_path, session=None, md5=None, urlstxt=False, retries=None)
     with FileLock(dst_path):
         rm_rf(dst_path)
         try:
-            resp = session.get(url, stream=True, proxies=session.proxies, timeout=(3.05, 27))
+            timeout = context.http_connect_timeout_secs, context.http_read_timeout_secs
+            resp = session.get(url, stream=True, proxies=session.proxies, timeout=timeout)
             resp.raise_for_status()
         except requests.exceptions.HTTPError as e:
             msg = "HTTPError: %s: %s\n" % (e, url)


Test patch:
Repository: conda/conda

Issue:
non json output on root clone
I understand that cloning root env is probably a not very good idea... but even then with the json flag, we get this non json output

```
$ conda create -n rootclone --clone root --json`
The following packages cannot be cloned out of the root environment:
 - conda-build-2.0.2-py35_0
 - conda-4.2.13-py35_0
... (valid Json output)
```

Possible fixes according to @kalefranz 

- Send that output to stderr
- Just eat that output
- Please fill in with your suggestion ...




Discussion:

Resolving patch:
diff --git a/conda/misc.py b/conda/misc.py
--- a/conda/misc.py
+++ b/conda/misc.py
@@ -224,9 +224,10 @@ def clone_env(prefix1, prefix2, verbose=True, quiet=False, index_args=None):
 
     if filter:
         if not quiet:
-            print('The following packages cannot be cloned out of the root environment:')
+            fh = sys.stderr if context.json else sys.stdout
+            print('The following packages cannot be cloned out of the root environment:', file=fh)
             for pkg in itervalues(filter):
-                print(' - ' + pkg.dist_name)
+                print(' - ' + pkg.dist_name, file=fh)
             drecs = {dist: info for dist, info in iteritems(drecs) if info['name'] not in filter}
 
     # Resolve URLs for packages that do not have URLs


Test patch:
Repository: conda/conda

Issue:
Conda 4.3.4 seems to be broken 
```
bag@bag ~ % conda --version      
conda 4.3.4
bag@bag ~ % conda install -y --file https://raw.githubusercontent.com/bioconda/bioconda-utils/master/bioconda_utils/bioconda_utils-requirements.txt


CondaError: Downloaded bytes did not match Content-Length
  url: https://raw.githubusercontent.com/bioconda/bioconda-utils/master/bioconda_utils/bioconda_utils-requirements.txt
  target_path: /tmp/tmpUp36pQ/bioconda_utils-requirements.txt
  Content-Length: 195
  downloaded bytes: 310



bag@bag ~ % 

```


Discussion:
Seems like https://github.com/conda/conda/commit/24ad4709#diff-e524c3264718c66b34ea0dadbfc2559fR88 introduced the bug. 

The request header sent by `requests.session` in this case has:
```bash
'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*'
```
AFAIK, the `Content-Length` header holds the raw length of the HTTP body. So, in this case, it will show 195 bytes, which is the size of the compressed 310 bytes.

If you do: `print(len(resp.raw.data))` you will see 195.
Sort of relevant discussion at: https://github.com/kennethreitz/requests/issues/2155

Resolving patch:
diff --git a/conda/gateways/download.py b/conda/gateways/download.py
--- a/conda/gateways/download.py
+++ b/conda/gateways/download.py
@@ -95,9 +95,10 @@ def download(url, target_full_path, md5sum):
                       Content-Length: %(content_length)d
                       downloaded bytes: %(downloaded_bytes)d
                     """)
-                    raise CondaError(message, url=url, target_path=target_full_path,
-                                     content_length=content_length,
-                                     downloaded_bytes=streamed_bytes)
+                    # raise CondaError(message, url=url, target_path=target_full_path,
+                    #                  content_length=content_length,
+                    #                  downloaded_bytes=streamed_bytes)
+                    log.info(message)
 
             except (IOError, OSError) as e:
                 if e.errno == 104:


Test patch:
Repository: conda/conda

Issue:
Conda 4.3.4 seems to be broken 
```
bag@bag ~ % conda --version      
conda 4.3.4
bag@bag ~ % conda install -y --file https://raw.githubusercontent.com/bioconda/bioconda-utils/master/bioconda_utils/bioconda_utils-requirements.txt


CondaError: Downloaded bytes did not match Content-Length
  url: https://raw.githubusercontent.com/bioconda/bioconda-utils/master/bioconda_utils/bioconda_utils-requirements.txt
  target_path: /tmp/tmpUp36pQ/bioconda_utils-requirements.txt
  Content-Length: 195
  downloaded bytes: 310



bag@bag ~ % 

```


Discussion:
Seems like https://github.com/conda/conda/commit/24ad4709#diff-e524c3264718c66b34ea0dadbfc2559fR88 introduced the bug. 

The request header sent by `requests.session` in this case has:
```bash
'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*'
```
AFAIK, the `Content-Length` header holds the raw length of the HTTP body. So, in this case, it will show 195 bytes, which is the size of the compressed 310 bytes.

If you do: `print(len(resp.raw.data))` you will see 195.
Sort of relevant discussion at: https://github.com/kennethreitz/requests/issues/2155

Resolving patch:
diff --git a/conda/gateways/download.py b/conda/gateways/download.py
--- a/conda/gateways/download.py
+++ b/conda/gateways/download.py
@@ -73,7 +73,9 @@ def download(url, target_full_path, md5sum):
                 with open(target_full_path, 'wb') as fh:
                     streamed_bytes = 0
                     for chunk in resp.iter_content(2 ** 14):
-                        streamed_bytes += len(chunk)
+                        # chunk could be the decompressed form of the real data
+                        # but we want the exact number of bytes read till now
+                        streamed_bytes = resp.raw.tell()
                         try:
                             fh.write(chunk)
                         except IOError as e:
@@ -95,10 +97,9 @@ def download(url, target_full_path, md5sum):
                       Content-Length: %(content_length)d
                       downloaded bytes: %(downloaded_bytes)d
                     """)
-                    # raise CondaError(message, url=url, target_path=target_full_path,
-                    #                  content_length=content_length,
-                    #                  downloaded_bytes=streamed_bytes)
-                    log.info(message)
+                    raise CondaError(message, url=url, target_path=target_full_path,
+                                     content_length=content_length,
+                                     downloaded_bytes=streamed_bytes)
 
             except (IOError, OSError) as e:
                 if e.errno == 104:


Test patch:
Repository: conda/conda

Issue:
Channels in centrally installed .condarc file are being ignored in conda 4.3.4
Hi, I am testing a centrally installed Anaconda setup with Anaconda installed under `C:\Program Files\Anaconda3`. I have a condarc file under `C:\Program Files\Anaconda3\.condarc`.

When I run `conda info` it tells me that my config file is under the correct location.

    config file : C:\Program Files\Anaconda3\.condarc

I have configured a few custom channels in this `.condarc` file, e.g.:

    channels:
      - http://some.internal/url

I can also use `conda config --system --add channels http://some.internal/url` to set this value and conda tells me that channels already contains this value.

But when I run `conda config --system --show`, the list of channels is always set to:

    channels:
      - defaults

It seems that the list of channels in the central `.condarc` file is completely ignored and always replaced by `defaults`. I have also tried to set the list of `default_channels` in the central `.condarc` file but without success.

Using conda 4.3.4 on win-64.



Discussion:
Definitely a problem.  Thanks for the report.  I'll investigate.

Resolving patch:
diff --git a/conda/__init__.py b/conda/__init__.py
--- a/conda/__init__.py
+++ b/conda/__init__.py
@@ -6,7 +6,9 @@
 """OS-agnostic, system-level binary package manager."""
 from __future__ import absolute_import, division, print_function, unicode_literals
 
+import os
 from os.path import dirname
+import sys
 
 from ._vendor.auxlib.packaging import get_version
 from .common.compat import iteritems, text_type
@@ -25,6 +27,10 @@
 __summary__ = __doc__
 __url__ = "https://github.com/conda/conda"
 
+
+if os.getenv('CONDA_ROOT') is None:
+    os.environ['CONDA_ROOT'] = sys.prefix
+
 CONDA_PACKAGE_ROOT = dirname(__file__)
 
 


Test patch:
Repository: conda/conda

Issue:
Error installing ipython
When trying to `conda install anaconda` on a Windows NanoServer container I continually get the below error when it tries to install ipython:
```
ERROR conda.core.link:_execute_actions(330): An error occurred while installing package 'defaults::ipython-5.1.0-py36_0'.
PathNotFoundException()
Attempting to roll back.

PathNotFoundException()
```
This error causes the build of the container to fail (anaconda doesn't get installed). Is there anyway to debug the problem? 

`conda                     4.3.13                   py36_0`


Discussion:
add `-v -v -v` to your commandline.
Yeah I'm not seeing `PathNotFoundException` anywhere in conda code.  `-vvv` should help
Sorry, should have thought of that myself - I just wanted to post the exception in case it rang a bell.

The output from trying to install ipython is available at: https://gist.github.com/dhirschfeld/b50c2a3640ae4b3fd10511acbaecf8eb
NB: I've seen menuinst errors before with ipython. Usually to do with not being admin, but I think the docker build runs as the container admin - will have to check. Either way the error seems to prevent the install from happening :/ 
Ah NanoServer doesn't have these folders I don't think. Does it even have a Start Menu? (or GUI?)
@mingwandroid - that's right, NanoServer doesn't have any GUI or desktop so wouldn't have a Start Menu. This means you can't remote desktop into it as you usually would on Windows but instead manage it via powershell.

I guess that explains the error. I'm wondering how to work around it short of rebuilding the ipython package without the menuinst component?

Resolving patch:
diff --git a/conda/gateways/disk/create.py b/conda/gateways/disk/create.py
--- a/conda/gateways/disk/create.py
+++ b/conda/gateways/disk/create.py
@@ -138,8 +138,8 @@ def make_menu(prefix, file_path, remove=False):
         log.warn("Environment name starts with underscore '_'. Skipping menu installation.")
         return
 
-    import menuinst
     try:
+        import menuinst
         menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
     except:
         stdoutlog.error("menuinst Exception:")


Test patch:
Repository: conda/conda

Issue:
cannot import conda.fetch.cache_fn_url
I'm using conda 4.3.2, and the function `conda.fetch.cache_fn_url` does not exist anymore.  What to do?


Discussion:
`conda.core.index.cache_fn_url`

> On Jan 9, 2017, at 6:11 PM, Ilan Schnell <notifications@github.com> wrote:
> 
> I'm using conda 4.3.2, and the function conda.fetch.cache_fn_url does not exist anymore. What to do?
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 

Thanks.  Nevertheless, this is yet another example of something I've been relying on for years is suddenly changing underneath me, and which is also I mostly rely on the "never to be changed" `libconda` package :-)
None of us is exempt from the admonition against relying on conda's private APIs.
That's true @mcg1969.  I have actually been the person always saying not to use conda as a library, but I did it myself for convenience because I was very familiar with what I wrote.
I'm not complaining, this change is not hard for me to make, but there are other people (in particular the maintainers of `conda-build` and `anaconda-navigator`), which rely intensely on the private API, for historical reasons.

The location changed again.  In 4.3.13 it is `conda.core.repodata.cache_fn_url()`.  Why do these things get moved around?

Resolving patch:
diff --git a/conda/exports.py b/conda/exports.py
--- a/conda/exports.py
+++ b/conda/exports.py
@@ -125,3 +125,6 @@
 
 from .gateways.subprocess import ACTIVE_SUBPROCESSES, subprocess_call  # NOQA
 ACTIVE_SUBPROCESSES, subprocess_call = ACTIVE_SUBPROCESSES, subprocess_call
+
+from .core.repodata import cache_fn_url  # NOQA
+cache_fn_url = cache_fn_url


Test patch: