README.md 5.98 KB
Newer Older
Julian Ospald's avatar
Julian Ospald committed
1
**THIS PROJECT IS NOW DEPRECATED IN FAVOR OF [ghcup-hs](https://gitlab.haskell.org/haskell/ghcup-hs)**
Julian Ospald's avatar
Julian Ospald committed
2 3 4

--

5
`ghcup` makes it easy to install specific versions of `ghc` on GNU/Linux as well as macOS (aka Darwin), and can also bootstrap a fresh Haskell developer environment from scratch.
Julian Ospald's avatar
Julian Ospald committed
6
It follows the unix UNIX philosophy of [do one thing and do it well](https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well).
Julian Ospald's avatar
Julian Ospald committed
7

Sam Halliday's avatar
Sam Halliday committed
8
Similar in scope to [rustup](https://github.com/rust-lang-nursery/rustup.rs), [pyenv](https://github.com/pyenv/pyenv) and [jenv](http://www.jenv.be).
9

10
*Ubuntu users may prefer [hvr's ppa](https://launchpad.net/~hvr/+archive/ubuntu/ghc).*
11

Julian Ospald's avatar
Julian Ospald committed
12 13
*This project was started when [CM](https://github.com/capital-match) was switching from stack to [cabal nix-style builds](https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html).*

Julian Ospald's avatar
Julian Ospald committed
14 15 16 17
## Table of Contents

   * [Installation](#installation)
   * [Usage](#usage)
Julian Ospald's avatar
Julian Ospald committed
18
     * [Manpages](#manpages)
Julian Ospald's avatar
Julian Ospald committed
19
   * [Design goals](#design-goals)
Sam Halliday's avatar
Sam Halliday committed
20
   * [How](#how)
Julian Ospald's avatar
Julian Ospald committed
21
   * [Known users](#known-users)
Julian Ospald's avatar
Julian Ospald committed
22
   * [Known problems](#known-problems)
Julian Ospald's avatar
Julian Ospald committed
23
   * [FAQ](#faq)
Julian Ospald's avatar
Julian Ospald committed
24

Julian Ospald's avatar
Julian Ospald committed
25 26
## Installation

Julian Ospald's avatar
Julian Ospald committed
27 28
Choose one of the following installation methods.

29 30 31 32
### Simple bootstrap of ghcup, GHC and cabal-install

```sh
# complete bootstrap
Julian Ospald's avatar
Julian Ospald committed
33
curl https://gitlab.haskell.org/haskell/ghcup/raw/master/bootstrap-haskell -sSf | sh
34 35 36 37 38 39 40 41 42 43 44 45 46

# prepare your environment
. "$HOME/.ghcup/env"
echo '. $HOME/.ghcup/env' >> "$HOME/.bashrc" # or similar

# now create a project, such as:
mkdir myproject && cd myproject
cabal init -n --is-executable
cabal v2-run
```

### Manual install

Julian Ospald's avatar
Julian Ospald committed
47 48 49
Just place the `ghcup` shell script into your `PATH` anywhere.

E.g.:
Julian Ospald's avatar
Julian Ospald committed
50

Julian Ospald's avatar
Julian Ospald committed
51
```sh
Julian Ospald's avatar
Julian Ospald committed
52
( mkdir -p ~/.ghcup/bin && curl https://gitlab.haskell.org/haskell/ghcup/raw/master/ghcup > ~/.ghcup/bin/ghcup && chmod +x ~/.ghcup/bin/ghcup) && echo "Success"
53 54
```

Julian Ospald's avatar
Julian Ospald committed
55 56 57
Then adjust your `PATH` in `~/.bashrc` (or similar, depending on your shell) like so, for example:

```sh
Julian Ospald's avatar
Julian Ospald committed
58
export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"
Julian Ospald's avatar
Julian Ospald committed
59 60
```

Julian Ospald's avatar
Julian Ospald committed
61
Security aware users may want to use the files from the [release page](https://gitlab.haskell.org/haskell/ghcup/tags/)
Julian Ospald's avatar
Julian Ospald committed
62 63
and verify the gpg signatures.

Julian Ospald's avatar
Julian Ospald committed
64 65
## Usage

66
See `ghcup --help`.
Julian Ospald's avatar
Julian Ospald committed
67

Julian Ospald's avatar
Julian Ospald committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
Common use cases are:

```sh
# install the last known "best" GHC version
ghcup install
# install a specific GHC version
ghcup install 8.2.2
# set the currently "active" GHC version
ghcup set 8.4.4
# install cabal-install
ghcup install-cabal
# update cabal-install
cabal new-install cabal-install
```

Julian Ospald's avatar
Julian Ospald committed
83 84 85
Generally this is meant to be used with [`cabal-install`](https://hackage.haskell.org/package/cabal-install), which
handles your haskell packages and can demand that [a specific version](https://cabal.readthedocs.io/en/latest/nix-local-build.html#cfg-flag---with-compiler)  of `ghc` is available, which `ghcup` can do.

Julian Ospald's avatar
Julian Ospald committed
86 87 88
### Manpages

For man pages to work you need [man-db](http://man-db.nongnu.org/) as your `man` provider, then issue `man ghc`. Manpages only work for the currently set ghc.
89
`MANPATH` may be required to be unset.
Julian Ospald's avatar
Julian Ospald committed
90

Julian Ospald's avatar
Julian Ospald committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104
## Design goals

1. simplicity
2. non-interactive
3. portable
4. do one thing and do it well (UNIX philosophy)

### Non-goals

1. invoking `sudo`, `apt-get` or *any* package manager
2. handling system packages
3. handling cabal projects
4. being a stack alternative

Sam Halliday's avatar
Sam Halliday committed
105 106 107 108 109 110 111 112 113 114 115 116
## How

Installs a specified GHC version into `~/.ghcup/ghc/<ver>`, and places `ghc-<ver>` symlinks in `~/.ghcup/bin/`.

Optionally, an unversioned `ghc` link can point to a default version of your choice.

This uses precompiled GHC binaries that have been compiled on fedora/debian by [upstream GHC](https://www.haskell.org/ghc/download_ghc_8_6_1.html#binaries).

Alternatively, you can also tell it to compile from source (note that this might fail due to missing requirements).

In addition this script can also install `cabal-install`.

Julian Ospald's avatar
Julian Ospald committed
117 118 119 120
## Known users

* [vabal](https://github.com/Franciman/vabal)

Sam Halliday's avatar
Sam Halliday committed
121
## Known problems
Julian Ospald's avatar
Julian Ospald committed
122

Sam Halliday's avatar
Sam Halliday committed
123
### Limited distributions supported
124

125
Currently only GNU/Linux distributions compatible with the [upstream GHC](https://www.haskell.org/ghc/download_ghc_8_6_1.html#binaries) binaries are supported.
Julian Ospald's avatar
Julian Ospald committed
126

127 128
### Precompiled binaries

Julian Ospald's avatar
Julian Ospald committed
129
Since this uses precompiled binaries you may run into
130 131 132 133 134
several problems.

#### Missing libtinfo (ncurses)

You may run into problems with *ncurses* and **missing libtinfo**, in case
Julian Ospald's avatar
Julian Ospald committed
135 136 137
your distribution doesn't use the legacy way of building
ncurses and has no compatibility symlinks in place.

138 139
Ask your distributor on how to solve this or
try to compile from source via `ghcup compile <version>`.
140

141 142 143 144
#### Libnuma required

This was a [bug](https://ghc.haskell.org/trac/ghc/ticket/15688) in the build system of some GHC versions that lead to
unconditionally enabled libnuma support. To mitigate this you might have to install the libnuma
Julian Ospald's avatar
Julian Ospald committed
145
package of your distribution. See [here](https://gitlab.haskell.org/haskell/ghcup/issues/58) for a discussion.
146

147 148
### Compilation

Julian Ospald's avatar
Julian Ospald committed
149
Although this script can compile GHC for you, it's just a very thin
150
wrapper around the build system. It makes no effort in trying
Julian Ospald's avatar
Julian Ospald committed
151
to figure out whether you have the correct toolchain and
152 153
the correct dependencies. Refer to [the official docs](https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Linux)
on how to prepare your environment for building GHC.
Julian Ospald's avatar
Julian Ospald committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174

## FAQ

1. Why reimplement stack?

ghcup is not a reimplementation of stack. The only common part is automatic installation of GHC, but even that differs in scope and design.

2. Why not contribute to stack and create a library for the common part?

While this might be an interesting idea, ghcup is about simplicity.

3. Why write a >1000k LOC bash script?

ghcup is POSIX sh.

4. Why write a >1000k LOC POSIX sh script?

Mainly because the implementation is fairly straight-forward and the script is highly portable. No need to bootstrap anything or set up yet another CI to build ghcup binaries for all possible arches and distros just to perform a very simple task: identify distro and platform and download a GHC bindist.

5. Why not support windows?

175
Consider using [Chocolatey](https://chocolatey.org/search?q=ghc) or [ghcups](https://github.com/kakkun61/ghcups).