Change Windows build documentation
License: MIT Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
Dominic Della Valle committed
Feb 12, 2018 at 20:37 UTC
bb47b63971eb312ed77c86025f5e4e6eaab0f38a
1 file changed
+107
-102
docs/windows.md
+107
-102
@@ -1,142 +1,147 @@
1
# Building on Windows
2
-
3
-## Install Git For Windows
4
-
5
-As Git is used by the Go language to download dependencies, you need
6
-to install Git, for example from http://git-scm.com/.
7
-
8
-You also must make sure that the directory that contains the Git For
9
-Windows binary is in the Path environment variable. Note that Git For
10
-Windows has a 'git' binary in a 'Git\bin' directory and another one in
11
-a 'Git\cmd' directory. You should only put the 'Git\cmd' directory in
12
-the Path environment variable.
2
+
3
4
## Install Go
5
+`go-ipfs` is built on Golang and thus depends on it for all building methods.
6
+https://golang.org/doc/install
7
+The `GOPATH` environment variable must be set as well.
8
+https://golang.org/doc/code.html#GOPATH
9
16
-Please install the Go language as explained on
17
-https://golang.org/doc/install.
18
-
19
-To properly install Go, you will need to set some environment
20
-variables. We recommend you to set them globally using the Control
21
-Panel, as explained in the documentation above, so that these
22
-environment variables are automatically available in all the possible
23
-environments that you might want to use like Git Bash, Windows's cmd,
24
-Cygwin's terminal, Windows' PowerShell and so on.
25
-
26
-You must make sure that the GOROOT environment variable is set and
27
-that the %GOROOT%/bin directory is in the Path environment variable.
28
-
29
-The GOPATH environment variable should also be set to a directory that
30
-you have created, and the %GOPATH/bin directory should also be in the
31
-Path environment variable.
10
+## Choose the way you want to proceed
11
+`go-ipfs` utilizes `make` to automate builds and run tests, but can be built without it using only `git` and `go`.
12
+No matter which method you choose, if you encounter issues, please see the [Troubleshooting](#troubleshooting) section.
13
33
-## Download go-ipfs and fix Git authentication
14
+**Using `make`:**
15
+MSYS2 and Cygwin provide the Unix tools we need to build `go-ipfs`. You may use either, but if you don't already have one installed, we recommend MSYS2.
16
+[MSYS2→](#msys2)
17
+[Cygwin→](#cygwin)
18
35
-Use the following command to download go-ipfs source code:
19
+**Using build tools manually:**
20
+This section assumes you have a working version of `go` and `git` already setup. You may want to build this way if your environment restricts installing additional software, or if you're integrating IPFS into your own build system.
21
+[Minimal→](#minimal)
22
23
+## MSYS2
24
+1. Install msys2 (http://www.msys2.org)
25
+2. Run the following inside a normal `cmd` prompt (Not the MSYS2 prompt, we only need MSYS2's tools).
26
+An explanation of this block is below.
27
```
28
+SET PATH=%PATH%;\msys64\usr\bin
29
+pacman --noconfirm -S git make unzip
30
go get -u github.com/ipfs/go-ipfs
31
+cd %GOPATH%\src\github.com\ipfs\go-ipfs
32
+make install
33
+%GOPATH%\bin\ipfs.exe version --all
34
```
35
41
-The above command uses Git to download go-ipfs from its GitHub
42
-repository. If you get authentication problems with Git, you might
43
-want to take a look at
44
-https://help.github.com/articles/caching-your-github-password-in-git/
45
-and use the suggested solution:
36
+If there were no errors, the final command should output version information similar to "`ipfs version 0.4.14-dev-XXXXXXX`" where "XXXXXXX" should match the current short-hash of the `go-ipfs` repo. You can retrieve said hash via this command: `git rev-parse --short HEAD`.
37
+If `ipfs.exe` executes and the version string matches, then building was successful.
38
+
39
+|Command|Explanation|
40
+| ---: | :--- |
41
+|`SET PATH=%PATH%;\msys64\usr\bin` |Add msys2's tools to our [`PATH`](https://ss64.com/nt/path.html); Defaults to: (\msys64\usr\bin)|
42
+|`pacman --noconfirm -S git make unzip` |Install `go-ipfs` build dependencies|
43
+|`go get -u github.com/ipfs/go-ipfs` |Fetch / Update `go-ipfs` source|
44
+|`cd %GOPATH%\src\github.com\ipfs\go-ipfs` |Change to `go-ipfs` source directory|
45
+|`make install` |Build and install to `%GOPATH%\bin\ipfs.exe`|
46
+|`%GOPATH%\bin\ipfs.exe version --all` |Test the built binary|
47
48
+To build again after making changes to the source, run:
49
```
48
-git config --global credential.helper wincred
50
+SET PATH=%PATH%;\msys64\usr\bin
51
+cd %GOPATH%\src\github.com\ipfs\go-ipfs
52
+make install
53
```
54
51
-## Choose the way you want to proceed
52
-
53
-Now there are two ways to download, install the dependencies and to
54
-build go-ipfs:
55
-
56
-1) There is the "Manual Way", where you don't need to install anymore
57
-software except the dependencies, but you have a number of commands to
58
-type.
59
-
60
-2) There is a way by installing 'make' through Cygwin and using it to
61
-do nearly everything. We call this way the "Cygwin Way". It may take
62
-much more time, because installing Cygwin can take a lot of time, but
63
-after that it might be easier as many procedures are just a 'make'
64
-command away.
65
-
66
-So use the next steps below that start with "Manual Way" if that's the
67
-way you want, otherwise scroll down a bit and use the "Cygwin Way"
68
-steps below.
69
-
70
-## Manual Way: download and install dependencies
71
-
72
-The following commands should download or update go-ipfs dependencies
73
-and then install them:
74
-
55
+**Tip:** To avoid setting `PATH` every time (`SET PATH=%PATH%;\msys64\usr\bin`), you can lock it in permanently using `setx` after it's been set once:
56
```
76
-go get -u github.com/whyrusleeping/gx
77
-go get -u github.com/whyrusleeping/gx-go
78
-cd %GOPATH%/src/github.com/ipfs/go-ipfs
79
-gx --verbose install --global
57
+SETX PATH %PATH%
58
```
59
82
-## Manual Way: build go-ipfs
83
-
84
-To actually build go-ipfs, first go to the cmd/ipfs directory:
85
-
60
+## Cygwin
61
+1. Install Cygwin (https://www.cygwin.com)
62
+2. During the install, select the following packages. (If you already have Cygwin installed, run the setup file again to install additional packages.) A fresh install should look something like [this reference image](https://ipfs.io/ipfs/QmaYFSQa4iHDafcebiKjm1WwuKhosoXr45HPpfaeMbCRpb/cygwin%20-%20install.png).
63
+ - devel packages
64
+ - `git`
65
+ - `make`
66
+ - archive packages
67
+ - `unzip`
68
+ - net packages
69
+ - `curl`
70
+3. Run the following inside a normal `cmd` prompt (Not the Cygwin prompt, we only need Cygwin's tools)
71
+An explanation of this block is below.
72
```
87
-cd cmd\ipfs
73
+SET PATH=%PATH%;\cygwin64\bin
74
+mkdir %GOPATH%\src\github.com\ipfs
75
+cd %GOPATH%\src\github.com\ipfs
76
+git clone https://github.com/ipfs/go-ipfs.git
77
+cd %GOPATH%\src\github.com\ipfs\go-ipfs
78
+make install
79
+%GOPATH%\bin\ipfs.exe version --all
80
```
81
90
-Then get the current Git commit:
82
+If there were no errors, the final command should output version information similar to "`ipfs version 0.4.14-dev-XXXXXXX`" where "XXXXXXX" should match the current short-hash of the `go-ipfs` repo. You can retrieve said hash via this command: `git rev-parse --short HEAD`.
83
+If `ipfs.exe` executes and the version string matches, then building was successful.
84
+
85
+|Command|Explanation|
86
+| ---: | :--- |
87
+|`SET PATH=%PATH%;\cygwin64\bin` |Add Cygwin's tools to our [`PATH`](https://ss64.com/nt/path.html); Defaults to: (\cygwin64\bin)|
88
+|`mkdir %GOPATH%\src\github.com\ipfs`<br/>`cd %GOPATH%\src\github.com\ipfs`<br/>`git clone https://github.com/ipfs/go-ipfs.git` |Fetch / Update `go-ipfs` source|
89
+|`cd %GOPATH%\src\github.com\ipfs\go-ipfs` |Change to `go-ipfs` source directory|
90
+|`make install` |Build and install to `%GOPATH%\bin\ipfs.exe`|
91
+|`%GOPATH%\bin\ipfs.exe version --all` |Test the built binary|
92
93
+To build again after making changes to the source, run:
94
```
93
-git rev-parse --short HEAD
95
+SET PATH=%PATH%;\cygwin64\bin
96
+cd %GOPATH%\src\github.com\ipfs\go-ipfs
97
+make install
98
```
99
96
-It will output a small number of hex characters that you must pass to
97
-the actual build command (replace XXXXXXX with these characters):
98
-
100
+**Tip:** To avoid setting `PATH` every time (`SET PATH=%PATH%;\cygwin64\bin`), you can lock it in permanently using `setx` after it's been set once:
101
```
100
-go install -ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=XXXXXXX"
102
+SETX PATH %PATH%
103
```
104
103
-After that ipfs should have been built and should be available in
104
-"%GOPATH%\bin".
105
+## Minimal
106
+While it's possible to build `go-ipfs` with `go` alone, we'll be using `git` and `gx` for practical source management.
107
+You can use whichever version of `git` you wish but we recommend the Windows builds at <https://git-scm.com>. `git` must be in your [`PATH`](https://ss64.com/nt/path.html) for `go get` to recognize and use it.
108
106
-You can check that the ipfs you built has the right version using:
109
+### `gx`
110
+You may install prebuilt binaries for [`gx`](https://dist.ipfs.io/#gx) & [`gx-go`](https://dist.ipfs.io/#gx-go) if they're available for your platform.
111
+Alternatively, you can build them from source and install them to `%GOPATH%\bin` by running the following:
112
113
```
109
-ipfs version --commit
114
+go get -u github.com/whyrusleeping/gx
115
+go get -u github.com/whyrusleeping/gx-go
116
```
117
112
-It should output something like "ipfs version 0.4.0-dev-XXXXXXX" where
113
-XXXXXXX is the current commit that you passed to the build command.
114
-
115
-## Cygwin way: install Cygwin
116
-
117
-Install Cygwin as explained in the Cygwin documentation:
118
+### `go-ipfs`
119
119
-http://cygwin.com/install.html
120
-
121
-By default Cygwin will not install 'make', so you should click on the
122
-"Devel" category during the Cygwin installation process and then check
123
-the 'make' package.
124
-
125
-## Cygwin way: build go-ipfs
126
-
127
-To build go-ipfs using Cygwin you just need to open a Cygwin Terminal
128
-and then type the following commands:
120
+```
121
+SET PATH=%PATH%;%GOPATH%\bin
122
+go get -u -d github.com/ipfs/go-ipfs
123
+cd %GOPATH%/src/github.com/ipfs/go-ipfs
124
+gx --verbose install --global
125
+cd cmd\ipfs
126
+```
127
+We need the `git` commit hash to be included in our build so that in the extremely rare event a bug is found, we have a reference point later for tracking it. We'll ask `git` for it and store it in a variable. The syntax for the next command is different depending on whether you're using the interactive command line or writing a batch file. Use the one that applies to you.
128
+- interactive: `FOR /F %V IN ('git rev-parse --short HEAD') do set SHA=%V`
129
+- interpreter: `FOR /F %%V IN ('git rev-parse --short HEAD') do set SHA=%%V`
130
131
+Finally, we'll build and test `ipfs` itself.
132
```
131
-cd $GOPATH/src/github.com/ipfs/go-ipfs
132
-make install
133
+go install -ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=%SHA%"
134
+%GOPATH%\bin\ipfs.exe version --all
135
```
136
+You can check that the ipfs output versions match with `go version` and `git rev-parse --short HEAD`.
137
+If `ipfs.exe` executes and everything matches, then building was successful.
138
135
-After that ipfs should have been built and should be available in
136
-"%GOPATH%\bin".
139
+## Troubleshooting
140
+- **Git auth**
141
+If you get authentication problems with Git, you might want to take a look at https://help.github.com/articles/caching-your-github-password-in-git/ and use the suggested solution:
142
+`git config --global credential.helper wincred`
143
138
-You can check that the ipfs you built has the right version using:
144
+- **Anything else**
145
+Please search [https://discuss.ipfs.io](https://discuss.ipfs.io/search?q=windows%20category%3A13) for any additional issues you may encounter. If you can't find any existing resolution, feel free to post a question asking for help.
146
140
-```
141
-ipfs version --commit
142
-```
147
+If you encounter a bug with `go-ipfs` itself (not related to building) please use the [issue tracker](https://github.com/ipfs/go-ipfs/issues) to report it.