Repository: conda/conda

Issue:
Cannot install conda-build 3.2.0
@AntoineD commented on [Fri Dec 22 2017](https://github.com/conda/conda-build/issues/2600)

Hello,

I am on a REHL 5.5 with anaconda 4.4, I was able to install recent version of conda-build by [hand ](https://github.com/conda/conda-build/issues/2450#issuecomment-337625349) but with the version 3.2.0 it fails:
```
 conda install /scratch/xxx/anaconda/pkgs/conda-build-3.2.0-py27_0.tar.bz2
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues



Current conda install:

               platform : linux-64
          conda version : 4.3.25
       conda is private : False
      conda-env version : 4.3.25
    conda-build version : 3.1.3
         python version : 2.7.13.final.0
       requests version : 2.14.2
       root environment : /scratch/xxx/anaconda  (writable)
    default environment : /scratch/xxx/anaconda
       envs directories : /scratch/xxx/conda-envs
                          /scratch/xxx/anaconda/envs
                          /home/xxx/.conda/envs
          package cache : /scratch/xxx/anaconda/pkgs
                          /home/xxx/.conda/pkgs
           channel URLs : file:///scratch/xxx/conda-bld/linux-64
                          file:///scratch/xxx/conda-bld/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
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
            config file : /home/xxx/.condarc
             netrc file : None
           offline mode : False
             user-agent : conda/4.3.25 requests/2.14.2 CPython/2.7.13 Linux/2.6.18-422.el5 Red Hat Enterprise Linux Server/5.11 glibc/2.5
                UID:GID : 7679:107679

`$ /scratch/xxx/anaconda/bin/conda install /scratch/xxx/anaconda/pkgs/conda-build-3.2.0-py27_0.tar.bz2`


    Traceback (most recent call last):
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 640, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 140, in _main
        exit_code = args.func(args, p)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main_install.py", line 80, in execute
        install(args, parser, 'install')
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/install.py", line 210, in install
        explicit(args_packages, prefix, verbose=not context.quiet)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/misc.py", line 110, in explicit
        execute_actions(actions, index, verbose=verbose)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/plan.py", line 830, in execute_actions
        execute_instructions(plan, index, verbose)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/instructions.py", line 247, in execute_instructions
        cmd(state, arg)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/instructions.py", line 107, in UNLINKLINKTRANSACTION_CMD
        txn = UnlinkLinkTransaction.create_from_dists(index, prefix, unlink_dists, link_dists)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/link.py", line 125, in create_from_dists
        for dist, pkg_dir in zip(link_dists, pkg_dirs_to_link))
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/link.py", line 125, in <genexpr>
        for dist, pkg_dir in zip(link_dists, pkg_dirs_to_link))
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/gateways/disk/read.py", line 95, in read_package_info
        paths_data=paths_data,
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 702, in __call__
        instance = super(EntityType, cls).__call__(*args, **kwargs)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 719, in __init__
        setattr(self, key, kwargs[key])
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 831, in __setattr__
        super(ImmutableEntity, self).__setattr__(attribute, value)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 424, in __set__
        instance.__dict__[self.name] = self.validate(instance, self.box(instance, val))
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 465, in validate
        raise ValidationError(getattr(self, 'name', 'undefined name'), val)
    ValidationError: Value for url cannot be None.
```
Is it expected?

---

@msarahan commented on [Fri Dec 22 2017](https://github.com/conda/conda-build/issues/2600#issuecomment-353633731)

This is a conda issue.  Installing packages from files as you are doing makes the installation much less standard - it doesn't install dependencies, for example.  Something is definitely going wrong, but the conda issue tracker is the better place to discuss what it might be.  I'll move this issue for you.




Discussion:
Not sure what the problem is yet.   Something isn't quite right.  Even if we do come up with a patch, after conda 4.3.27, you're going to pull in https://repo.continuum.io/pkgs/main by default, which is NOT compatible with CentOS 5.

To stay compatible with CentOS 5, in a condarc file, you're going to want:

```
default_channels:
  - https://repo.continumm.io/pkgs/free
  - https://repo.continumm.io/pkgs/pro
  - https://repo.continumm.io/pkgs/r
```

After you do that, try in your condarc

```
channels:
  - conda-canary
  - defaults
  - conda-forge
```

and `conda update conda`.  See if it's still a problem in the latest conda.
Hello,
I followed your instructions (this has updated to conda 4.4.6 and pycosat 0.6.3) and then get the error when installing manually conda-build:
```
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 724, in __call__
        return func(*args, **kwargs)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 78, in _main
        exit_code = do_call(args, p)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 76, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main_install.py", line 11, in execute
        install(args, parser, 'install')
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/install.py", line 173, in install
        explicit(args_packages, prefix, verbose=not context.quiet)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/misc.py", line 69, in explicit
        pfe.execute()
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 553, in execute
        self.prepare()
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/common/io.py", line 415, in decorated
        return f(*args, **kwds)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 540, in prepare
        for prec in self.link_precs)
      File "/scratch/xxx/anaconda/lib/python2.7/_abcoll.py", line 571, in update
        for key, value in other:
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 540, in <genexpr>
        for prec in self.link_precs)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 449, in make_actions_for_record
        ), None)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 446, in <genexpr>
        pcrec for pcrec in concat(pcache.query(pref_or_spec)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/package_cache.py", line 115, in <genexpr>
        if param.match(pcrec))
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/models/match_spec.py", line 207, in match
        if not self._match_individual(rec, field_name, v):
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/models/match_spec.py", line 212, in _match_individual
        val = getattr(record, field_name)
      File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 414, in __get__
        raise AttributeError("A value for {0} has not been set".format(self.name))
    AttributeError: A value for url has not been set```
```

Thanks.
  
I tried from brand new anaconda installation ( 4.4 installation + your .condarc modification + conda update --all): there is no error in this situation.
You may close this issue.
The error came back while trying to update another package, it turned out that conda-build was the culprit.
From the error report I felt like hand installing it implied a lack of information (such as channel and plaftorm) for this installed package. So I created a local channel with the downloaded conda-build archive (and with `conda index /path/to/local/channel/{noarch,linux-64}`), re-installed it and apparently all is OK now.

Is hand installation (`conda install /path/to/package.tar.bz2`) still supported?
> Is hand installation (`conda install /path/to/package.tar.bz2`) still supported?

Yes.  If that's not working for you, definitely give more details.

Also though, please make sure you're using 4.4.7 (just released today).  It has one fix that may be applicable.
  
My issue looks like #6665, I will check conda 4.4.7 but I do not know when.
Anyway I prefer using a local channel for this because the dependencies are installed.
You may close that issue.
Thanks for your help.
@AntoineD even with conda 4.4.7, I'm still seeing some KeyError reports.  See https://github.com/conda/conda/issues/6698

If you still have your issue with conda 4.4.7, I want to make sure we get it resolved.  #6665 is closed as fixed, but there must be something else that's related going on.  Maybe we have a way to reproduce it with something you're doing.
I've just tested: issue is gone with conda 4.4.7.
@kalefranz  I've hit the same problem today (edit: this one: https://github.com/conda/conda/issues/6537#issuecomment-354992368; `AttributeError: A value for url has not been set`), after debugging into conda it turns out for me this is due to what seems to me a packaging glitch in an old `ssl_match_hostname` package that I had lying around in my `anaconda/pkgs` directory:

Looks like for whatever reason that package has the `url` field in the `repodata_record.json` missing:

`ssl_match_hostname-3.4.0.2-py27_1/info/repodata_record.json`

```json

{
  "arch": "x86_64",
  "build": "py27_0",
  "build_number": 0,
  "channel": "",
  "constrains": [],
  "depends": [
    "python 2.7*"
  ],
  "fn": "ssl_match_hostname-3.4.0.2-py27_0",
  "name": "ssl_match_hostname",
  "platform": "linux",
  "subdir": "linux-64",
  "version": "3.4.0.2"
}
```

This is comparing it with build no. 1:
```diff
--- ssl_match_hostname-3.4.0.2-py27_0/info/repodata_record.json	2018-01-18 17:50:07.533885592 +0100
+++ ssl_match_hostname-3.4.0.2-py27_1/info/repodata_record.json	2018-01-18 17:50:07.533885592 +0100
@@ -1,15 +1,18 @@
 {
   "arch": "x86_64",
-  "build": "py27_0",
-  "build_number": 0,
-  "channel": "",
+  "build": "py27_1",
+  "build_number": 1,
+  "channel": "https://repo.continuum.io/pkgs/free",
   "constrains": [],
   "depends": [
+    "backports",
     "python 2.7*"
   ],
-  "fn": "ssl_match_hostname-3.4.0.2-py27_0",
+  "fn": "ssl_match_hostname-3.4.0.2-py27_1.tar.bz2",
+  "license": "PSF",
   "name": "ssl_match_hostname",
   "platform": "linux",
   "subdir": "linux-64",
+  "url": "https://repo.continuum.io/pkgs/free/linux-64/ssl_match_hostname-3.4.0.2-py27_1.tar.bz2",
   "version": "3.4.0.2"
 }
\ No newline at end of file
```

After moving those (unpacked) packages out from `../pkgs/` I can run the failing `$ conda install <path_to_local_conda_package>` without problems.

So I guess maybe there should be a more friendly warning message about what package is causing the problem, so that users can get rid of the offending malformed package.

Resolving patch:
diff --git a/conda/models/index_record.py b/conda/models/index_record.py
--- a/conda/models/index_record.py
+++ b/conda/models/index_record.py
@@ -122,11 +122,8 @@ def __get__(self, instance, instance_type):
         try:
             return super(ChannelField, self).__get__(instance, instance_type)
         except AttributeError:
-            try:
-                url = instance.url
-                return self.unbox(instance, instance_type, Channel(url))
-            except AttributeError:
-                return Channel(None)
+            url = instance.url
+            return self.unbox(instance, instance_type, Channel(url))
 
 
 class SubdirField(StringField):
@@ -224,7 +221,7 @@ class PackageRef(BasePackageRef):
     fn = FilenameField(aliases=('filename',))
 
     md5 = StringField(default=None, required=False, nullable=True, default_in_dump=False)
-    url = StringField(required=False, nullable=True)
+    url = StringField(default=None, required=False, nullable=True, default_in_dump=False)
 
     @property
     def schannel(self):


Test patch: