# What to do when Elm Package Registry is down?

**URL:** <https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048>\
**Category:** Learn\
**Created:** [January 23, 2020, 8:29am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048 "2020-01-23T08:29:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jigargosar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jigargosar/32/79_2.png) [@jigargosar](https://discourse.elm-lang.org/u/jigargosar)\
**Post date:** [January 23, 2020, 8:29am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/1 "2020-01-23T08:29:28Z")

</div>

The website at [https://package.elm-lang.org/](https://package.elm-lang.org/), shows following error:

```
502 Bad Gateway
nginx/1.10.3 (Ubuntu)

```

Looking for advise for installing packages, and viewing documentation, when official package repository is down.

Please share your previous expriences, if any.

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [January 23, 2020, 9:46am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/2 "2020-01-23T09:46:16Z")

</div>

For viewing documentation offline you could use [https://github.com/dmy/elm-doc-preview](https://github.com/dmy/elm-doc-preview)

---

<div class="post-metadata">

**Author:** ![jigargosar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jigargosar/32/79_2.png) [@jigargosar](https://discourse.elm-lang.org/u/jigargosar)\
**Post date:** [January 23, 2020, 12:19pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/3 "2020-01-23T12:19:44Z")

</div>

Thanks for sharing, it works like a charm for viewing documentation of **locally cached** packages.

---

<div class="post-metadata">

**Author:** ![sashaafm](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sashaafm/32/453_2.png) [@sashaafm](https://discourse.elm-lang.org/u/sashaafm)\
**Post date:** [January 23, 2020, 1:58pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/4 "2020-01-23T13:58:08Z")

</div>

The package repository is maintained by the Elm Core Team, no? Would it be possible to know what’s wrong and if there’s any way we can contribute?

---

<div class="post-metadata">

**Author:** ![Janiczek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/janiczek/32/4516_2.png) [@Janiczek](https://discourse.elm-lang.org/u/Janiczek)\
**Post date:** [January 23, 2020, 2:40pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/5 "2020-01-23T14:40:10Z")

</div>

There are ways to unblock your local development, eg.

- [https://gist.github.com/rlefevre/850b1147f0ca256bf65d6bb8a58f0bcb](https://gist.github.com/rlefevre/850b1147f0ca256bf65d6bb8a58f0bcb)
- [https://gist.github.com/opsb/544c568bdbeb548548a104eaf207e4ce](https://gist.github.com/opsb/544c568bdbeb548548a104eaf207e4ce) (which builds on it)
- [https://github.com/drathier/elm-offline](https://github.com/drathier/elm-offline)
- [https://github.com/Skinney/elm-git-install](https://github.com/Skinney/elm-git-install)

But that’s not a satisfactory solution IMHO… Failover server _and_ people with enough permissions to fix the servers in various timezones (so that folks don’t need to wait for US to wake up) might be a step in the right direction?

---

<div class="post-metadata">

**Author:** ![evancz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/evancz/32/16_2.png) [@evancz](https://discourse.elm-lang.org/u/evancz)\
**Post date:** [January 23, 2020, 10:16pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/6 "2020-01-23T22:16:26Z")

</div>

Should be back as of about 8 hours ago, around when @Janiczek posted. I shared the following info on a GitHub issue about the 502.

### What happened?

This has happened once before, but at a better time of day. That time, I spent the next few days setting up `monit` so that the server could restart itself.

In this case, it looks like the server went down at the worst possible time for US-based admin. We had `monit` set up to restart the server if this ever happened, but it ran into trouble. It seems that restarting needed the `HOME` environment variable to be defined, but it was not defined in whatever context `monit` was trying to run the restart script.

Anyway, once US work hours started again, we got the server back up. Then figured out what the problem was that prevented `monit` from working. So the issue reported here should be resolved as of US morning.

Additionally, I have added a new admin for the site who lives in Europe. Between these two things, I think the window of possible downtime should be a lot smaller. There will be an Elm event in Japan relatively soon, so perhaps we will be able to find someone there to add, further limiting the amount of time that are not covered by people at work.

### Making CI more resilient

For folks who had trouble with CI, it is possible with most systems to cache the `~/.elm` directory such that you do not need to talk to `package.elm-lang.org` or to `github.com` on normal builds. Only if a new package dependency is added.

People who had this configured did not experience any downtime on CI. I am asking community members to blog about this and make sure any default configurations out there are doing this.

We are hopeful the `monit` fix and the European admin will help with downtime, but configuring CI to save `~/.elm/` is a great way to be resilient to downtime elsewhere and to reduce build times in general.

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [January 24, 2020, 9:19am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/7 "2020-01-24T09:19:58Z")

</div>

What we are doing at my company is using Docker to build everything, in particular we run the elm compiler from a Docker container. This means we do not care what specific machine the CI runs on, as long as it has Docker installed. As we build not only elm projects but also C++, Fortran, etc., this is quite convenient and scales well.

We used to simply put the 0.19.1 directory under version control, which is inconvenient because it bloats the repository & dependencies are duplicated for each elm project. Then we tested removing those submodules (i.e. downloading from the internet at each fresh build) and literally four day later the elm package repository broke…

The problems I have with caching the .elm directory for CI are:

- Each project has different dependencies so, eventually, your .elm directory becomes a very large subset of the whole elm package registry
- We cannot execute the CI jobs on any runner (CI runners are no longer tool-agnostic)

In [this thread](https://discourse.elm-lang.org/t/about-private-packages/1872), Evan says that he does not want to enable private repositories because it would add a lot of complexity to the package system. I think that simply enabling any git repository (not just Github) is sufficient: just require Github for published packages. This is more or less the idea developed [here](https://discourse.elm-lang.org/t/about-private-packages/1872/10).

It would bring the following benefits:

- Use private packages instead of git submodules
- No single point of failure (elm package repository is one)

---

<div class="post-metadata">

**Author:** ![opsb](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/opsb/32/240_2.png) [@opsb](https://discourse.elm-lang.org/u/opsb)\
**Post date:** [January 24, 2020, 10:37am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/8 "2020-01-24T10:37:38Z")

</div>

During the downtime somebody suggested that a CDN could be a good option.

Given Elm’s semantic versioning of packages it should be possible for the server to serve the assets with the `Cache-Control: immutable` header. The server would then serve the initial request for an asset, the CDN handling all requests thereafter. This would give us HA with very little maintenance overhead.

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [January 24, 2020, 2:52pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/9 "2020-01-24T14:52:45Z")

</div>

That looks like a great idea! I still think being able to specify any Git server & rejecting pushes to the package registry if any server is not GitHub would be a good idea, though, but your suggestion would certainly help mitigate the downtime problem.

---

<div class="post-metadata">

**Author:** ![dta](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dta/32/1917_2.png) [@dta](https://discourse.elm-lang.org/u/dta)\
**Post date:** [January 24, 2020, 6:02pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/10 "2020-01-24T18:02:26Z")

</div>

Why not bake the package cache into your docker image? That way the tooling would still be machine-agnostic, but you won’t have to pay the penalty of downloading the dependencies each build, and you’ll be resilient to network issues.

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [January 24, 2020, 7:45pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/11 "2020-01-24T19:45:57Z")

</div>

Yes that’s an interesting idea. I suppose I would need one Docker image per project otherwise my Docker image would end up containing all of elm’s packages! I’ll see if I can figure something out. Thanks for the idea!

---

<div class="post-metadata">

**Author:** ![illeatmyhat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/illeatmyhat/32/2607_2.png) [@illeatmyhat](https://discourse.elm-lang.org/u/illeatmyhat)\
**Post date:** [January 25, 2020, 2:37am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/12 "2020-01-25T02:37:24Z")

</div>

> [@Deimos](#):
>
> I think that simply enabling any git repository (not just Github) is sufficient: just require Github for published packages.

Python’s `pip` is an excellent example of something that just works and nobody complains about, and isn’t locked to github either.  
You can just do `pip install git+ssh://my.github.enterprise/my-project/my-repo@1234567890`

---

<div class="post-metadata">

**Author:** ![Deimos](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/deimos/32/2359_2.png) [@Deimos](https://discourse.elm-lang.org/u/Deimos)\
**Post date:** [January 27, 2020, 5:52am UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/13 "2020-01-27T05:52:20Z")

</div>

Yes, there are other ways of doing it. In fact, I don’t know any other language that requires you to use GitHub… I’m not sure why we could not use the same technique as PIP: the use case looks fairly similar.

---

<div class="post-metadata">

**Author:** ![stchris](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@stchris](https://discourse.elm-lang.org/u/stchris)\
**Post date:** [February 4, 2020, 4:37pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/14 "2020-02-04T16:37:41Z")

</div>

I found [https://github.com/robx/shelm](https://github.com/robx/shelm) to allow me to do just what was mentioned above with pinning git commits, just like in Python’s pip.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [February 14, 2020, 4:52pm UTC](https://discourse.elm-lang.org/t/what-to-do-when-elm-package-registry-is-down/5048/15 "2020-02-14T16:52:50Z")

</div>

Closed on February 14, 2020, 4:52pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
