Repository: spack/spack

Issue:
bash@4.3 ^readline@7.0 gives error: 
I am using the development branch + PR: 2548, 2972

```
[sfux@develop02 tools]$ spack find
==> 35 installed packages.
-- linux-centos7-x86_64 / gcc@4.8.5 -----------------------------
autoconf@2.69  coreutils@8.26  font-util@1.3.1  libpng@1.6.27       lua@5.3.2            ncurses@6.0   perl@5.24.1        tcl@8.6.6           xz@5.2.3
automake@1.15  curl@7.53.1     freetype@2.7     libsigsegv@2.11     lua-luaposix@33.4.0  patch@2.7.5   pkg-config@0.29.2  unzip@6.0           yasm@1.3.0
bison@3.0.4    dbus@1.11.2     libelf@0.8.13    libtool@2.4.6       m4@1.4.18            patchelf@0.9  readline@7.0       util-macros@1.19.1  zlib@1.2.11
bzip2@1.0.6    expat@2.2.0     libiconv@1.15    libunistring@0.9.7  mawk@1.3.4           pcre@8.40     tar@1.29           wget@1.17
```

```
[sfux@develop02 tools]$ spack install bash@4.3 ^readline@7.0
==> Installing bash
==> readline is already installed in /local/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/readline-7.0-p5j542rky6ftmlge27u2fk3m5hsbqn2w
==> Fetching https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
######################################################################## 100.0%
==> Staging archive: /local/cluster/spack/var/spack/stage/bash-4.3-hes7gbusu3hidnr6lwav6injj6b4gi3g/bash-4.3.tar.gz
==> Created stage in /local/cluster/spack/var/spack/stage/bash-4.3-hes7gbusu3hidnr6lwav6injj6b4gi3g
==> Ran patch() for bash
==> Building bash [Package]
==> Executing phase : 'install'
==> Error: ProcessError: Command exited with status 2:
```
```

/local/cluster/spack/lib/spack/env/gcc/gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/malloc -L./lib/sh  -rdynamic  -g -O2 -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o  dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o bashline.o  list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o pcomplib.o syntax.o xmalloc.o  -lbuiltins -lglob -lsh -lreadline -lhistory -lcurses -ltilde -lmalloc    -ldl
/usr/bin/ld: cannot find -lcurses
collect2: error: ld returned 1 exit status
```

bash spec:

```
    def install(self, spec, prefix):
        configure('--prefix=%s' % prefix,
                  '--with-curses',
                  '--with-installed-readline=%s' % spec['readline'].prefix)
```

It seems that the configure script ignores the specified readline:

```
checking for tgetent... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for tgetent in -lcurses... no
checking for tgetent in -lncurses... no
checking which library has the termcap functions... using gnutermcap
checking version of installed readline library... configure: WARNING: Could not test version of installed readline library.
configure: WARNING: installed readline library is too old to be linked with bash
configure: WARNING: using private bash version
```

config.log:
```

configure:5252: checking version of installed readline library
configure:5306: /local/cluster/spack/lib/spack/env/gcc/gcc -o conftest -g -O2 -I/local/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/readline-7.0-p5j542rky6ftmlge27u2fk3m5hsbqn2w/include   -L/local/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/readline-7.0-p5j542rky6ftmlge27u2fk3m5hsbqn2w/lib conftest.c  -lreadline -lcurses >&5
conftest.c: In function 'main':
conftest.c:60:3: warning: incompatible implicit declaration of built-in function 'exit' [enabled by default]
   exit(1);
   ^
/usr/bin/ld: cannot find -lcurses
collect2: error: ld returned 1 exit status
configure:5306: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "bash"
| #define PACKAGE_TARNAME "bash"
| #define PACKAGE_VERSION "4.3-release"
| #define PACKAGE_STRING "bash 4.3-release"
| #define PACKAGE_BUGREPORT "bug-bash@gnu.org"
| #define PACKAGE_URL ""
| #define USING_BASH_MALLOC 1
| #define ALIAS 1
| #define PUSHD_AND_POPD 1
| #define RESTRICTED_SHELL 1
| #define PROCESS_SUBSTITUTION 1
| #define PROMPT_STRING_DECODE 1
| #define SELECT_COMMAND 1
| #define HELP_BUILTIN 1
| #define ARRAY_VARS 1
| #define DPAREN_ARITHMETIC 1
| #define BRACE_EXPANSION 1
| #define COMMAND_TIMING 1
| #define EXTENDED_GLOB 1
| #define EXTGLOB_DEFAULT 0
| #define COND_COMMAND 1
| #define COND_REGEXP 1
| #define COPROCESS_SUPPORT 1
| #define ARITH_FOR_COMMAND 1
| #define NETWORK_REDIRECTIONS 1
| #define PROGRAMMABLE_COMPLETION 1
| #define DEBUGGER 1
| #define CASEMOD_ATTRS 1
| #define CASEMOD_EXPANSIONS 1
| #define GLOBASCII_DEFAULT 0
| #define MEMSCRAMBLE 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _ALL_SOURCE 1
| #define _GNU_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| /* end confdefs.h.  */
| 
| #include <stdio.h>
| #include <readline/readline.h>
| 
| extern int rl_gnu_readline_p;
| 
| main()
| {
|       FILE *fp;
|       fp = fopen("conftest.rlv", "w");
|       if (fp == 0)
|               exit(1);
|       if (rl_gnu_readline_p != 1)
|               fprintf(fp, "0.0\n");
|       else
|               fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
|       fclose(fp);
|       exit(0);
| }
| 
configure:5352: WARNING: Could not test version of installed readline library.
configure:5397: WARNING: installed readline library is too old to be linked with bash
configure:5399: WARNING: using private bash version
configure:5503: checking for a BSD-compatible install
```

Any idea ?

Should bash have a dependency ncurses, since it the speck contains the option --with-curses, or do you think it is because the readline library that is linked against ncurses is not recognized ?

Best regards

Sam


Discussion:
This is (kind of) my fault. `ncurses` has a couple different library types. There is the default library `libncurses.so` and there is a wide-encoding UTF-8 library for CJK support called `libncursesw.so` (notice the 'w'). We've always built the latter library, but we previously passed the `--disable-lib-suffixes` option so that the libraries would be named without the 'w'. This broke the `htop` package which only looks for `libncursesw.so`, so I removed this flag. This is the way that Homebrew does it and the way that the developers recommend. But it seems that `readline` or `bash` is still looking for the no-w library. We have two options here. We can either add a flag like `LIBS=-lncursesw` to the configure line or we can add a variant to `ncurses` to dictate whether or not we build with wide encoding support.
@adamjstewart: Thank you for your reply. Sorry for opening so many issues and thank you for the great work that you and the other spack developers do.

I hope that I can also contribute to the project once I am more used to work with git and spack.

For the moment, I will try to edit the bash package and add LIBS=-lncursesw to the configure line to see if this fixes the problem.
I'll test things too since I kind of feel responsible. Btw, I've been having a lot of problems with the readline library in regards to Python, so maybe the two are related. See #3269.
I think `LIBS=-lncursesw` solved the problem. Tests passed for me as well. I'll send out a PR shortly.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/bash/package.py b/var/spack/repos/builtin/packages/bash/package.py
--- a/var/spack/repos/builtin/packages/bash/package.py
+++ b/var/spack/repos/builtin/packages/bash/package.py
@@ -25,21 +25,27 @@
 from spack import *
 
 
-class Bash(Package):
+class Bash(AutotoolsPackage):
     """The GNU Project's Bourne Again SHell."""
 
     homepage = "https://www.gnu.org/software/bash/"
-    url      = "https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz"
+    url      = "https://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz"
 
+    version('4.4', '148888a7c95ac23705559b6f477dfe25')
     version('4.3', '81348932d5da294953e15d4814c74dd1')
 
-    depends_on('readline')
+    depends_on('ncurses')
+    depends_on('readline@5.0:')
 
-    def install(self, spec, prefix):
-        configure('--prefix=%s' % prefix,
-                  '--with-curses',
-                  '--with-installed-readline=%s' % spec['readline'].prefix)
+    def configure_args(self):
+        spec = self.spec
 
-        make()
-        make("tests")
-        make("install")
+        return [
+            'LIBS=-lncursesw',
+            '--with-curses',
+            '--enable-readline',
+            '--with-installed-readline={0}'.format(spec['readline'].prefix),
+        ]
+
+    def check(self):
+        make('tests')


Test patch: