New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
esptool.py misses the shebang line (IDFGH-9577) #10926
Comments
@xinwenfu Are you running the command from an ESP-IDF environment, i.e. from a terminal where The suggested shebang is not necessary. |
The context is I tried to do everything within VS Code with the ESP-IDF Explorer. ESP-IDF was installed through VS Code. With this setup, I did run esptool.py from an ESP-IDF environment after running . export.sh within either a Linux terminal or ESP-IDF terminal of VS-Code. Here are the errors without the shebang line $ esptool.py |
I don't think you have esptool installed or @brianignacio5 Could you please check this issue please? I don't exactly know how this should work in the case of Vscode. If the esptool package is installed then |
Below is what I got after running export.sh within an ESP-IDF terminal within VS code. Apprently, /home/iot/esp/esp-idf/components/esptool_py/esptool (where esptool.py is located) is added to PATH. esptool.py is only available in /home/iot/esp/esp-idf/components/esptool_py/esptool in the entire esp/esp-idf folder. $ . $HOME/esp/esp-idf/export.sh Detected installed tools that are not currently used by active ESP-IDF version. Done! You can now compile ESP-IDF projects. idf.py build |
I assume that we cannot fix your issue on the ESP-IDF side. I can advise to uninstall Vscode, un-do all the settings in environment variables and try to set it up based on instructions at https://github.com/espressif/vscode-esp-idf-extension. If you still experience the issue then please report it at https://github.com/espressif/vscode-esp-idf-extension/issues. |
@dobairoland From what the user @xinwenfu is telling I don't see any vscode extension configuration being used. Maybe is related to the current terminal being used in vscode as shown in Terminal shells vscode documentation. If you are using the esp-idf vscode extension please open an issue with required troubleshooting information as @dobairoland mentioned. |
I reinstalled everything, including VS Code, the esp-idf extension and esp-idf based on instructions at https://github.com/espressif/vscode-esp-idf-extension. When I opened ESP-IDF Terminal within VS Code, the same error happened. I had to add the shebang line so that esptool.py works. |
@brianignacio5 If esptool is installed with |
There is a very easy way to check which Python packages are in the virtual env with the Isn't |
That is a leftover. We can remove it if it helps. But I don't understand why is this happening with Vscode only. I have not seen reports from those who use ESP-IDF terminal without Vscode. |
@xinwenfu Could you please check the files in |
Within the Terminal in VS Code with the ESP-IDF Explorer, if I run export.sh, it still adds /home/iot/esp/esp-idf/components/esptool_py/esptool to PATH as shown below. export.sh is executable. But it is treated as a general Linux script without that shbang line. . $HOME/esp/esp-idf/export.sh idf.py build |
esptool.py is executable. But it is treated as a general Linux script without that shebang line. |
Maybe your local git configuration makes it executable. It should not be executable if git is not configured to change that on local checkout:
In the above case, the attribute would be 755 if the executable bit would be set. |
Please try to remove If the environment is correctly installed then |
Esptool.py is available from the esptool package which is installed in every ESP-IDF v5.0+ shells. Therefore, the path to the legacy wrapper scripts is not needed to be in the PATH. In some cases like #10926 it even cases problem because the wrapper doesn't have a shebang line and is not executable. Note that the wrapper is kept only for invoking esptool as "python $IDF_PATH/..../esptool.py" which was previously used mostly in CMake files. There should be no other use-case where the esptool wrappers are still needed.
Esptool.py is available from the esptool package which is installed in every ESP-IDF v5.0+ shells. Therefore, the path to the legacy wrapper scripts is not needed to be in the PATH. In some cases like #10926 it even cases problem because the wrapper doesn't have a shebang line and is not executable. Note that the wrapper is kept only for invoking esptool as "python $IDF_PATH/..../esptool.py" which was previously used mostly in CMake files. There should be no other use-case where the esptool wrappers are still needed.
I got time to revisit the issue. export.sh has issues and has the following line adding the components/esptool_py/esptool to PATH. IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool" After running . $HOME/esp/esp-idf/export.sh, the wrong esptool.py is then used even if sudo apt install esptool is used to install the esptool package. |
Please check the linked commits above. This is not true anymore. |
Yesterday, I followed https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html and installed ESP-IDF again. export.sh still had the issue. Thought the problem was still there. Good to know it is resolved. Thanks |
Answers checklist.
General issue report
esp-idf/components/esptool_py/esptool/esptool.py misses the following shebang line and will not run normally as described at https://docs.espressif.com/projects/esptool/en/latest/esp32s3/esptool/basic-commands.html
#!/usr/bin/env python
The text was updated successfully, but these errors were encountered: