1.. _west-troubleshooting: 2 3Troubleshooting West 4#################### 5 6This page covers common issues with west and how to solve them. 7 8``west update`` fetching failures 9********************************* 10 11One good way to troubleshoot fetching issues is to run ``west update`` in 12verbose mode, like this: 13 14.. code-block:: shell 15 16 west -v update 17 18The output includes Git commands run by west and their outputs. Look for 19something like this: 20 21.. code-block:: none 22 23 === updating your_project (path/to/your/project): 24 west.manifest: your_project: checking if cloned 25 [...other west.manifest logs...] 26 --- your_project: fetching, need revision SOME_SHA 27 west.manifest: running 'git fetch ... https://github.com/your-username/your_project ...' in /some/directory 28 29The ``git fetch`` command example in the last line above is what needs to 30succeed. 31 32One strategy is to go to ``/path/to/your/project``, copy/paste and run the entire 33``git fetch`` command, then debug from there using the documentation for your 34credential storage helper. 35 36If you're behind a corporate firewall and may have proxy or other issues, 37``curl -v FETCH_URL`` (for HTTPS URLs) or ``ssh -v FETCH_URL`` (for SSH URLs) 38may be helpful. 39 40If you can get the ``git fetch`` command to run successfully without prompting 41for a password when you run it directly, you will be able to run ``west 42update`` without entering your password in that same shell. 43 44"'west' is not recognized as an internal or external command, operable program or batch file.' 45********************************************************************************************** 46 47On Windows, this means that either west is not installed, or your :envvar:`PATH` 48environment variable does not contain the directory where pip installed 49:file:`west.exe`. 50 51First, make sure you've installed west; see :ref:`west-install`. Then try 52running ``west`` from a new ``cmd.exe`` window. If that still doesn't work, 53keep reading. 54 55You need to find the directory containing :file:`west.exe`, then add it to your 56:envvar:`PATH`. (This :envvar:`PATH` change should have been done for you when 57you installed Python and pip, so ordinarily you should not need to follow these 58steps.) 59 60Run this command in ``cmd.exe``:: 61 62 pip3 show west 63 64Then: 65 66#. Look for a line in the output that looks like ``Location: 67 C:\foo\python\python38\lib\site-packages``. The exact location 68 will be different on your computer. 69#. Look for a file named ``west.exe`` in the ``scripts`` directory 70 ``C:\foo\python\python38\scripts``. 71 72 .. important:: 73 74 Notice how ``lib\site-packages`` in the ``pip3 show`` output was changed 75 to ``scripts``! 76#. If you see ``west.exe`` in the ``scripts`` directory, add the full path to 77 ``scripts`` to your :envvar:`PATH` using a command like this:: 78 79 setx PATH "%PATH%;C:\foo\python\python38\scripts" 80 81 **Do not just copy/paste this command**. The ``scripts`` directory location 82 will be different on your system. 83#. Close your ``cmd.exe`` window and open a new one. You should be able to run 84 ``west``. 85 86"Error: unexpected keyword argument 'requires_workspace'" 87********************************************************* 88 89This error occurs on some Linux distributions after upgrading to west 0.7.0 or 90later from 0.6.x. For example: 91 92.. code-block:: none 93 94 $ west update 95 [... stack trace ...] 96 TypeError: __init__() got an unexpected keyword argument 'requires_workspace' 97 98This appears to be a problem with the distribution's pip; see `this comment in 99west issue 373`_ for details. Some versions of **Ubuntu** and **Linux Mint** are known to 100have this problem. Some users report issues on Fedora as well. 101 102Neither macOS nor Windows users have reported this issue. There have been no 103reports of this issue on other Linux distributions, like Arch Linux, either. 104 105.. _this comment in west issue 373: 106 https://github.com/zephyrproject-rtos/west/issues/373#issuecomment-583489272 107 108**Workaround 1**: remove the old version, then upgrade: 109 110.. code-block:: none 111 112 $ pip3 show west | grep Location: | cut -f 2 -d ' ' 113 /home/foo/.local/lib/python3.6/site-packages 114 $ rm -r /home/foo/.local/lib/python3.6/site-packages/west 115 $ pip3 install --user west==0.7.0 116 117**Workaround 2**: install west in a Python virtual environment 118 119One option is to use the `venv module`_ that's part of the Python 3 standard 120library. Some distributions remove this module from their base Python 3 121packages, so you may need to do some additional work to get it installed on 122your system. 123 124.. _venv module: 125 https://docs.python.org/3/library/venv.html 126 127"invalid choice: 'build'" (or 'flash', etc.) 128******************************************** 129 130If you see an unexpected error like this when trying to run a Zephyr extension 131command (like :ref:`west flash <west-flashing>`, :ref:`west build 132<west-building>`, etc.): 133 134.. code-block:: none 135 136 $ west build [...] 137 west: error: argument <command>: invalid choice: 'build' (choose from 'init', [...]) 138 139 $ west flash [...] 140 west: error: argument <command>: invalid choice: 'flash' (choose from 'init', [...]) 141 142The most likely cause is that you're running the command outside of a 143:ref:`west workspace <west-workspace>`. West needs to know where your workspace 144is to find :ref:`west-extensions`. 145 146To fix this, you have two choices: 147 148#. Run the command from inside a workspace (e.g. the :file:`zephyrproject` 149 directory you created when you :ref:`got started <getting_started>`). 150 151 For example, create your build directory inside the workspace, or run ``west 152 flash --build-dir YOUR_BUILD_DIR`` from inside the workspace. 153 154#. Set the :envvar:`ZEPHYR_BASE` :ref:`environment variable <env_vars>` and re-run 155 the west extension command. If set, west will use :envvar:`ZEPHYR_BASE` to 156 find your workspace. 157 158If you're unsure whether a command is built-in or an extension, run ``west 159help`` from inside your workspace. The output prints extension commands 160separately, and looks like this for mainline Zephyr: 161 162.. code-block:: none 163 164 $ west help 165 166 built-in commands for managing git repositories: 167 init: create a west workspace 168 [...] 169 170 other built-in commands: 171 help: get help for west or a command 172 [...] 173 174 extension commands from project manifest (path: zephyr): 175 build: compile a Zephyr application 176 flash: flash and run a binary on a board 177 [...] 178 179"invalid choice: 'post-init'" 180***************************** 181 182If you see this error when running ``west init``: 183 184.. code-block:: none 185 186 west: error: argument <command>: invalid choice: 'post-init' 187 (choose from 'init', 'update', 'list', 'manifest', 'diff', 188 'status', 'forall', 'config', 'selfupdate', 'help') 189 190Then you have an old version of west installed, and are trying to use it in a 191workspace that requires a more recent version. 192 193The easiest way to resolve this issue is to upgrade west and retry as follows: 194 195#. Install the latest west with the ``-U`` option for ``pip3 install`` as shown 196 in :ref:`west-install`. 197 198#. Back up any contents of :file:`zephyrproject/.west/config` that you want to 199 save. (If you don't have any configuration options set, it's safe to skip 200 this step.) 201 202#. Completely remove the :file:`zephyrproject/.west` directory (if you don't, 203 you will get the "already in a workspace" error message discussed next). 204 205#. Run ``west init`` again. 206 207"already in an installation" 208**************************** 209 210You may see this error when running ``west init`` with west 0.6: 211 212.. code-block:: none 213 214 FATAL ERROR: already in an installation (<some directory>), aborting 215 216If this is unexpected and you're really trying to create a new west workspace, 217then it's likely that west is using the :envvar:`ZEPHYR_BASE` :ref:`environment 218variable <env_vars>` to locate a workspace elsewhere on your system. 219 220This is intentional; it allows you to put your Zephyr applications in 221any directory and still use west to build, flash, and debug them, for example. 222 223To resolve this issue, unset :envvar:`ZEPHYR_BASE` and try again. 224