flipperdevices / flipperzero-ufbt

Compact tool for building and debugging applications for Flipper Zero.
https://pypi.org/project/ufbt/
GNU General Public License v3.0
598 stars 40 forks source link

Problems running vscode_dist #51

Open eblis opened 1 month ago

eblis commented 1 month ago

I tried to run ufbt vscode_dist and had a few issues.

After all these issues it's failing with this error:

Cleaning up temp toolchain path..
Extracting Windows toolchain..moving..An error occurred
Access to the path 'C:\Users\<user>\.ufbt\current\gcc-arm-none-eabi-12.3-x86_64-windows-flipper' is denied.
Please close VSCode and any other programs that may be using the toolchain and try again.
scons: Entering directory `C:\Users\<user>\.ufbt\current\scripts\ufbt'
scons: *** Toolchain binary arm-none-eabi-ar not found in PATH.  Stop.
hedger commented 1 month ago

It does not work with Python 3.9, where the docs I saw said it will work with Python >= 3.7.

  1. ufbt requires Python 3.8, as stated in the package manifest and readme. Could you please point out where exactly does it mention Python 3.7?

The problem is that it uses the | notation for multiple types

Please provide stack trace for that error.

  1. ufbt downloads and unpacks the SDK, which in turn sets up the environment using pre-built toolchain it downloads. Both ansi and scons packages are in that toolchain and do not require any manual installation.

Please provide more information on your configuration, commands you are executing, and error messages you're getting.

eblis commented 1 month ago

I am using poetry for dependency management and venv. It will automatically create a venv for the "project" and keep python dependencies contained to that venv.

I installed ufbt using poetry add ufbt in a poetry environment for Python 3.9.13 set up with pyenv - this should grab all dependencies listed for ufbt. I remembered reading Python >=3.7, but still, 3.9 should be ok since it's saying 3.8 is minimum.

Running poetry run ufbt vscode_dist i have the following error:

Cleaning up temp toolchain path..
Extracting Windows toolchain..moving..An error occurred
Access to the path 'C:\Users\<user>\.ufbt\current\gcc-arm-none-eabi-12.3-x86_64-windows-flipper' is denied.
Please close VSCode and any other programs that may be using the toolchain and try again.
C:\Users\<user>\AppData\Local\pypoetry\Cache\virtualenvs\flipper-qIvlI9iJ-py3.9\Scripts\python.exe: No module named SCons

So I installed poetry add scons. At one point I got a similar error for ansi package so I also installed ansi package. Trying to reproduce it just now I didn't get the error again, but I didn't start with a fresh env, so maybe that's why.

Running poetry run ufbt vscode_dist i have the following error:

Cleaning up temp toolchain path..
Extracting Windows toolchain..moving..An error occurred
Access to the path 'C:\Users\<user>\.ufbt\current\gcc-arm-none-eabi-12.3-x86_64-windows-flipper' is denied.
Please close VSCode and any other programs that may be using the toolchain and try again.
scons: Entering directory `C:\Users\<user>\.ufbt\current\scripts\ufbt'
TypeError: unsupported operand type(s) for |: '_CallableType' and 'NoneType':
  File "C:\Users\<user>\.ufbt\current\scripts\ufbt\SConstruct", line 46:
    from fbt.appmanifest import FlipperApplication, FlipperAppType
  File "C:\Users\<user>\.ufbt\current\scripts\fbt\appmanifest.py", line 246:
    class AppBuildset:
  File "C:\Users\<user>\.ufbt\current\scripts\fbt\appmanifest.py", line 284:
    message_writer: Callable | None = None,

The | notation isn't available in 3.9 either, so we switch to Python 3.11

pyenv local 3.11.6
poetry env use python
poetry install

Which brings us to the final error:

Cleaning up temp toolchain path..
Extracting Windows toolchain..moving..An error occurred
Access to the path 'C:\Users\<user>\.ufbt\current\gcc-arm-none-eabi-12.3-x86_64-windows-flipper' is denied.
Please close VSCode and any other programs that may be using the toolchain and try again.
scons: Entering directory `C:\Users\<user>\.ufbt\current\scripts\ufbt'
scons: *** Toolchain binary arm-none-eabi-ar not found in PATH.  Stop.

I get the same error even if I enter the venv shell with poetry shell and then run the vscode_dist command.

hedger commented 1 month ago

It seems that poetry does something that conflicts with the way ufbt sets up its environment.

ufbt itself has minimal dependencies (a single oslex package) and had been verified to be functional when being installed using pipx. I suggest you either use pipx or basic venv for setting up ufbt. Please check if that works on your system.

We'll investigate poetry compatibility.