Repository: conda/conda

Issue:
conda create causes: AttributeError: 'dict' object has no attribute 'add'
Trying to clone the root environment with:

```
conda create --clone root --copy -n myenv2
```

Gives:

```
Traceback (most recent call last):
  File "/opt/miniconda/bin/conda", line 6, in <module>
    sys.exit(main())
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 120, in main
    exit_code = args_func(args, p)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 130, in args_func
    exit_code = args.func(args, p)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main_create.py", line 58, in execute
    install(args, parser, 'create')
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 223, in install
    clone(args.clone, prefix, json=args.json, quiet=args.quiet, index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 88, in clone
    index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/misc.py", line 360, in clone_env
    force_extract=False, index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/misc.py", line 109, in explicit
    channels.add(channel)
AttributeError: 'dict' object has no attribute 'add'

```

conda info:

```
             platform : linux-64
        conda version : 4.1.8
    conda-env version : 2.5.1
  conda-build version : 1.18.1
       python version : 2.7.12.final.0
     requests version : 2.10.0
     root environment : /opt/miniconda  (read only)
  default environment : /opt/miniconda
     envs directories : /home/wiecki/.conda/envs
                        /home/wiecki/envs
                        /opt/miniconda/envs
        package cache : /home/wiecki/.conda/envs/.pkgs
                        /home/wiecki/envs/.pkgs
                        /opt/miniconda/pkgs
         channel URLs : 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/
          config file : None
         offline mode : False
    is foreign system : False
```

conda create causes: AttributeError: 'dict' object has no attribute 'add'
Trying to clone the root environment with:

```
conda create --clone root --copy -n myenv2
```

Gives:

```
Traceback (most recent call last):
  File "/opt/miniconda/bin/conda", line 6, in <module>
    sys.exit(main())
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 120, in main
    exit_code = args_func(args, p)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 130, in args_func
    exit_code = args.func(args, p)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/main_create.py", line 58, in execute
    install(args, parser, 'create')
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 223, in install
    clone(args.clone, prefix, json=args.json, quiet=args.quiet, index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 88, in clone
    index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/misc.py", line 360, in clone_env
    force_extract=False, index_args=index_args)
  File "/opt/miniconda/lib/python2.7/site-packages/conda/misc.py", line 109, in explicit
    channels.add(channel)
AttributeError: 'dict' object has no attribute 'add'

```

conda info:

```
             platform : linux-64
        conda version : 4.1.8
    conda-env version : 2.5.1
  conda-build version : 1.18.1
       python version : 2.7.12.final.0
     requests version : 2.10.0
     root environment : /opt/miniconda  (read only)
  default environment : /opt/miniconda
     envs directories : /home/wiecki/.conda/envs
                        /home/wiecki/envs
                        /opt/miniconda/envs
        package cache : /home/wiecki/.conda/envs/.pkgs
                        /home/wiecki/envs/.pkgs
                        /opt/miniconda/pkgs
         channel URLs : 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/
          config file : None
         offline mode : False
    is foreign system : False
```



Discussion:
Same problem on Windows. Also encountered https://github.com/conda/conda/issues/3009

On Mac, it also has this bug. In the source code, channels is initialised as {}, and dict has no add() function. I change it to channels = () at line 51, and every thing is fine. 

Thanks for pointing out the bug

@kalefranz , this is a bug need to fix for conda 4.2 I think, and I will create a PR for that

Same problem on Windows. Also encountered https://github.com/conda/conda/issues/3009

On Mac, it also has this bug. In the source code, channels is initialised as {}, and dict has no add() function. I change it to channels = () at line 51, and every thing is fine. 

Thanks for pointing out the bug

@kalefranz , this is a bug need to fix for conda 4.2 I think, and I will create a PR for that


Resolving patch:
diff --git a/conda/misc.py b/conda/misc.py
--- a/conda/misc.py
+++ b/conda/misc.py
@@ -46,7 +46,7 @@ def explicit(specs, prefix, verbose=False, force_extract=True, index_args=None,
     index_args = index_args or {}
     index = index or {}
     verifies = []
-    channels = {}
+    channels = set()
     for spec in specs:
         if spec == '@EXPLICIT':
             continue
@@ -106,7 +106,7 @@ def explicit(specs, prefix, verbose=False, force_extract=True, index_args=None,
                     actions[RM_FETCHED].append(conflict)
                 if not is_local:
                     if fn not in index or index[fn].get('not_fetched'):
-                        channels.add(channel)
+                        channels.add(schannel)
                     verifies.append((dist + '.tar.bz2', md5))
                 actions[FETCH].append(dist)
             actions[EXTRACT].append(dist)
@@ -122,7 +122,7 @@ def explicit(specs, prefix, verbose=False, force_extract=True, index_args=None,
         index_args = index_args or {}
         index_args = index_args.copy()
         index_args['prepend'] = False
-        index_args['channel_urls'] = channels
+        index_args['channel_urls'] = list(channels)
         index.update(get_index(**index_args))
 
     # Finish the MD5 verification


Test patch: