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 | |
| 22 | ## Symlinks |
| 23 | |
| 24 | Repo will use symlinks heavily internally. |
| 25 | On *NIX platforms, this isn't an issue, but Windows makes it a bit difficult. |
| 26 | |
| 27 | There are some documents out there for how to do this, but usually the easiest |
| 28 | answer is to run your shell as an Administrator and invoke repo/git in that. |
| 29 | |
| 30 | This isn't a great solution, but Windows doesn't make this easy, so here we are. |
| 31 | |
| 32 | ### Launch Git Bash |
| 33 | |
| 34 | If you install Git Bash (see below), you can launch that with appropriate |
| 35 | permissions so that all programs "just work". |
| 36 | |
| 37 | * Open the Start Menu (i.e. press the ⊞ key). |
| 38 | * Find/search for "Git Bash". |
| 39 | * Right click it and select "Run as administrator". |
| 40 | |
| 41 | *** note |
| 42 | **NB**: This environment is only needed when running `repo`, or any specific `git` |
| 43 | command that might involve symlinks (e.g. `pull` or `checkout`). |
| 44 | You do not need to run all your commands in here such as your editor. |
| 45 | *** |
| 46 | |
| 47 | ### Symlinks with GNU tools |
| 48 | |
| 49 | If you want to use `ln -s` inside of the default Git/bash shell, you might need |
| 50 | to export this environment variable: |
| 51 | ```sh |
| 52 | $ export MSYS="winsymlinks:nativestrict" |
| 53 | ``` |
| 54 | |
| 55 | Otherwise `ln -s` will copy files and not actually create a symlink. |
| 56 | This also helps `tar` unpack symlinks, so that's nice. |
| 57 | |
| 58 | ### References |
| 59 | |
| 60 | * https://github.com/git-for-windows/git/wiki/Symbolic-Links |
| 61 | * https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/ |
| 62 | |
| 63 | ## Python |
| 64 | |
| 65 | You should make sure to be running Python 3.6 or newer under Windows. |
| 66 | Python 2 might work, but due to already limited platform testing, you should |
| 67 | only run newer Python versions. |
| 68 | See our [Python Support](./python-support.md) document for more details. |
| 69 | |
| 70 | You can grab the latest Windows installer here:<br> |
| 71 | https://www.python.org/downloads/release/python-3 |
| 72 | |
| 73 | ## Git |
| 74 | |
| 75 | You should install the most recent version of Git for Windows:<br> |
| 76 | https://git-scm.com/download/win |
| 77 | |
| 78 | When installing, make sure to turn on "Enable symbolic links" when prompted. |
| 79 | |
| 80 | If you've already installed Git for Windows, you can simply download the latest |
| 81 | installer from above and run it again. |
| 82 | It should safely upgrade things in situ for you. |
| 83 | This is useful if you want to switch the symbolic link option after the fact. |
| 84 | |
| 85 | ## Shell |
| 86 | |
| 87 | We don't have a specific requirement for shell environments when running repo. |
| 88 | Most developers use MinTTY/bash that's included with the Git for Windows install |
| 89 | (so see above for installing Git). |
| 90 | |
| 91 | Command & Powershell & the Windows Terminal probably work. |
| 92 | Who knows! |
| 93 | |
| 94 | ## FAQ |
| 95 | |
| 96 | ### repo upload always complains about allowing hooks or using --no-verify! |
| 97 | |
| 98 | When using `repo upload` in projects that have custom repohooks, you might get |
| 99 | an error like the following: |
| 100 | ```sh |
| 101 | $ repo upload |
| 102 | ERROR: You must allow the pre-upload hook or use --no-verify. |
| 103 | ``` |
| 104 | |
| 105 | This can be confusing as you never get prompted. |
| 106 | [MinTTY has a bug][mintty] that breaks isatty checking inside of repo which |
| 107 | causes repo to never interactively prompt the user which means the upload check |
| 108 | always fails. |
| 109 | |
| 110 | You can workaround this by manually granting consent when uploading. |
| 111 | Simply add the `--verify` option whenever uploading: |
| 112 | ```sh |
| 113 | $ repo upload --verify |
| 114 | ``` |
| 115 | |
| 116 | You will have to specify this flag every time you upload. |
| 117 | |
| 118 | [mintty]: https://github.com/mintty/mintty/issues/56 |
| 119 | |
| 120 | ### repohooks always fail with an close_fds error. |
| 121 | |
| 122 | When using the [reference repohooks project][repohooks] included in AOSP, |
| 123 | you might see errors like this when running `repo upload`: |
| 124 | ```sh |
| 125 | $ repo upload |
| 126 | ERROR: Traceback (most recent call last): |
| 127 | ... |
| 128 | File "C:\...\lib\subprocess.py", line 351, in __init__ |
| 129 | raise ValueError("close_fds is not supported on Windows " |
| 130 | ValueError: close_fds is not supported on Windows platforms if you redirect stdin/stderr/stdout |
| 131 | |
| 132 | Failed to run main() for pre-upload hook; see traceback above. |
| 133 | ``` |
| 134 | |
| 135 | This error shows up when using Python 2. |
| 136 | You should upgrade to Python 3 instead (see above). |
| 137 | |
| 138 | If you already have Python 3 installed, make sure it's the default version. |
| 139 | Running `python --version` should say `Python 3`, not `Python 2`. |
| 140 | If you didn't install the Python versions, or don't have permission to change |
| 141 | the default version, you can probably workaround this by changing `$PATH` in |
| 142 | your shell so the Python 3 version is found first. |
| 143 | |
| 144 | [repohooks]: https://android.googlesource.com/platform/tools/repohooks |