Repository: spack/spack

Issue:
r-cairo installation fails
Hi,

I am trying to install all R packages from spack in an environment. I can install most of them properly, but `r-cairo` and others dependent on this one fail.


Then I proceed to install packages and get the following for `r-cairo`:
```sh
spack -d install
...
  >> 147    xlib-backend.c:34:10: fatal error: X11/Intrinsic.h: No such file or directory
     148       34 | #include <X11/Intrinsic.h>      /*->    Xlib.h  Xutil.h Xresource.h .. */
     149          |          ^~~~~~~~~~~~~~~~~
     150    compilation terminated.
  >> 151    make: *** [xlib-backend.o] Error 1
     152    make: *** Waiting for unfinished jobs....
     153    ERROR: compilation failed for package 'Cairo'

...
```

### Information on my system

```sh
$ spack debug report
* **Spack:** 0.16.1-1621-e9c399110e
* **Python:** 3.6.8
* **Platform:** linux-centos7-cascadelake
* **Concretizer:** original
```
### Additional information
My environment config file looks like this:
```yaml
spack:
  # add package specs to the `specs` list
  #concretization: separately
  concretization: together
  packages:
    all:
      compiler:
      - gcc@10.2.0
      target:
      - linux-centos7-x86_64
    r:
      version:
      - 4.0.4
      variants: +X+rmath
    cairo:
      version:
      - 1.16.0
      variants: +X+fc+ft+gobject+pdf+png
    harfbuzz:
      version:
      - 2.6.8
      variants: +graphite2
    proj:
      version:
      - 7.2.1
  view: true
  specs:
  - r-...
  - ...
```

- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have searched the issues of this repo and believe this is not a duplicate
- [x] I have run the failing commands in debug mode and reported the output



Discussion:
I can build `r-cairo` with your specs outside of an environment.
```console
spack install r-cairo%gcc@10.2.0 ^r@4.0.4 +X+rmath ^cairo +X+fc+ft+gobject+pdf+png
```
Your environment snippet indicates that other packages are installed and I suspect that the problem is from
```yaml
  concretization: together
```
with something else in the environment causing the problem. You might be able to track this down by setting 
```yaml
  concretization: separately
```
If you force reconcretization and install you might be able to see what the culprit is as you will see "duplicate" packages that probably have different requirements. There may be a better way to do that but that is what comes to mind. 
My ultimate goal is to install R and all its packages from spack in a single environment. The downside of concretizing separately is I can get multiple R installations (multiple r@4.0.4 indeed), but I need a single one. Otherwise I get packages depending on different R's, and cannot use them from a single R.
However, I can't understand why multiple r@4.0.4 become installed, since I'm specifying at `spack:packages:all:r` a concrete R version. Is there a way to force installing a single one r@4.0.4?

Thanks
It could be because something is requiring a different version or variant of something, anything really, in the dependency chain. You can use `spack spec` to evaluate those and try to come up with a set of constraints that you can put in a `packages.yaml` file or the `packages:` section of the environment's `spack.yaml`. Alternatively, you may want to try Spack's new concretizer.
> I can build `r-cairo` with your specs outside of an environment.
> 
> ```
> spack install r-cairo%gcc@10.2.0 ^r@4.0.4 +X+rmath ^cairo +X+fc+ft+gobject+pdf+png
> ```
> 
> Your environment snippet indicates that other packages are installed and I suspect that the problem is from
> 
> ```yaml
>   concretization: together
> ```
> 
> with something else in the environment causing the problem. You might be able to track this down by setting
> 
> ```yaml
>   concretization: separately
> ```
> 

> If you force reconcretization and install you might be able to see what the culprit is as you will see "duplicate" packages that probably have different requirements. There may be a better way to do that but that is what comes to mind.

I have tried to install r-cairo outside of the environment and after `spack clean -a`) and I still get the same error:
```
spack -d install r-cairo@1.5-12.2 %gcc@10.2.0 ^r@4.0.4 +X+rmath ^cairo@1.16.0 +X+fc+ft+gobject+pdf+png arch=linux-centos7-x86_64
```

[This is the full log.](https://github.com/spack/spack/files/6933124/out.log)

Could it be a GCC-related issue?

I do not think it is a GCC issue. I created a git branch from the commit level of your version from the `spack debug report` output, thinking that maybe something was off from that timeframe. However, I was still able to build `r-cairo`.

I am wondering though if there is something going on with system X11 packages. Do you have the `libXt-devel` RPM package installed? That package is installed on my system and I am wondering if this works for me because of that.
According to `yum info libXt*`, it seems only `libXt` and `libXtst` are installed on my system as RPM packages (they are also installed inside of the environment), but not `libXt-devel`.
After a quick search, everything points to the lack of `libXt-devel` as a cause for this issue. However, I cannot find it on spack repository. Is there any solution apart from installing it as RPM? (I have a bunch of compute nodes and would rather install it through Spack)
There is a spack package called `libxt` and it should be part of the spec for `r-cairo`, but pulled in by other dependencies. The idea is this should work without needing the system packages. Since I have that RPM installed, the build finds it, but that is not desired. Try adding
```
depends_on('libxt') 
```
to the r-cairo package and see if that helps.
That solved the issue.

Thanks!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/r-cairo/package.py b/var/spack/repos/builtin/packages/r-cairo/package.py
--- a/var/spack/repos/builtin/packages/r-cairo/package.py
+++ b/var/spack/repos/builtin/packages/r-cairo/package.py
@@ -31,5 +31,7 @@ class RCairo(RPackage):
     version('1.5-10', sha256='7837f0c384cd49bb3342cb39a916d7a80b02fffbf123913a58014e597f69b5d5')
     version('1.5-9', sha256='2a867b6cae96671d6bc3acf9334d6615dc01f6ecf1953a27cde8a43c724a38f4')
 
+    depends_on('r+X', type=('build', 'run'))
     depends_on('r@2.4.0:', type=('build', 'run'))
     depends_on('cairo@1.2:')
+    depends_on('libxt')


Test patch: