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