Repository: spack/spack

Issue:
Installation issue: ncurses
### Steps to reproduce the issue

```console
$ git clone https://github.com/llnl/spack.git spack-git
$ cd spack-git

# When this is set, the ncurses install will go here instead of under
# the spack installation directory
$ export TERMINFO=/tmp/terminfo_user_dir

# Nothing in either location yet before the install
$ ls -ld $TERMINFO opt/spack/*/*/ncurses-6.1-*/share/terminfo
ls: cannot access /tmp/terminfo_user_dir: No such file or directory
ls: cannot access opt/spack/*/*/ncurses-6.1-*/share/terminfo: No such file or directory

$ bin/spack install ncurses
...
==> Successfully installed ncurses
  Fetch: 7.47s.  Build: 39.02s.  Total: 46.50s.
[+] /home/watson30/src/personal/src/spack/spack-git/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/ncurses-6.1-wkyck363aqihprfuuiipgdmzt6vjk6nk

# Database installed in the wrong location
$ ls -ld $TERMINFO opt/spack/*/*/ncurses-6.1-*/share/terminfo
ls: cannot access opt/spack/*/*/ncurses-6.1-*/share/terminfo: No such file or directory
drwxr-xr-x 44 watson30 watson30 4096 May  3 16:49 /tmp/terminfo_user_dir
```

### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux auk120.llnl.gov 3.10.0-957.5.1.el7.x86_64 #1 SMP Wed Dec 19 10:46:58 EST 2018 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -d
Description:    Red Hat Enterprise Linux Workstation release 7.6 (Maipo)
``` 

### Additional information

I recommend unsetting the TERMINFO environment variable for the ncurses package, so it installs its terminfo database under its installation directory.


Discussion:
Spack is designed to install things in its own directory, one root tree per package.  It is NOT designed to install things in system-set locations.  I'm closing this issue because it's not a bug.  There are many advantages, fundamental to the design of Spack, in doing things the way Spack does them.
I agree with all of that.  I thought that is what I said. The bug is that Spack is NOT installing in its own directory.  Instead, it is using the directory given in the TERMINFO environment variable.  Surely there is a way in the ncurses spack package to unset that environment variable before compilation, so that the resulting terminfo database is installed in the spack directory rather than in a system or user-specified directory.
Yes by all means, if an env variable is giving problems, you should consider un-setting it in the Spack package.  See here; and grep through the code for real-world examples:

https://spack.readthedocs.io/en/latest/tutorial_advanced_packaging.html#modifying-a-package-s-build-environment


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/ncurses/package.py b/var/spack/repos/builtin/packages/ncurses/package.py
--- a/var/spack/repos/builtin/packages/ncurses/package.py
+++ b/var/spack/repos/builtin/packages/ncurses/package.py
@@ -33,6 +33,9 @@ class Ncurses(AutotoolsPackage):
     patch('patch_gcc_5.txt', when='@6.0%gcc@5.0:')
     patch('sed_pgi.patch',   when='@:6.0')
 
+    def setup_environment(self, spack_env, run_env):
+        spack_env.unset('TERMINFO')
+
     def configure(self, spec, prefix):
         opts = [
             'CFLAGS={0}'.format(self.compiler.pic_flag),


Test patch: