internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spack/spack

Issue:
libpciaccess build problem
I cannot build libpciaccess. Spack uses a non-released version that doesn't have a `configure` script. It fails to create the script since the `xorg-macros` are not installed on the system:

```
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
configure.ac:39: error: must install xorg-macros 1.8 or later before running autoconf/autogen
configure.ac:39: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
```

One way around would be to create a `configure` script somewhere, and add it to libpciaccess as patch. Configure scripts are portable.



Discussion:

Resolving patch:
diff --git a/var/spack/packages/libpciaccess/package.py b/var/spack/packages/libpciaccess/package.py
--- a/var/spack/packages/libpciaccess/package.py
+++ b/var/spack/packages/libpciaccess/package.py
@@ -5,12 +5,10 @@ class Libpciaccess(Package):
     """Generic PCI access library."""
 
     homepage = "http://cgit.freedesktop.org/xorg/lib/libpciaccess/"
-    url      = "http://cgit.freedesktop.org/xorg/lib/libpciaccess/"
+    url      = "http://xorg.freedesktop.org/archive/individual/lib/libpciaccess-0.13.4.tar.bz2"
 
-    version('0.13.4', git='http://anongit.freedesktop.org/git/xorg/lib/libpciaccess.git',
-            tag='libpciaccess-0.13.4')
+    version('0.13.4', 'ace78aec799b1cf6dfaea55d3879ed9f')
 
-    depends_on('autoconf')
     depends_on('libtool')
 
     def install(self, spec, prefix):
@@ -20,9 +18,6 @@ def install(self, spec, prefix):
             mkdir(prefix.lib)
             return
 
-        from subprocess import call
-        call(["./autogen.sh"])
         configure("--prefix=%s" % prefix)
-
         make()
         make("install")


Test patch:
Repository: spack/spack

Issue:
Cannot install Boost on Darwin -- file name too long
Installing Boost on Darwin aborts with this error:

```
Traceback (most recent call last):
  File "/Users/eschnett/src/spack/bin/spack", line 176, in <module>
    main()
  File "/Users/eschnett/src/spack/bin/spack", line 154, in main
    return_val = command(parser, args)
  File "/Users/eschnett/src/spack/lib/spack/spack/cmd/install.py", line 81, in install
    fake=args.fake)
  File "/Users/eschnett/src/spack/lib/spack/spack/package.py", line 958, in do_install
    spack.hooks.post_install(self)
  File "/Users/eschnett/src/spack/lib/spack/spack/hooks/__init__.py", line 69, in __call__
    hook(pkg)
  File "/Users/eschnett/src/spack/lib/spack/spack/hooks/dotkit.py", line 30, in post_install
    dk.write()
  File "/Users/eschnett/src/spack/lib/spack/spack/modules.py", line 161, in write
    with open(self.file_name, 'w') as f:
IOError: [Errno 63] File name too long: '/Users/eschnett/src/spack/share/spack/dotkit/darwin-x86_64/boost@1.60.0%gcc@5.3.0-clang-apple-7.0.2+atomic+chrono+date_time~debug+filesystem+graph~icu_support+iostreams+locale+log+math+mpi+multithreaded+program_options~python+random+regex+serialization+shared+signals+singlethreaded+system+test+thread+wave-2y4ny2g.dk'
```



Discussion:
Ping?

This problem was introduced in the recent change to Boost that turned each sub-library into a variant. Can we temporarily revert this change, until Spack uses shorter file names?

This long name for boost also causes a buffer overflow in 
/usr/bin/modulecmd 
on SL6. The installed version is
environment-modules-3.2.10-2.el6.x86_64


Resolving patch:
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -194,12 +194,14 @@ class Dotkit(EnvModule):
     @property
     def file_name(self):
         return join_path(Dotkit.path, self.spec.architecture,
-                         self.spec.format('$_$@$%@$+$#.dk'))
+                         '%s.dk' % self.use_name)
 
     @property
     def use_name(self):
-        return self.spec.format('$_$@$%@$+$#')
-
+      return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version,
+                                 self.spec.compiler.name,
+                                 self.spec.compiler.version, 
+                                 self.spec.dag_hash())
 
     def _write(self, dk_file):
         # Category
@@ -235,7 +237,10 @@ def file_name(self):
 
     @property
     def use_name(self):
-        return self.spec.format('$_$@$%@$+$#')
+      return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version,
+                                 self.spec.compiler.name,
+                                 self.spec.compiler.version, 
+                                 self.spec.dag_hash())
 
 
     def _write(self, m_file):


Test patch:
Repository: spack/spack

Issue:
Spack create crashes due to undefined variable
Here is the error message I get when trying to create a parallel-netcdf package:

``` bash
$ spack create http://cucis.ece.northwestern.edu/projects/PnetCDF/Release/parallel-netcdf-1.6.1.tar.gz
==> This looks like a URL for parallel-netcdf version 1.6.1.
==> Creating template for package parallel-netcdf
Traceback (most recent call last):
  File "/soft/spack/bin/spack", line 176, in <module>
    main()
  File "/soft/spack/bin/spack", line 154, in main
    return_val = command(parser, args)
  File "/blues/gpfs/home/software/spack/lib/spack/spack/cmd/create.py", line 259, in create
    versions, urls = fetch_tarballs(url, name, args)
  File "/blues/gpfs/home/software/spack/lib/spack/spack/cmd/create.py", line 225, in fetch_tarballs
    versions = { version : url }
NameError: global name 'version' is not defined
```



Discussion:
This appears to have been fixed.  Do you still see the problem @adamjstewart?

I do still see the problem. I just downloaded the latest development branch on a different computer and tried to `spack create` the same url and I still get the same exact error message. The create.py file hasn't been edited since I posted this issue so I don't see how it could've been fixed. Are you able to `spack create` with this specific url? There's nothing wrong with the path because I can wget it fine. Maybe there is something else going on here...


Resolving patch:
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -222,7 +222,7 @@ def fetch_tarballs(url, name, args):
     archives_to_fetch = 1
     if not versions:
         # If the fetch failed for some reason, revert to what the user provided
-        versions = { version : url }
+        versions = { "version" : url }
     elif len(versions) > 1:
         tty.msg("Found %s versions of %s:" % (len(versions), name),
                 *spack.cmd.elide_list(


Test patch:
Repository: spack/spack

Issue:
How to abort an install?
I was looking for a method to abort the `install` routine when an error is detected. I didn't find this described in the manual, and various packages seem to be using various methods:
- `tty.error(...)`
- `raise RunTimeError(...)`
- `raise InstallError(...)`
  I think none of these actually work the way they are intended, although they all do abort the install -- because the respective identifiers are not defined.



Discussion:
@eschnett: which one of these seems best to you?  I think for packagers it would be nice to just have an `abort()` function to call, and it could raise a subclass of `InstallError`... maybe `UserInstallError`?   The other use case I have for this is for external packages like CUDA that need placeholders, which would probably want another subclass like `ExternalInstallOnlyError` (notional name).

Thoughts? 

`raise InstallError(...)` seems best; it uses the regular Python way (`raise`), and `InstallError` sounds right.


Resolving patch:
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -189,5 +189,9 @@
 from spack.util.executable import *
 __all__ += spack.util.executable.__all__
 
-from spack.package import install_dependency_symlinks, flatten_dependencies, DependencyConflictError
-__all__ += ['install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError']
+from spack.package import \
+    install_dependency_symlinks, flatten_dependencies, DependencyConflictError, \
+    InstallError, ExternalPackageError
+__all__ += [
+    'install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError',
+    'InstallError', 'ExternalPackageError']
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1351,6 +1351,10 @@ def __init__(self, message, long_msg=None):
         super(InstallError, self).__init__(message, long_msg)
 
 
+class ExternalPackageError(InstallError):
+    """Raised by install() when a package is only for external use."""
+
+
 class PackageStillNeededError(InstallError):
     """Raised when package is still needed by another on uninstall."""
     def __init__(self, spec, dependents):


Test patch:
Repository: spack/spack

Issue:
Log output for how configure is called should use quotes
I'm trying to debug a build problem. I'm looking at the log file, which begins by listing the `configure` command. It's difficult to see exactly what options were given because these options contain spaces. Adding quotes to this log output would be better.

For example, instead of outputting

```
./configure --with-flags=a b c
```

I'd like to see

```
./configure --with-flags='a b c'
```



Discussion:

Resolving patch:
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -144,7 +144,7 @@ def streamify(arg, mode):
 
         cmd = self.exe + list(args)
 
-        cmd_line = ' '.join(cmd)
+        cmd_line = "'%s'" % "' '".join(map(lambda arg: arg.replace("'", "'\"'\"'"), cmd))
         tty.debug(cmd_line)
 
         try:


Test patch:
Repository: spack/spack

Issue:
spack does not pick up updated compilers
subj. When one updates XCode from 7.2.1. to 7.3. clang version changes accordingly. However, spack does not pick up those changes. Presumably because `compilers.yaml` is already created and available. If one removes the file and reruns `spack compilers`, then the new file with the correct version is generated.



Discussion:
If you just run `spack compiler add`, it will re-search.  Do you think `spack compilers` itself should redo the search?  We could also add a more explicit, clearer command for this, e.g. `spack compiler find`.

Thoughts?

i think i was a bit confused by description:

```
    list       list available compilers
```

which I interpreted as **available in the system**, whereas it means those which have been previously found by spack and thereby available to spack.

I think that `spack compiler find` is indeed a better subcommand that `add`. 

perhaps change to something along the lines

```
usage: spack compiler [-h] SUBCOMMAND

positional arguments:
  SUBCOMMAND
    find        Find compilers and add the results to the Spack configuration.
    remove (rm)
               Remove compiler by spec.
    list       list previously found compilers (default). When executed for the first time, find subcommand is invoked.
    info       Show compiler paths.

optional arguments:
  -h, --help   show this help message and exit
```

Seems like find could just be a synonym for `add`.  We could keep `add` as an alias.


Resolving patch:
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -44,10 +44,10 @@ def setup_parser(subparser):
 
     scopes = spack.config.config_scopes
 
-    # Add
-    add_parser = sp.add_parser('add', help='Add compilers to the Spack configuration.')
-    add_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
-    add_parser.add_argument('--scope', choices=scopes, default=spack.cmd.default_modify_scope,
+    # Find
+    find_parser = sp.add_parser('find', aliases=['add'], help='Search the system for compilers to add to the Spack configuration.')
+    find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
+    find_parser.add_argument('--scope', choices=scopes, default=spack.cmd.default_modify_scope,
                             help="Configuration scope to modify.")
 
     # Remove
@@ -70,7 +70,7 @@ def setup_parser(subparser):
                              help="Configuration scope to read from.")
 
 
-def compiler_add(args):
+def compiler_find(args):
     """Search either $PATH or a list of paths for compilers and add them
        to Spack's configuration."""
     paths = args.add_paths
@@ -136,7 +136,8 @@ def compiler_list(args):
 
 
 def compiler(parser, args):
-    action = { 'add'    : compiler_add,
+    action = { 'add'    : compiler_find,
+               'find'   : compiler_find,
                'remove' : compiler_remove,
                'rm'     : compiler_remove,
                'info'   : compiler_info,


Test patch:
Repository: spack/spack

Issue:
GMsh installation not fully contained with prefix
The installation paths for the GMsh binaries, tutorials etc. are not contained within the CMake installation path (see the end of [build.out](https://gist.github.com/jppelteret/24b7ef9c38ee10072c721bcc89872b7a)). The result is that the destination directory contains the `include` folder, while binaries sit in another folder one level down (`../MacOS`) and the tutorials and examples are somewhere else entirely (`opt/spack`).



Discussion:
Also, as a result of this, the binary directory is not loaded into path when `spack load gmsh` is called.

i think i know how to fix it, will try now...

@davydden Done already thanks!


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/gmsh/package.py b/var/spack/repos/builtin/packages/gmsh/package.py
--- a/var/spack/repos/builtin/packages/gmsh/package.py
+++ b/var/spack/repos/builtin/packages/gmsh/package.py
@@ -62,6 +62,9 @@ def install(self, spec, prefix):
 
         build_directory = join_path(self.stage.path, 'spack-build')
         source_directory = self.stage.source_path
+        
+        # Prevent GMsh from using its own strange directory structure on OSX
+        options.append('-DENABLE_OS_SPECIFIC_INSTALL=OFF')
 
         if '+shared' in spec:
             options.extend(['-DENABLE_BUILD_SHARED:BOOL=ON',


Test patch:
Repository: spack/spack

Issue:
Missing Feature : No Support for Default Compiler Flags in Compiler Config
After looking over PR #360 and its documentation in PR #989 more carefully, I found that the intended feature for specifying compiler flags in the `compilers.yaml` file is missing.  I was able to verify this by having something like the following in my `compilers.yaml` file:

```
compilers:
  chaos_5_x86_64_ib:
    gcc@4.7.2:
      ...
      cflags: -fPIC
      cppflags: -fPIC
      cxxflags: -fPIC
```

This inclusion caused an 'additional properties are not allowed ('cppflags', 'cxxflags', 'cflags' were unexpected)' error to occur when I attempted to install packages with this compiler.



Discussion:
one could also add `PIC` flags to compiler classes, similar to `cxx-11` and `openmp`.


Resolving patch:
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -167,6 +167,18 @@
                                                         {'type' : 'null' }]},
                                     'fc':  { 'anyOf': [ {'type' : 'string' },
                                                         {'type' : 'null' }]},
+                                    'fflags':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
+                                    'cppflags':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
+                                    'cflags':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
+                                    'cxxflags':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
+                                    'ldflags':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
+                                    'ldlibs':  { 'anyOf': [ {'type' : 'string' },
+                                                        {'type' : 'null' }]},
                                 },},},},},},},},
 
     'mirrors': {


Test patch:
Repository: spack/spack

Issue:
Path name in output is badly formatted
I see this output from Spack:

```
SPACK_SHORT_SPEC=hdf5-blosc@master%gcc@6.1.0-spack arch=darwin-x86_64-2vj6sge
==> Warning: Keeping install prefix in place despite error.
  Spack will think this package is installed. Manually remove this
  directory to fix:
  /Users/eschnett/src/spack/opt/spack/darwin-
  x86_64/gcc-6.1.0-spack/hdf5-blosc-master-
  2vj6sge7werlurxr57qij5zaqa3k5idj
```

Note the many line breaks. I might understand a line break in the "Spack will think" message (although it's not necessary since the line is so short), but breaking a path name over multiple lines is both confusing and inconvenient. For example, this makes it impossible to copy and paste.



Discussion:

Resolving patch:
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py
--- a/lib/spack/llnl/util/tty/__init__.py
+++ b/lib/spack/llnl/util/tty/__init__.py
@@ -64,12 +64,14 @@ def info(message, *args, **kwargs):
     format = kwargs.get('format', '*b')
     stream = kwargs.get('stream', sys.stdout)
     wrap   = kwargs.get('wrap', False)
+    break_long_words = kwargs.get('break_long_words', False)
 
     cprint("@%s{==>} %s" % (format, cescape(str(message))), stream=stream)
     for arg in args:
         if wrap:
             lines = textwrap.wrap(
-                str(arg), initial_indent=indent, subsequent_indent=indent)
+                str(arg), initial_indent=indent, subsequent_indent=indent,
+                break_long_words=break_long_words)
             for line in lines:
                 stream.write(line + '\n')
         else:


Test patch:
Repository: spack/spack

Issue:
'which' helper method not defined 
Hello!

Is anyone else getting complaints about the `which` helper not being defined in build_environment.py? I am getting this when trying to build anything with the latest develop (e41d67e031aca9acabca) on Cray systems, but not on civilized systems.

```
Robert.French@gaea9 ~/Projects/spack $ spack install libpng %gcc@4.3.4 arch=cray_xc-SuSE11-ivybridge
==> Installing libpng
==> zlib is already installed in /autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/opt/spack/cray_xc-SuSE11-ivybridge/gcc-4.3.4/zlib-1.2.8-jblztzcconqyhj6bigfz4bh453zrjgoz
Traceback (most recent call last):
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/bin/spack", line 179, in <module>
    main()
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/bin/spack", line 157, in main
    return_val = command(parser, args)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/cmd/install.py", line 82, in install
    explicit=True)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/package.py", line 997, in do_install
    spack.build_environment.fork(self, build_process)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/build_environment.py", line 491, in fork
    setup_package(pkg)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/build_environment.py", line 431, in setup_package
    set_build_environment_variables(pkg, spack_env)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/build_environment.py", line 292, in set_build_environment_variables
    load_module(pkg.spec.architecture.target.module_name)
  File "/autofs/mnt/ncrc-svm1_home1/Robert.French/Projects/spack/lib/spack/spack/build_environment.py", line 123, in load_module
    modulecmd = which('modulecmd')
NameError: name 'which' is not defined
==> Error: Installation process had nonzero exit code : 256
```

It looks like build_environment.py:123 definitely invokes `which` without first importing it from `spack.util.executable`. I reckon this route through the code only gets used on Crays?



Discussion:

Resolving patch:
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -63,7 +63,7 @@
 import spack
 from spack.environment import EnvironmentModifications, validate
 from spack.util.environment import *
-from spack.util.executable import Executable
+from spack.util.executable import Executable, which
 
 #
 # This can be set by the user to globally disable parallel builds.


Test patch:
Repository: spack/spack

Issue:
[BUG] : spack test leaves references to builtin.mock in the db
What triggers the issue:

```
$ spack test
...
$ spack module refresh
==> Regenerating tcl module files.
==> Error: Unknown namespace: builtin.mock
```

The issue disappears after a:

```
$ spack reindex
```



Discussion:
Might be best if the tests use their own `opt/` directory.


Resolving patch:
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -165,7 +165,7 @@ def remove_install_directory(self, spec):
 class YamlDirectoryLayout(DirectoryLayout):
     """Lays out installation directories like this::
            <install root>/
-               <target>/
+               <platform-os-target>/
                    <compiler>-<compiler version>/
                        <name>-<version>-<variants>-<hash>
 


Test patch:
diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py
--- a/lib/spack/spack/test/install.py
+++ b/lib/spack/spack/test/install.py
@@ -28,6 +28,7 @@
 import spack
 from llnl.util.filesystem import *
 from spack.directory_layout import YamlDirectoryLayout
+from spack.database import Database
 from spack.fetch_strategy import URLFetchStrategy, FetchStrategyComposite
 from spack.test.mock_packages_test import *
 from spack.test.mock_repo import MockArchive
@@ -49,7 +50,10 @@ def setUp(self):
         # installed pkgs and mock packages.
         self.tmpdir = tempfile.mkdtemp()
         self.orig_layout = spack.install_layout
+        self.orig_db = spack.installed_db
+
         spack.install_layout = YamlDirectoryLayout(self.tmpdir)
+        spack.installed_db   = Database(self.tmpdir)
 
 
     def tearDown(self):
@@ -61,6 +65,7 @@ def tearDown(self):
 
         # restore spack's layout.
         spack.install_layout = self.orig_layout
+        spack.installed_db   = self.orig_db
         shutil.rmtree(self.tmpdir, ignore_errors=True)
 
 
@@ -71,7 +76,7 @@ def fake_fetchify(self, pkg):
         pkg.fetcher = fetcher
 
 
-    def ztest_install_and_uninstall(self):
+    def test_install_and_uninstall(self):
         # Get a basic concrete spec for the trivial install package.
         spec = Spec('trivial_install_test_package')
         spec.concretize()