Repository: spack/spack

Issue:
Spack's default timeout is too short
Spack occasionally aborts a fetch too early when a url source is too slow.  I ran into this issue with util-macros on a busy night. 


### Steps to reproduce the issue

```console
$ spack install util-macros
```

### Steps that resolved the issue (workaround)

I edited spack/lib/spack/spack/fetch_strategy.py to increase the timeout to 1 minute from 10 seconds.  Ideally this should be configurable.

### Error Message


```console
==> Installing util-macros
==> Searching for binary cache of util-macros
==> No binary for util-macros found: installing from source
==> Fetching https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2

curl: (28) Operation timed out after 10001 milliseconds with 0 out of 0 bytes received
==> Failed to fetch file from URL: https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2
    Curl failed with error 28
==> Fetching from https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 failed.
==> Error: FetchError: All fetchers failed for spack-stage-util-macros-1.19.1-3khni2zc7qm6ruqeot3pbstb2lb36uhd

/blues/gpfs/home/underwoo/git/spack/lib/spack/spack/package.py:1110, in do_fetch:
       1107                raise FetchError("Will not fetch %s" %
       1108                                 self.spec.format('{name}{@version}'), ck_msg)
       1109
  >>   1110        self.stage.create()
       1111        self.stage.fetch(mirror_only)
       1112        self._fetch_time = time.time() - start_time
       1113
```


### Information on your system

I ran this on ANL's bebop, but also replicated it on Clemson's palmetto using spack's default configuration.

Eigen project is moving
The Eigen project is moving from Bitbucket to GitLab, and its Spack recipe will have to be updated accordingly.  See announcement below.


> Dear all,
> 
> following the decision of Bitbucket.org to delete all mercurial repositories next spring, we decided to migrate to a git repository hosted on gitlab.com. We also decided to take this opportunity to migrate our self hosted bugzilla instance to gitlab.com. Both migrations are scheduled on the 4th of December, starting at 8:00 UTC, and the new project:
> 
> https://gitlab.com/libeigen/eigen
> 
> will be made public once the migration is completed.
> 
> Details on the migration process:
> 
> - Our bugzilla (https://eigen.tuxfamily.org/bz/) will be made read only; all entries, comments and attachments will be transferred to gitlab.com while keeping the same bug IDs.
> 
> - https://bitbucket.org/eigen/eigen will be unavailable and replaced by an empty project pointing to https://gitlab.com/libeigen/eigen
> 
> - The old mercurial repository will still be readable on eigen.tuxfamily.org but with no updates.
> 
> - Existing pull-requests will be archived as static pages hosted on eigen.tuxfamily.org
> 
> - The official git mirror (https://github.com/eigenteam/eigen-git-mirror) will be kept as it is for a few months with no updates until we eventually replace it by an empty project pointing to https://gitlab.com/libeigen/eigen. (it cannot be synchronised because of hash differences)
> 
> Cheers,
> Gael
> 


unifyfs fails to build, unknown type 'MPI_Fint'
Package `unifyfs` fails to build on Ubuntu 18.04, x86_64 with Spack develop (e3b357ad87). The full spack-build-log is attached, but the error is shown below. I've tried with both `mpich` and `openmpi` -- same error either way.

Full build log: [unifyfs-build-out.txt](https://github.com/spack/spack/files/4276893/unifyfs-build-out.txt)

**Error:**
```
make[3]: Entering directory '/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/spack-build/client/src'
  CC       libunifyfs_la-margo_client.lo
  CC       libunifyfs_la-unifyfs.lo
  CC       libunifyfs_la-unifyfs-dirops.lo
  CC       libunifyfs_la-unifyfs-fixed.lo
  CC       libunifyfs_la-unifyfs-stack.lo
  CC       libunifyfs_la-unifyfs-stdio.lo
  CC       libunifyfs_la-unifyfs-sysio.lo
  CC       libunifyfs_la-pmpi_wrappers.lo
In file included from /tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/client/src/pmpi_wrappers.c:15:0:
/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/client/src/pmpi_wrappers.h:21:16: error: unknown type name 'MPI_Fint'
 void mpi_init_(MPI_Fint* ierr);
                ^~~~~~~~
/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/client/src/pmpi_wrappers.h:26:20: error: unknown type name 'MPI_Fint'
 void mpi_finalize_(MPI_Fint* ierr);
                    ^~~~~~~~
Makefile:646: recipe for target 'libunifyfs_la-pmpi_wrappers.lo' failed
make[3]: *** [libunifyfs_la-pmpi_wrappers.lo] Error 1
make[3]: Leaving directory '/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/spack-build/client/src'
Makefile:460: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/spack-build/client'
Makefile:490: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/walker/spack-stage/spack-stage-unifyfs-0.9.0-yqx3hsbr465azvv6lwnq7q5vp7r5st3p/spack-src/spack-build'
Makefile:400: recipe for target 'all' failed
make: *** [all] Error 2
```

@CamStan 


Discussion:
I also had this issue with libbsd today. In my case it worked on about the 10th try.
I also had this issue today with libffi and bzip2.
> I also had this issue today with libffi and bzip2.

For the record build tests on `develop` at https://github.com/spack/spack/commit/8d8925c725491cf028ef6c1b93e431dcb200f439 were failing because of that.
I just ran into the same problem and created a way to configure the timeout in PR #15212. Let me know whether this works for you as well.
I am a new user.  I am now encountering this issue as Spack cannot pull from bitbucket as per:

```terminal
==> No binary for eigen found: installing from source
==> Fetching https://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2

curl: (22) The requested URL returned error: 401 Unauthorized
==> Fetching from https://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2 failed.
==> Error: FetchError: All fetchers failed for spack-stage-eigen-3.3.7-rnuwo2wk73rcr3eqk7howzsna35i4ech

/opt/spack_toolchain/spack/lib/spack/spack/package.py:1079, in do_fetch:
       1076                raise FetchError("Will not fetch %s" %
       1077                                 self.spec.format('{name}{@version}'), ck_msg)
       1078
  >>   1079        self.stage.create()
       1080        self.stage.fetch(mirror_only)
       1081        self._fetch_time = time.time() - start_time
       1082
```

I have downloaded the tar.bz2 from the GitHub mirror.  Can I ask, how do I issue a spack install command point to a local tar file?
Thanks,
Andy
Can you update to the new URL in the `package.py` file, test that it works for you, and submit it as a PR?  That would be super!

Note the following additional news just came through on the Eigen email list:
```The critical steps of the migration are done. I've thus made public the new repo:

https://gitlab.com/libeigen/eigen

I've also re-opened the deprecated mercurial repo on bitbucket so that people can smoothly migrate their clones, links, etc.

Please report any outdated links and mercurial/bitbucket references you'll find. I'm already aware of some pages on our wiki, like:
- http://eigen.tuxfamily.org/index.php?title=Developer%27s_Corner
- http://eigen.tuxfamily.org/index.php?title=Mercurial

Any help on updating those old documentations will be greatly appreciated!
```

The fact they have re-opened fixed that problem.  I can confirm it also bust CANTERA as that has Eigen as a dependancy.  I'm about 36 hours new to spack, happy to help, where is that package.py downloaded onto my machine?  Is it only downloaded once I issue `spack install eigen` or is it always there?


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/anaconda3/package.py b/var/spack/repos/builtin/packages/anaconda3/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/anaconda3/package.py
@@ -0,0 +1,53 @@
+# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+from os.path import split
+
+
+class Anaconda3(Package):
+    """
+       Anaconda is a free and open-source distribution of the Python and R
+       programming languages for scientific computing, that aims to simplify
+       package management and deployment. Package versions are managed by
+       the package management system conda.
+    """
+    homepage = "https://www.anaconda.com"
+    url      = "https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh"
+
+    maintainers = ['ajkotobi']
+
+    version('2019.10', sha256='46d762284d252e51cd58a8ca6c8adc9da2eadc82c342927b2f66ed011d1d8b53', expand=False)
+    version('2019.07', sha256='69581cf739365ec7fb95608eef694ba959d7d33b36eb961953f2b82cb25bdf5a', expand=False)
+    version('2019.03', sha256='45c851b7497cc14d5ca060064394569f724b67d9b5f98a926ed49b834a6bb73a', expand=False)
+    version('2018.12', sha256='1019d0857e5865f8a6861eaf15bfe535b87e92b72ce4f531000dc672be7fce00', expand=False)
+    version('5.3.1',   sha256='d4c4256a8f46173b675dd6a62d12f566ed3487f932bab6bb7058f06c124bcc27', expand=False)
+    version('5.3.0',   sha256='cfbf5fe70dd1b797ec677e63c61f8efc92dad930fd1c94d60390bb07fdc09959', expand=False)
+    version('5.2.0',   sha256='09f53738b0cd3bb96f5b1bac488e5528df9906be2480fe61df40e0e0d19e3d48', expand=False)
+    version('5.1.0',   sha256='7e6785caad25e33930bc03fac4994a434a21bc8401817b7efa28f53619fa9c29', expand=False)
+    version('5.0.1',   sha256='55e4db1919f49c92d5abbf27a4be5986ae157f074bf9f8238963cd4582a4068a', expand=False)
+    version('5.0.0.1', sha256='092c92427f44687d789a41922ce8426fbdc3c529cc9d6d4ee6de5b62954b93b2', expand=False)
+    version('5.0.0',   sha256='67f5c20232a3e493ea3f19a8e273e0618ab678fa14b03b59b1783613062143e9', expand=False)
+    version('4.4.0',   sha256='3301b37e402f3ff3df216fe0458f1e6a4ccbb7e67b4d626eae9651de5ea3ab63', expand=False)
+    version('4.3.1',   sha256='4447b93d2c779201e5fb50cfc45de0ec96c3804e7ad0fe201ab6b99f73e90302', expand=False)
+    version('4.3.0',   sha256='e9169c3a5029aa820393ac92704eb9ee0701778a085ca7bdc3c57b388ac1beb6', expand=False)
+    version('4.2.0',   sha256='73b51715a12b6382dd4df3dd1905b531bd6792d4aa7273b2377a0436d45f0e78', expand=False)
+    version('4.1.1',   sha256='4f5c95feb0e7efeadd3d348dcef117d7787c799f24b0429e45017008f3534e55', expand=False)
+    version('4.1.0',   sha256='11d32cf4026603d3b327dc4299863be6b815905ff51a80329085e1bb9f96c8bd', expand=False)
+    version('4.0.0',   sha256='36a558a1109868661a5735f5f32607643f6dc05cf581fefb1c10fb8abbe22f39', expand=False)
+    version('2.5.0',   sha256='addadcb927f15cb0b5b6e36890563d3352a8ff6a901ea753d389047d274a29a9', expand=False)
+    version('2.4.1',   sha256='0735e69199fc37135930ea2fd4fb6ad0adef215a2a7ba9fd6b0a0a4daaadb1cf', expand=False)
+    version('2.4.0',   sha256='fb4e480059e991f2fa632b5a9bcdd284c7f0677814cd719c11d524453f96a40d', expand=False)
+    version('2.3.0',   sha256='3be5410b2d9db45882c7de07c554cf4f1034becc274ec9074b23fd37a5c87a6f', expand=False)
+    version('2.2.0',   sha256='4aac68743e7706adb93f042f970373a6e7e087dbf4b02ac467c94ca4ce33d2d1', expand=False)
+    version('2.1.0',   sha256='af3225ccbe8df0ffb918939e009aa57740e35058ebf9dfcf5fec794a77556c3c', expand=False)
+    version('2.0.1',   sha256='3c3b834793e461f3316ad1d9a9178c67859a9d74aaf7bcade076f04134dd1e26', expand=False)
+    version('2.0.0',   sha256='57ce4f97e300cf94c5724f72d992e9eecef708fdaa13bc672ae9779773056540', expand=False)
+
+    def install(self, spec, prefix):
+
+        dir, anaconda_script = split(self.stage.archive_file)
+        bash = which('bash')
+        bash(anaconda_script, '-b', '-f', '-p', self.prefix)


Test patch: