Repository: spack/spack

Issue:
intel parallel studio professional 2017.4 failing to install
Hi all,
I was trying to install Intel parallel studio professional 2017.4, with spack and I am getting the following error:
```bash
==> Fetching file:///CEDAR/group/hpc/Software/intel-parallel-studio/intel-parallel-studio-professional.2017.4.tgz
######################################################################## 100.0%
==> Staging archive: /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/stage/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/parallel_studio_xe_2017_update4.tgz
==> Created stage in /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/stage/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf
==> No patches needed for intel-parallel-studio
==> Building intel-parallel-studio [IntelPackage]
==> Found already existing license /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/etc/spack/licenses/intel/license.lic
==> Executing phase : 'configure'
==> Executing phase : 'install'
==> Error: IOError: [Errno 2] No such file or directory: '/prod/acs/spack_prod/spack/linux-centos7-x86_64/intel-17.0.4/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/../../../../../../../ROWAN/group/prod/LINUX_WORKSTATION/acs/spack_prod/spack/linux-centos7-x86_64/intel-17.0.4/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/compilers_and_libraries_2017.4.196/linux/bin/intel64/icc.cfg'
/ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/repos/builtin/packages/intel-parallel-studio/package.py:415, in rpath_configuration:
     406      @run_after('install')
     407      def rpath_configuration(self):
     408          spec = self.spec
     409  
     410          if '+rpath' in spec:
     411              lib_dir = os.path.join(self.prefix, self.lib_dir)
     412              for compiler in ['icc', 'icpc', 'ifort']:
     413                  cfgfilename = os.path.join(
     414                      self.prefix, self.bin_dir, '{0}.cfg'.format(compiler))
  >> 415                  with open(cfgfilename, 'w') as f:
     416                      f.write('-Xlinker -rpath -Xlinker {0}\n'.format(lib_dir))

See build log for details:
  /local/cjn/.spack/var/spack/stage/spack-stage/spack-stage-NYw4d9/parallel_studio_xe_2017_update4/spack-build.out
```
output and env files are attached.
Any ideas anyone?

cheers,
Chris
(spack downloaded from git on 17th August)

[spack-build.out.txt](https://github.com/LLNL/spack/files/1245617/spack-build.out.txt)
[silent.cfg.txt](https://github.com/LLNL/spack/files/1245616/silent.cfg.txt)
[spack-build.env.txt](https://github.com/LLNL/spack/files/1245618/spack-build.env.txt)

intel parallel studio professional 2017.4 failing to install
Hi all,
I was trying to install Intel parallel studio professional 2017.4, with spack and I am getting the following error:
```bash
==> Fetching file:///CEDAR/group/hpc/Software/intel-parallel-studio/intel-parallel-studio-professional.2017.4.tgz
######################################################################## 100.0%
==> Staging archive: /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/stage/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/parallel_studio_xe_2017_update4.tgz
==> Created stage in /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/stage/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf
==> No patches needed for intel-parallel-studio
==> Building intel-parallel-studio [IntelPackage]
==> Found already existing license /ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/etc/spack/licenses/intel/license.lic
==> Executing phase : 'configure'
==> Executing phase : 'install'
==> Error: IOError: [Errno 2] No such file or directory: '/prod/acs/spack_prod/spack/linux-centos7-x86_64/intel-17.0.4/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/../../../../../../../ROWAN/group/prod/LINUX_WORKSTATION/acs/spack_prod/spack/linux-centos7-x86_64/intel-17.0.4/intel-parallel-studio-professional.2017.4-hgzj4lg3d3cfr5hy3s75x2t7vywqgwtf/compilers_and_libraries_2017.4.196/linux/bin/intel64/icc.cfg'
/ROWAN/group/prod/LINUX_WORKSTATION/acs/spack/var/spack/repos/builtin/packages/intel-parallel-studio/package.py:415, in rpath_configuration:
     406      @run_after('install')
     407      def rpath_configuration(self):
     408          spec = self.spec
     409  
     410          if '+rpath' in spec:
     411              lib_dir = os.path.join(self.prefix, self.lib_dir)
     412              for compiler in ['icc', 'icpc', 'ifort']:
     413                  cfgfilename = os.path.join(
     414                      self.prefix, self.bin_dir, '{0}.cfg'.format(compiler))
  >> 415                  with open(cfgfilename, 'w') as f:
     416                      f.write('-Xlinker -rpath -Xlinker {0}\n'.format(lib_dir))

See build log for details:
  /local/cjn/.spack/var/spack/stage/spack-stage/spack-stage-NYw4d9/parallel_studio_xe_2017_update4/spack-build.out
```
output and env files are attached.
Any ideas anyone?

cheers,
Chris
(spack downloaded from git on 17th August)

[spack-build.out.txt](https://github.com/LLNL/spack/files/1245617/spack-build.out.txt)
[silent.cfg.txt](https://github.com/LLNL/spack/files/1245616/silent.cfg.txt)
[spack-build.env.txt](https://github.com/LLNL/spack/files/1245618/spack-build.env.txt)



Discussion:
Same issue for me :( I think issue is coming from symlink mess. 

On one of the new machine where I am setting spack, I can cd into directory: 

```
○ → cd /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/
○ → pwd
/gpfs/bbp.cscs.ch/tds/home/kumbhar
```

But if I can't create file using that path:

```
○ → touch /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/a.txt

touch: cannot touch ‘/gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/a.txt’: No such file or directory
```

and hence (may be) spack installation fails with an error : 
```
/gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64/icc.cfg
```
Ok, I think I see the issue:

I see following path during installation:

```
 → cd /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64
```

which is actually : 

```
○ → pwd
/gpfs/bbp.cscs.ch/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel6
```

using `os.path.realpath` get : 

```
>>> os.path.realpath(path)
'/gpfs/bbp.cscs.ch/tds/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64'
```
which doesn't exist (see `/tds/tds/`). With `abspath`:

```
>>> os.path.abspath(path)
'/gpfs/bbp.cscs.ch/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64'
```
is the correct one. Need to take abspath of [cfgfilename](https://github.com/spack/spack/blob/1f731cd787cafdc35411c6c3a4297f56e8bce53e/var/spack/repos/builtin/packages/intel-parallel-studio/package.py#L434): 

```
cfgfilename = os.path.join(self.prefix, self.bin_dir, '{0}.cfg'.format(compiler))
```

@alalazo @adamjstewart ?
Same issue for me :( I think issue is coming from symlink mess. 

On one of the new machine where I am setting spack, I can cd into directory: 

```
○ → cd /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/
○ → pwd
/gpfs/bbp.cscs.ch/tds/home/kumbhar
```

But if I can't create file using that path:

```
○ → touch /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/a.txt

touch: cannot touch ‘/gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/a.txt’: No such file or directory
```

and hence (may be) spack installation fails with an error : 
```
/gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64/icc.cfg
```
Ok, I think I see the issue:

I see following path during installation:

```
 → cd /gpfs/bbp.cscs.ch/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/../../../../../../../../../../tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64
```

which is actually : 

```
○ → pwd
/gpfs/bbp.cscs.ch/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel6
```

using `os.path.realpath` get : 

```
>>> os.path.realpath(path)
'/gpfs/bbp.cscs.ch/tds/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64'
```
which doesn't exist (see `/tds/tds/`). With `abspath`:

```
>>> os.path.abspath(path)
'/gpfs/bbp.cscs.ch/tds/home/kumbhar/WORKSPACE/SPACK_DEPLOYMENT/install/compilers/install/linux-rhel7-x86_64/gcc-4.8.5/intel-parallel-studio-professional.2018.1/compilers_and_libraries_2018.1.163/linux/bin/intel64'
```
is the correct one. Need to take abspath of [cfgfilename](https://github.com/spack/spack/blob/1f731cd787cafdc35411c6c3a4297f56e8bce53e/var/spack/repos/builtin/packages/intel-parallel-studio/package.py#L434): 

```
cfgfilename = os.path.join(self.prefix, self.bin_dir, '{0}.cfg'.format(compiler))
```

@alalazo @adamjstewart ?

Resolving patch:
diff --git a/lib/spack/spack/hooks/licensing.py b/lib/spack/spack/hooks/licensing.py
--- a/lib/spack/spack/hooks/licensing.py
+++ b/lib/spack/spack/hooks/licensing.py
@@ -157,6 +157,7 @@ def symlink_license(pkg):
     target = pkg.global_license_file
     for filename in pkg.license_files:
         link_name = join_path(pkg.prefix, filename)
+        link_name = os.path.abspath(link_name)
         license_dir = os.path.dirname(link_name)
         if not os.path.exists(license_dir):
             mkdirp(license_dir)
diff --git a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
--- a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
+++ b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
@@ -433,6 +433,7 @@ def rpath_configuration(self):
             for compiler in ['icc', 'icpc', 'ifort']:
                 cfgfilename = os.path.join(
                     self.prefix, self.bin_dir, '{0}.cfg'.format(compiler))
+                cfgfilename = os.path.abspath(cfgfilename)
                 with open(cfgfilename, 'w') as f:
                     f.write('-Xlinker -rpath -Xlinker {0}\n'.format(lib_dir))
 
@@ -443,7 +444,7 @@ def fix_psxevars(self):
 
         bindir = glob.glob(join_path(
             self.prefix, 'parallel_studio*', 'bin'))[0]
-
+        bindir = os.path.abspath(bindir)
         if self.version[1] > 2016:
             filter_file('^SCRIPTPATH=.*', 'SCRIPTPATH={0}'.format(self.prefix),
                         os.path.join(bindir, 'psxevars.sh'),


Test patch: