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

Issue:
conda search broken for me on master
On master (`4d7286cddf091c0bcf8bd105ad847dd9f57c1ed7`), I now get:

```
$ conda search
...
Traceback (most recent call last):
  File "/Users/ilan/python/bin/conda", line 6, in <module>
    sys.exit(conda.cli.main())
  File "/Users/ilan/conda/conda/cli/main.py", line 120, in main
    args_func(args, p)
  File "/Users/ilan/conda/conda/cli/main.py", line 127, in args_func
    args.func(args, p)
  File "/Users/ilan/conda/conda/cli/main_search.py", line 118, in execute
    execute_search(args, parser)
  File "/Users/ilan/conda/conda/cli/main_search.py", line 155, in execute_search
    extracted = conda.install.extracted()
  File "/Users/ilan/conda/conda/install.py", line 749, in extracted
    return set(dist for dist, rec in package_cache().items() if rec['dirs'])
  File "/Users/ilan/conda/conda/install.py", line 673, in package_cache
    add_cached_package(pdir, fn)
  File "/Users/ilan/conda/conda/install.py", line 627, in add_cached_package
    url = remove_binstar_tokens(url)
  File "/Users/ilan/conda/conda/config.py", line 258, in remove_binstar_tokens
    return BINSTAR_TOKEN_PAT.sub(r'\1', url)
TypeError: expected string or buffer
```



Discussion:
Hmm, I also get this when I do `conda install`.  CC @kalefranz 

Guessing you'll be fine on py2 if you want to keep testing. Will definitely address it though ASAP. No idea how it happened or why tests passed with it. 

> On May 21, 2016, at 11:30 PM, Ilan Schnell notifications@github.com wrote:
> 
> Hmm, I also get this when I do conda install. CC @kalefranz
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub

I am on Python 2.

Oh then try py3

> On May 22, 2016, at 12:41 AM, Ilan Schnell notifications@github.com wrote:
> 
> I am on Python 2.
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub

I've added a debug print statement to see what `url` is.  The result is that `url` is `None`.  So this is not a Python 2 / 3 problem.

I think I know what it is


Resolving patch:
diff --git a/conda/install.py b/conda/install.py
--- a/conda/install.py
+++ b/conda/install.py
@@ -624,7 +624,8 @@ def add_cached_package(pdir, url, overwrite=False, urlstxt=False):
         xdir = None
     if not (xpkg or xdir):
         return
-    url = remove_binstar_tokens(url)
+    if url:
+        url = remove_binstar_tokens(url)
     _, schannel = url_channel(url)
     prefix = '' if schannel == 'defaults' else schannel + '::'
     xkey = xpkg or (xdir + '.tar.bz2')


Test patch:
Repository: conda/conda

Issue:
install.package_cache() broken with cache directory does not exist
I just ran into this bug when building a package with `conda-build`.  Before building the package, I cleaned out removed the cache directory `pkgs`.  The trachback is as follows:

```
Traceback (most recent call last):
  File "/home/ilan/minonda/bin/conda-build", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/ilan/conda-build/bin/conda-build", line 5, in <module>
    sys.exit(main())
  File "/home/ilan/conda-build/conda_build/main_build.py", line 140, in main
    args_func(args, p)
  File "/home/ilan/conda-build/conda_build/main_build.py", line 380, in args_func
    args.func(args, p)
  File "/home/ilan/conda-build/conda_build/main_build.py", line 367, in execute
    build.test(m)
  File "/home/ilan/conda-build/conda_build/build.py", line 613, in test
    rm_pkgs_cache(m.dist())
  File "/home/ilan/conda-build/conda_build/build.py", line 386, in rm_pkgs_cache
    plan.execute_plan(rmplan)
  File "/home/ilan/conda/conda/plan.py", line 583, in execute_plan
    inst.execute_instructions(plan, index, verbose)
  File "/home/ilan/conda/conda/instructions.py", line 133, in execute_instructions
    cmd(state, arg)
  File "/home/ilan/conda/conda/instructions.py", line 65, in RM_FETCHED_CMD
    install.rm_fetched(arg)
  File "/home/ilan/conda/conda/install.py", line 749, in rm_fetched
    rec = package_cache().get(dist)
  File "/home/ilan/conda/conda/install.py", line 692, in package_cache
    for fn in os.listdir(pdir):
OSError: [Errno 2] No such file or directory: '/home/ilan/minonda/pkgs'
```

The problem is that https://github.com/conda/conda/blob/master/conda/install.py#L692 assumes that the directory already exists, which might not be the case.

CC @mcg1969 



Discussion:
I think the best thing here is to surround 692-693 in a `try/except` block like the previous block of code. I'll do this ASAP


Resolving patch:
diff --git a/conda/install.py b/conda/install.py
--- a/conda/install.py
+++ b/conda/install.py
@@ -689,8 +689,9 @@ def package_cache():
                     add_cached_package(pdir, url)
         except IOError:
             pass
-        for fn in os.listdir(pdir):
-            add_cached_package(pdir, fn)
+        if isdir(pdir):
+            for fn in os.listdir(pdir):
+                add_cached_package(pdir, fn)
     del package_cache_['@']
     return package_cache_
 


Test patch:
Repository: conda/conda

Issue:
conda 4.1 breaks fish integrations
The new version does not work with fish at all. While the .fish script is finally there in the bin directory, it does not seem to kick in, since the new activate.py command is messing with it. How is it supposed to work?

This is the error I get:

```
$ conda activate myenv
Traceback (most recent call last):
  File "/home/jrodriguez/.local/anaconda/bin/conda", line 6, in <module>
    sys.exit(main())
  File "/home/jrodriguez/.local/anaconda/lib/python3.5/site-packages/conda/cli/main.py", line 48, in main
    activate.main()
  File "/home/jrodriguez/.local/anaconda/lib/python3.5/site-packages/conda/cli/activate.py", line 119, in main
    shelldict = shells[shell]
KeyError: 'myenv'
```

Meanwhile, I had to downgrade to conda 4.0 with `conda install conda=4.0`. Thank you!



Discussion:
I'd actually recommend downgrading to `4.0.8`. But we'll investigate this quickly!

Working on it.  This is because we have to explicitly name the shell when calling ..activate and such.  Detecting the parent shell proved to be unreliable.


Resolving patch:
diff --git a/conda/cli/activate.py b/conda/cli/activate.py
--- a/conda/cli/activate.py
+++ b/conda/cli/activate.py
@@ -134,8 +134,11 @@ def main():
         if rootpath:
             path = path.replace(shelldict['pathsep'].join(rootpath), "")
 
+        path = path.lstrip()
         # prepend our new entries onto the existing path and make sure that the separator is native
         path = shelldict['pathsep'].join(binpath + [path, ])
+        # Clean up any doubled-up path separators
+        path = path.replace(shelldict['pathsep'] * 2, shelldict['pathsep'])
 
     # deactivation is handled completely in shell scripts - it restores backups of env variables.
     #    It is done in shell scripts because they handle state much better than we can here.
diff --git a/conda/utils.py b/conda/utils.py
--- a/conda/utils.py
+++ b/conda/utils.py
@@ -410,7 +410,8 @@ def yaml_dump(string):
         "zsh": dict(
             unix_shell_base, exe="zsh",
                    ),
-        # "fish": dict(unix_shell_base, exe="fish",
-        #             shell_suffix=".fish",
-        #             source_setup=""),
+        "fish": dict(
+            unix_shell_base, exe="fish",
+            pathsep=" ",
+                    ),
     }
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,9 @@
     long_description = f.read()
 
 scripts = ['bin/activate',
-           'bin/deactivate', ]
+           'bin/deactivate',
+           'bin/conda.fish',
+           ]
 if sys.platform == 'win32':
     # Powershell scripts should go here
     scripts.extend(['bin/activate.bat',


Test patch:
Repository: conda/conda

Issue:
activate symlink error
when using source activate they get this symlink error

> While trying to use the nfs installation with a user account that lacks the write permissions on the installation and the preconfigured environments, I'm getting an error:
> 
>    Cannot activate environment bash, not have write access to conda symlink
> 
> Is this new, or I simply didn't notice the problem in the earlier versions?

https://github.com/conda/conda/blob/4.1.x/conda/cli/activate.py#L158-L167 seems like its testing that it can create the symlink even if its already there, can anyone explain this functionality and why it would require permissions to write to the root environment?



Discussion:
Just noting this wouldn't have been a problem if I'd pushed forward with https://github.com/conda/conda/issues/2502


Resolving patch:
diff --git a/conda/cli/activate.py b/conda/cli/activate.py
--- a/conda/cli/activate.py
+++ b/conda/cli/activate.py
@@ -163,7 +163,8 @@ def main():
             conda.install.symlink_conda(prefix, root_dir, shell)
         except (IOError, OSError) as e:
             if e.errno == errno.EPERM or e.errno == errno.EACCES:
-                msg = ("Cannot activate environment {0}, not have write access to conda symlink"
+                msg = ("Cannot activate environment {0}.\n"
+                       "User does not have write access for conda symlinks."
                        .format(sys.argv[2]))
                 sys.exit(msg)
             raise
diff --git a/conda/install.py b/conda/install.py
--- a/conda/install.py
+++ b/conda/install.py
@@ -573,13 +573,20 @@ def symlink_conda_hlp(prefix, root_dir, where, symlink_fn):
     for f in scripts:
         root_file = join(root_dir, where, f)
         prefix_file = join(prefix_where, f)
-        # try to kill stale links if they exist
-        if os.path.lexists(prefix_file):
-            os.remove(prefix_file)
-        # if they're in use, they won't be killed.  Skip making new symlink.
-        if not os.path.lexists(prefix_file):
-            symlink_fn(root_file, prefix_file)
-
+        try:
+            # try to kill stale links if they exist
+            if os.path.lexists(prefix_file):
+                os.remove(prefix_file)
+            # if they're in use, they won't be killed.  Skip making new symlink.
+            if not os.path.lexists(prefix_file):
+                symlink_fn(root_file, prefix_file)
+        except (IOError, OSError) as e:
+            if (os.path.lexists(prefix_file) and
+                    (e.errno == errno.EPERM or e.errno == errno.EACCES)):
+                log.debug("Cannot symlink {0} to {1}. Ignoring since link already exists."
+                          .format(root_file, prefix_file))
+            else:
+                raise
 
 # ========================== begin API functions =========================
 


Test patch:
Repository: conda/conda

Issue:
Conda install from file fails in version 4.1
I've recently installed linux-32 conda on CentOS 6.2. I confirmed this on linux-64 version as well.

If I run: `conda install ./FILE_1.tar.bz2`, I always get the error:
`Fetching package metadata ...Error: Could not find URL: file:///root/dir1/
`
If i downgrade to conda 4.0.8, it works fine.

Here's the command with the added `--debug` option:

```
$ conda --debug install ./FILE_1.tar.bz2
DEBUG:conda.fetch:channel_urls={'file:///root/dir1/': ('file:///root', 0)}
Fetching package metadata ...INFO:stdoutlog:Fetching package metadata ...
DEBUG:requests.packages.urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None)
DEBUG:conda.fetch:Could not find URL: file:///root/dir1/
Error: Could not find URL: file:///root/dir1/
```



Discussion:
relates to #2642, but not exactly the same

I'll take this


Resolving patch:
diff --git a/conda/config.py b/conda/config.py
--- a/conda/config.py
+++ b/conda/config.py
@@ -297,6 +297,8 @@ def url_channel(url):
         return None, '<unknown>'
     channel = url.rsplit('/', 2)[0]
     schannel = canonical_channel_name(channel)
+    if url.startswith('file://') and schannel != 'local':
+        channel = schannel = url.rsplit('/', 1)[0]
     return channel, schannel
 
 # ----- allowed channels -----
diff --git a/conda/misc.py b/conda/misc.py
--- a/conda/misc.py
+++ b/conda/misc.py
@@ -76,12 +76,17 @@ def explicit(specs, prefix, verbose=False, force_extract=True, fetch_args=None,
             prefix = '' if schannel == 'defaults' else schannel + '::'
         fn = prefix + fn
         dist = fn[:-8]
+        is_file = fn.startswith('file://')
+        # Add file to index so we'll see it later
+        if is_file:
+            index[fn] = {'fn': dist2filename(fn), 'url': url, 'md5': None}
 
         pkg_path = is_fetched(dist)
         dir_path = is_extracted(dist)
 
         # Don't re-fetch unless there is an MD5 mismatch
-        if pkg_path and (md5 and md5_file(pkg_path) != md5):
+        # Also remove explicit tarballs from cache
+        if pkg_path and (is_file or md5 and md5_file(pkg_path) != md5):
             # This removes any extracted copies as well
             actions[RM_FETCHED].append(dist)
             pkg_path = dir_path = None
@@ -96,10 +101,11 @@ def explicit(specs, prefix, verbose=False, force_extract=True, fetch_args=None,
                 _, conflict = find_new_location(dist)
                 if conflict:
                     actions[RM_FETCHED].append(conflict)
-                if fn not in index or index[fn].get('not_fetched'):
-                    channels[url_p + '/'] = (schannel, 0)
+                if not is_file:
+                    if fn not in index or index[fn].get('not_fetched'):
+                        channels[url_p + '/'] = (schannel, 0)
+                    verifies.append((dist + '.tar.bz2', md5))
                 actions[FETCH].append(dist)
-                verifies.append((dist + '.tar.bz2', md5))
             actions[EXTRACT].append(dist)
 
         # unlink any installed package with that name


Test patch:
Repository: conda/conda

Issue:
source activate without arguments breaks source activate/deactivate commands
Running `source activate` without any further arguments on Linux with the latest release makes it so that further activate/deactivate commands do not work. For example:

```
ihenriksen@ubuntu:~$ source activate
prepending /home/ihenriksen/miniconda2/envs/bin to PATH
ihenriksen@ubuntu:~$ source activate py27
bash: activate: No such file or directory
ihenriksen@ubuntu:~$ source deactivate
bash: deactivate: No such file or directory
ihenriksen@ubuntu:~$
```

This isn't at all a blocking issue for me, but it seems like something worth revisiting when we can.



Discussion:
Pretty sure it is getting an empty string, then considering that a valid env, somehow.  ugh.  Thanks for reporting.


Resolving patch:
diff --git a/conda/cli/activate.py b/conda/cli/activate.py
--- a/conda/cli/activate.py
+++ b/conda/cli/activate.py
@@ -119,14 +119,11 @@ def main():
     shelldict = shells[shell]
     if sys.argv[1] == '..activate':
         path = get_path(shelldict)
-        if len(sys.argv) == 3 or sys.argv[3].lower() == root_env_name.lower():
-            binpath = binpath_from_arg(root_env_name, shelldict=shelldict)
-            rootpath = None
-        elif len(sys.argv) == 4:
+        if len(sys.argv) == 4:
             binpath = binpath_from_arg(sys.argv[3], shelldict=shelldict)
             rootpath = binpath_from_arg(root_env_name, shelldict=shelldict)
         else:
-            sys.exit("Error: did not expect more than one argument")
+            sys.exit("Error: ..activate expected exactly two arguments: shell and env name")
         pathlist_str = pathlist_to_str(binpath)
         sys.stderr.write("prepending %s to PATH\n" % shelldict['path_to'](pathlist_str))
 
@@ -142,7 +139,7 @@ def main():
 
     elif sys.argv[1] == '..checkenv':
         if len(sys.argv) < 4:
-            sys.argv.append(root_env_name)
+            sys.exit("Invalid arguments to checkenv.  Need shell and env name/path")
         if len(sys.argv) > 4:
             sys.exit("Error: did not expect more than one argument.")
         if sys.argv[3].lower() == root_env_name.lower():


Test patch:
Repository: conda/conda

Issue:
conda throws error if allow_other_channels setting is used
The feature to lock down what channels your users are allowed to use stopped working
http://conda.pydata.org/docs/install/central.html#allow-other-channels-allow-other-channels

Reproduced this error in Windows 10 and OS X 10.11.5, if you use this setting in the systemwide .condarc file.  

```
$ cat /Users/jenns/anaconda/.condarc
allow_other_channels: False
channels:
  - defaults

```

```
$ conda info
Traceback (most recent call last):
  File "/Users/jenns/anaconda/bin/conda", line 6, in <module>
    sys.exit(main())
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 61, in main
    from conda.cli import conda_argparse
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 15, in <module>
    from .common import add_parser_help
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/cli/common.py", line 12, in <module>
    from ..config import (envs_dirs, default_prefix, platform, update_dependencies,
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/config.py", line 331, in <module>
    allowed_channels = get_allowed_channels()
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/config.py", line 329, in get_allowed_channels
    return normalize_urls(base_urls)
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/config.py", line 253, in normalize_urls
    urls = get_rc_urls() + urls
  File "/Users/jenns/anaconda/lib/python2.7/site-packages/conda/config.py", line 197, in get_rc_urls
    if rc.get('channels') is None:
AttributeError: 'NoneType' object has no attribute 'get'
```



Discussion:
downgraded conda to 4.0.9 and the issue went away.

This occurs because when `allow_other_channels` is `False`, the call to `get_allowed_channels()` in `config.py` is trying to call `get_rc_urls()` before the local `~/.condarc` has been loaded.

This can be fixed by moving the line `allowed_channels = get_allowed_channels()` to the very end of `config.py`, after the `load_condarc` call. It can also be fixed by modifying `get_rc_urls` to return an empty list if `rc` is `None`. I'm leaning towards the latter.


Resolving patch:
diff --git a/conda/config.py b/conda/config.py
--- a/conda/config.py
+++ b/conda/config.py
@@ -194,7 +194,7 @@ def get_default_urls(merged=False):
     return defaults_
 
 def get_rc_urls():
-    if rc.get('channels') is None:
+    if rc is None or rc.get('channels') is None:
         return []
     if 'system' in rc['channels']:
         raise RuntimeError("system cannot be used in .condarc")


Test patch:
Repository: conda/conda

Issue:
Zsh.exe not supported on MSYS2
The following error is reported in a MSYS2 zsh shell:

```
➜  dotfiles git:(master) ✗ source activate py35_32
Traceback (most recent call last):
  File "C:\Miniconda3\Scripts\conda-script.py", line 5, in <module>
    sys.exit(main())
  File "C:\Miniconda3\lib\site-packages\conda\cli\main.py", line 48, in main
    activate.main()
  File "C:\Miniconda3\lib\site-packages\conda\cli\activate.py", line 105, in main
    shelldict = shells[shell]
KeyError: 'zsh.exe'
```



Discussion:

Resolving patch:
diff --git a/conda/utils.py b/conda/utils.py
--- a/conda/utils.py
+++ b/conda/utils.py
@@ -313,6 +313,12 @@ def human_bytes(n):
         "sh.exe": dict(
             msys2_shell_base, exe="sh.exe",
         ),
+        "zsh.exe": dict(
+            msys2_shell_base, exe="zsh.exe",
+        ),
+        "zsh": dict(
+            msys2_shell_base, exe="zsh",
+        ),
     }
 
 else:


Test patch:
Repository: conda/conda

Issue:
URLs with :: are OK and should not raise assertion errors
For conda-build's perl skeleton generator, we can end up with URLs like:

http://api.metacpan.org/v0/module/Test::More

Unfortunately, conda prevents us from actually using those URLs:

```
  File "/Users/msarahan/miniconda2/lib/python2.7/site-packages/conda/fetch.py", line 354, in download
    assert "::" not in str(url), url
AssertionError: http://api.metacpan.org/v0/module/Test::More
```

Please partially revert https://github.com/conda/conda/commit/39605e01ccd05b5af5ebeceeacaafe652f4b32e4



Discussion:
I believe I add this assertion, and I think it is fine to revert back or change it in a new PR.


Resolving patch:
diff --git a/conda/fetch.py b/conda/fetch.py
--- a/conda/fetch.py
+++ b/conda/fetch.py
@@ -351,7 +351,6 @@ def fetch_pkg(info, dst_dir=None, session=None):
 
 
 def download(url, dst_path, session=None, md5=None, urlstxt=False, retries=None):
-    assert "::" not in str(url), url
     assert "::" not in str(dst_path), str(dst_path)
     if not offline_keep(url):
         raise RuntimeError("Cannot download in offline mode: %s" % (url,))


Test patch:
Repository: conda/conda

Issue:
Conda 4.2 branch doesn't support CIO_TEST.
In config.py in `conda 4.1.x` I see:

```
def get_channel_urls(platform=None):
    if os.getenv('CIO_TEST'):
        import cio_test
        base_urls = cio_test.base_urls
```

cio_test is not imported anywhere in 4.2.



Discussion:
I need to discuss with Ilan. Didn't get a chance today.

No problem, I've been using `4.1.x` when I need to build those packages anyway.


Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -20,10 +20,10 @@
 
 log = getLogger(__name__)
 
-
-default_python = '%d.%d' % sys.version_info[:2]
-
-# ----- operating system and architecture -----
+try:
+    import cio_test  # NOQA
+except ImportError:
+    log.info("No cio_test package found.")
 
 _platform_map = {
     'linux2': 'linux',
@@ -40,8 +40,6 @@
 
 class Context(Configuration):
 
-    default_python = property(lambda self: default_python)
-
     add_anaconda_token = PrimitiveParameter(True, aliases=('add_binstar_token',))
     add_pip_as_python_dependency = PrimitiveParameter(True)
     allow_softlinks = PrimitiveParameter(True)
@@ -79,6 +77,11 @@ class Context(Configuration):
     binstar_upload = PrimitiveParameter(None, aliases=('anaconda_upload',),
                                         parameter_type=(bool, NoneType))
 
+    @property
+    def default_python(self):
+        ver = sys.version_info
+        return '%d.%d' % (ver.major, ver.minor)
+
     @property
     def arch_name(self):
         m = machine()
diff --git a/conda/config.py b/conda/config.py
--- a/conda/config.py
+++ b/conda/config.py
@@ -106,5 +106,5 @@ def get_rc_path():
 
 
 # put back because of conda build
-default_python = context. default_python
+default_python = context.default_python
 binstar_upload = context.binstar_upload


Test patch: