blob: 4282bebfd2bc21c2fb86f5f71f59c1dd20f1178c [file] [log] [blame] [view]
Mike Frysinger7ac12a92019-12-04 18:34:07 -05001# Microsoft Windows Details
2
3Repo is primarily developed on Linux with a lot of users on macOS.
4Windows is, unfortunately, not a common platform.
5There is support in repo for Windows, but there might be some rough edges.
6
7Keep in mind that Windows in general is "best effort" and "community supported".
8That means we don't actively test or verify behavior, but rely heavily on users
9to report problems back to us, and to contribute fixes as needed.
10
11[TOC]
12
13## Windows
14
15We only support Windows 10 or newer.
16This is largely due to symlinks not being available in older versions, but it's
17also due to most developers not using Windows.
18
19We will never add code specific to older versions of Windows.
20It might work, but it most likely won't, so please don't bother asking.
21
Mike Frysingerf5dbd2e2020-02-21 01:19:46 -050022## Git worktrees
23
24*** note
25**Warning**: Repo's support for Git worktrees is new & experimental.
26Please report any bugs and be sure to maintain backups!
27***
28
29The Repo 2.4 release introduced support for [Git worktrees][git-worktree].
30You don't have to worry about or understand this particular feature, so don't
31worry if this section of the Git manual is particularly impenetrable.
32
33The salient point is that Git worktrees allow Repo to create repo client
34checkouts that do not require symlinks at all under Windows.
35This means users no longer need Administrator access to sync code.
36
37Simply use `--worktree` when running `repo init` to opt in.
38
39This does not effect specific Git repositories that use symlinks themselves.
40
41[git-worktree]: https://git-scm.com/docs/git-worktree
42
43## Symlinks by default
44
45*** note
46**NB**: This section applies to the default Repo behavior which does not use
47Git worktrees (see the previous section for more info).
48***
Mike Frysinger7ac12a92019-12-04 18:34:07 -050049
50Repo will use symlinks heavily internally.
51On *NIX platforms, this isn't an issue, but Windows makes it a bit difficult.
52
53There are some documents out there for how to do this, but usually the easiest
54answer is to run your shell as an Administrator and invoke repo/git in that.
55
56This isn't a great solution, but Windows doesn't make this easy, so here we are.
57
58### Launch Git Bash
59
60If you install Git Bash (see below), you can launch that with appropriate
61permissions so that all programs "just work".
62
63* Open the Start Menu (i.e. press the key).
64* Find/search for "Git Bash".
65* Right click it and select "Run as administrator".
66
67*** note
68**NB**: This environment is only needed when running `repo`, or any specific `git`
69command that might involve symlinks (e.g. `pull` or `checkout`).
70You do not need to run all your commands in here such as your editor.
71***
72
73### Symlinks with GNU tools
74
75If you want to use `ln -s` inside of the default Git/bash shell, you might need
76to export this environment variable:
77```sh
78$ export MSYS="winsymlinks:nativestrict"
79```
80
81Otherwise `ln -s` will copy files and not actually create a symlink.
82This also helps `tar` unpack symlinks, so that's nice.
83
84### References
85
86* https://github.com/git-for-windows/git/wiki/Symbolic-Links
87* https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
88
89## Python
90
Mike Frysingerf5dbd2e2020-02-21 01:19:46 -050091Python 3.6 or newer is required.
92Python 2 is known to be broken when running under Windows.
Mike Frysinger7ac12a92019-12-04 18:34:07 -050093See our [Python Support](./python-support.md) document for more details.
94
95You can grab the latest Windows installer here:
96https://www.python.org/downloads/release/python-3
97
98## Git
99
100You should install the most recent version of Git for Windows:
101https://git-scm.com/download/win
102
103When installing, make sure to turn on "Enable symbolic links" when prompted.
104
105If you've already installed Git for Windows, you can simply download the latest
106installer from above and run it again.
107It should safely upgrade things in situ for you.
108This is useful if you want to switch the symbolic link option after the fact.
109
110## Shell
111
112We don't have a specific requirement for shell environments when running repo.
113Most developers use MinTTY/bash that's included with the Git for Windows install
114(so see above for installing Git).
115
116Command & Powershell & the Windows Terminal probably work.
117Who knows!
118
119## FAQ
120
121### repo upload always complains about allowing hooks or using --no-verify!
122
123When using `repo upload` in projects that have custom repohooks, you might get
124an error like the following:
125```sh
126$ repo upload
127ERROR: You must allow the pre-upload hook or use --no-verify.
128```
129
130This can be confusing as you never get prompted.
131[MinTTY has a bug][mintty] that breaks isatty checking inside of repo which
132causes repo to never interactively prompt the user which means the upload check
133always fails.
134
135You can workaround this by manually granting consent when uploading.
136Simply add the `--verify` option whenever uploading:
137```sh
138$ repo upload --verify
139```
140
141You will have to specify this flag every time you upload.
142
143[mintty]: https://github.com/mintty/mintty/issues/56
144
145### repohooks always fail with an close_fds error.
146
147When using the [reference repohooks project][repohooks] included in AOSP,
148you might see errors like this when running `repo upload`:
149```sh
150$ repo upload
151ERROR: Traceback (most recent call last):
152 ...
153 File "C:\...\lib\subprocess.py", line 351, in __init__
154 raise ValueError("close_fds is not supported on Windows "
155ValueError: close_fds is not supported on Windows platforms if you redirect stdin/stderr/stdout
156
157Failed to run main() for pre-upload hook; see traceback above.
158```
159
160This error shows up when using Python 2.
161You should upgrade to Python 3 instead (see above).
162
163If you already have Python 3 installed, make sure it's the default version.
164Running `python --version` should say `Python 3`, not `Python 2`.
165If you didn't install the Python versions, or don't have permission to change
166the default version, you can probably workaround this by changing `$PATH` in
167your shell so the Python 3 version is found first.
168
169[repohooks]: https://android.googlesource.com/platform/tools/repohooks