2022-11-20 13:19:39 +00:00
|
|
|
# install
|
|
|
|
|
|
2022-12-01 21:23:20 +00:00
|
|
|
You may install `d2` through any of the following methods.
|
2022-11-20 13:19:39 +00:00
|
|
|
|
|
|
|
|
<!-- toc -->
|
2022-12-01 20:59:53 +00:00
|
|
|
- <a href="#installsh" id="toc-installsh">install.sh</a>
|
|
|
|
|
- <a href="#security" id="toc-security">Security</a>
|
|
|
|
|
- <a href="#macos-homebrew" id="toc-macos-homebrew">macOS (Homebrew)</a>
|
|
|
|
|
- <a href="#standalone" id="toc-standalone">Standalone</a>
|
2022-12-01 21:14:09 +00:00
|
|
|
- <a href="#manual" id="toc-manual">Manual</a>
|
|
|
|
|
- <a href="#prefix" id="toc-prefix">PREFIX</a>
|
2022-12-01 20:59:53 +00:00
|
|
|
- <a href="#from-source" id="toc-from-source">From source</a>
|
2022-12-06 08:31:36 +00:00
|
|
|
- <a href="#source-release" id="toc-source-release">Source Release</a>
|
2022-12-06 11:00:08 +00:00
|
|
|
- <a href="#windows" id="toc-windows">Windows</a>
|
|
|
|
|
- <a href="#msys2" id="toc-msys2">MSYS2</a>
|
2022-12-06 11:12:00 +00:00
|
|
|
- <a href="#wsl" id="toc-wsl">WSL</a>
|
2022-12-01 20:59:53 +00:00
|
|
|
- <a href="#coming-soon" id="toc-coming-soon">Coming soon</a>
|
2022-11-20 13:19:39 +00:00
|
|
|
|
|
|
|
|
## install.sh
|
|
|
|
|
|
2022-11-21 17:35:49 +00:00
|
|
|
The recommended and easiest way to install is with our install script, which will detect
|
|
|
|
|
the OS and architecture you're on and use the best method:
|
|
|
|
|
|
2022-11-20 13:19:39 +00:00
|
|
|
```sh
|
|
|
|
|
# With --dry-run the install script will print the commands it will use
|
|
|
|
|
# to install without actually installing so you know what it's going to do.
|
|
|
|
|
curl -fsSL https://d2lang.com/install.sh | sh -s -- --dry-run
|
|
|
|
|
# If things look good, install for real.
|
|
|
|
|
curl -fsSL https://d2lang.com/install.sh | sh -s --
|
|
|
|
|
```
|
|
|
|
|
|
2022-11-21 08:02:39 +00:00
|
|
|
For help on the terminal run, including the supported package managers and detection
|
|
|
|
|
methods:
|
2022-11-20 13:19:39 +00:00
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
curl -fsSL https://d2lang.com/install.sh | sh -s -- --help
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-01 20:59:53 +00:00
|
|
|
### Security
|
|
|
|
|
|
|
|
|
|
The install script is not the most secure way to install d2. We recommend that if
|
|
|
|
|
possible, you use your OS's package manager directly or install from source with `go` as
|
|
|
|
|
described below.
|
|
|
|
|
|
|
|
|
|
But this does not mean the install script is insecure. There is no major flaw that
|
|
|
|
|
the install script is more vulnerable to than any other method of manual installation.
|
|
|
|
|
The most secure installation method involves a second independent entity, i.e your OS
|
|
|
|
|
package repos or Go's proxy server.
|
|
|
|
|
|
2022-12-01 21:23:20 +00:00
|
|
|
We're careful shell programmers and are aware of the many footguns of the Unix shell. Our
|
2022-12-01 20:59:53 +00:00
|
|
|
script was written carefully and with detail. For example, it is not vulnerable to partial
|
|
|
|
|
execution and the entire script runs with `set -eu` and very meticulous quoting.
|
|
|
|
|
|
2022-12-06 05:51:46 +00:00
|
|
|
It follows the XDG standards, installs `d2` properly into a Unix hierarchy path
|
|
|
|
|
(`/usr/local` unless `/usr/local` requires sudo in which case `~/.local` is used) and
|
|
|
|
|
allows for easy uninstall. You can easily adjust the used path with `--prefix`.
|
2022-12-01 20:59:53 +00:00
|
|
|
|
|
|
|
|
Some other niceties are that it'll tell you if you need to adjust `$PATH` or `$MANPATH` to
|
2022-12-01 21:23:20 +00:00
|
|
|
access `d2` and its manpages. It can also install
|
2022-12-01 20:59:53 +00:00
|
|
|
[TALA](https://github.com/terrastruct/tala) for you with `--tala`. You can also use it to
|
|
|
|
|
install a specific version of `d2` with `--version`. Run it with `--help` for more more
|
|
|
|
|
detailed docs on its various options and features.
|
|
|
|
|
|
2022-12-01 21:23:20 +00:00
|
|
|
If you're still concerned, remember you can run with `--dry-run` to avoid writing anything.
|
2022-12-01 20:59:53 +00:00
|
|
|
|
|
|
|
|
The install script does not yet verify any signature on the downloaded release
|
|
|
|
|
but that is coming soon. [#315](https://github.com/terrastruct/d2/issues/315)
|
|
|
|
|
|
2022-11-21 08:02:39 +00:00
|
|
|
## macOS (Homebrew)
|
|
|
|
|
|
2022-11-22 00:37:33 +00:00
|
|
|
If you're on macOS, you can install with `brew`.
|
2022-11-21 08:02:39 +00:00
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
brew tap terrastruct/d2
|
|
|
|
|
brew install d2
|
|
|
|
|
```
|
|
|
|
|
|
2022-11-22 00:35:27 +00:00
|
|
|
> The install script above does this automatically if you have `brew` installed and
|
|
|
|
|
> are running it on macOS.
|
|
|
|
|
|
2022-11-20 13:19:39 +00:00
|
|
|
## Standalone
|
|
|
|
|
|
2022-11-22 00:35:27 +00:00
|
|
|
We publish standalone release archives for every release on Github.
|
2022-12-01 21:14:09 +00:00
|
|
|
|
|
|
|
|
Here's a minimal example script that downloads a standalone release, extracts it into the
|
|
|
|
|
current directory and then installs it.
|
|
|
|
|
Adjust VERSION, OS, and ARCH as needed.
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
VERSION=v0.0.13 OS=macos ARCH=amd64 curl -fsSLO \
|
|
|
|
|
"https://github.com/terrastruct/d2/releases/download/$VERSION/d2-$VERSION-$OS-$ARCH.tar.gz" \
|
|
|
|
|
&& tar -xzf "d2-$VERSION-$OS-$ARCH.tar.gz" \
|
|
|
|
|
&& make -sC "d2-$VERSION" install
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To uninstall:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
VERSION=v0.0.13 make -sC "d2-$VERSION" uninstall
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Manual
|
|
|
|
|
|
|
|
|
|
You can also manually download the `.tar.gz` release for your OS/ARCH combination and then
|
|
|
|
|
run the following inside the extracted directory to install:
|
2022-11-20 13:19:39 +00:00
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
make install
|
|
|
|
|
```
|
|
|
|
|
|
2022-11-21 08:02:39 +00:00
|
|
|
Run the following to uninstall:
|
2022-11-20 13:19:39 +00:00
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
make uninstall
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-01 21:14:09 +00:00
|
|
|
### PREFIX
|
|
|
|
|
|
2022-11-21 08:02:39 +00:00
|
|
|
You can control the Unix hierarchy installation path with `PREFIX=`. For example:
|
2022-11-20 13:19:39 +00:00
|
|
|
|
2022-12-01 21:14:09 +00:00
|
|
|
```sh
|
2022-11-20 13:19:39 +00:00
|
|
|
# Install under ~/.local.
|
|
|
|
|
# Binaries will be at ~/.local/bin
|
|
|
|
|
# And manpages will be under ~/.local/share/man
|
|
|
|
|
# And supporting data like icons and fonts at ~/.local/share/d2
|
|
|
|
|
make install PREFIX=$HOME/.local
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The install script places the standalone release into `$PREFIX/lib/d2/d2-<version>`
|
|
|
|
|
and we recommend doing the same with manually installed releases so that you
|
|
|
|
|
know where the release directory is for easy uninstall.
|
|
|
|
|
|
2022-11-21 08:02:39 +00:00
|
|
|
## From source
|
2022-11-21 07:03:22 +00:00
|
|
|
|
2022-11-22 00:35:27 +00:00
|
|
|
You can always install from source:
|
2022-11-21 07:03:22 +00:00
|
|
|
|
|
|
|
|
```sh
|
2022-12-01 05:14:38 +00:00
|
|
|
go install oss.terrastruct.com/d2@latest
|
2022-11-21 07:03:22 +00:00
|
|
|
```
|
2022-11-21 17:31:05 +00:00
|
|
|
|
2022-12-06 08:31:36 +00:00
|
|
|
### Source Release
|
|
|
|
|
|
2022-12-01 20:59:53 +00:00
|
|
|
To install a proper release from source clone the repository and then:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
./ci/release/build.sh --install
|
|
|
|
|
# To uninstall:
|
|
|
|
|
# ./ci/release/build.sh --uninstall
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-06 08:31:36 +00:00
|
|
|
Installing a real release will also install manpages and in the future other assets like
|
|
|
|
|
fonts and icons. Furthermore, when installing a non versioned commit, installing a proper
|
|
|
|
|
release will ensure that `d2 --version` works correctly by embedding the commit hash into
|
|
|
|
|
the `d2` binary.
|
|
|
|
|
|
2022-12-06 11:00:08 +00:00
|
|
|
## Windows
|
|
|
|
|
|
|
|
|
|
d2 builds and runs on Windows:
|
|
|
|
|
|
|
|
|
|
We have prebuilt standalone releases for Windows though they're structured in the same way
|
|
|
|
|
as our Unix releases. So after extracting a release, you'll have to manually put the d2
|
|
|
|
|
binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`.
|
|
|
|
|
|
|
|
|
|
See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows
|
|
|
|
|
|
|
|
|
|
Then you'll be able to call `d2` from the commandline in `cmd.exe` or `pwsh.exe`.
|
|
|
|
|
|
|
|
|
|
We intend to have a `.msi` release installer sometime soon that handles putting `d2` into
|
|
|
|
|
your `$PATH` for you.
|
|
|
|
|
|
|
|
|
|
### MSYS2
|
|
|
|
|
|
|
|
|
|
<img width="1680" alt="Screenshot 2022-12-06 at 2 55 27 AM" src="https://user-images.githubusercontent.com/10180857/205892927-6f3e116c-1c4a-440a-9972-82c306aa9779.png">
|
|
|
|
|
|
|
|
|
|
We recommend using [MSYS2](https://www.msys2.org/) or [Git
|
|
|
|
|
Bash](https://gitforwindows.org/#bash) (Git Bash is based on MSYS2) for an improved
|
|
|
|
|
terminal experience.
|
|
|
|
|
|
|
|
|
|
MSYS2 provides a unix style shell environment that is native to Windows (unlike
|
|
|
|
|
[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables proper
|
|
|
|
|
installation of our standalone releases via `make install` and makes the manpage
|
|
|
|
|
accessible via `man d2`.
|
|
|
|
|
|
|
|
|
|
The MSYS2 terminal also enables `d2` to display colors like in the above screenshot.
|
|
|
|
|
|
|
|
|
|
In addition, all of our development and CI scripts work under MSYS2 whereas they do not
|
|
|
|
|
under plain Windows.
|
|
|
|
|
|
2022-12-06 11:12:00 +00:00
|
|
|
### WSL
|
|
|
|
|
|
|
|
|
|
`d2` works perfectly under [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)
|
|
|
|
|
aka Windows Subsystem for Linux if that's what you prefer. Installation is just like any
|
|
|
|
|
other Linux system.
|
|
|
|
|
|
2022-11-21 17:31:05 +00:00
|
|
|
## Coming soon
|
|
|
|
|
|
|
|
|
|
- Docker image
|
|
|
|
|
- rpm and deb packages
|
2022-11-22 00:35:27 +00:00
|
|
|
- with repositories and standalone
|
2022-11-21 17:31:05 +00:00
|
|
|
- homebrew core
|