flipperzero-ufbt icon indicating copy to clipboard operation
flipperzero-ufbt copied to clipboard

TypeError: 'float' object is not iterable in fbt_extapps.py

Open nazarhktwitch opened this issue 10 months ago • 0 comments

When attempting to build the firmware using ufbt build, the following error occurs:

TypeError: 'float' object is not iterable:
  File "C:\Users\nazar\.ufbt\current\scripts\ufbt\SConstruct", line 248:
    app_artifacts = appenv.BuildAppElf(app)
  File "C:\Users\nazar\.ufbt\toolchain\x86_64-windows\python\Lib\site-packages\SCons\Util\envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "C:\Users\nazar\.ufbt\current\scripts\fbt_tools\fbt_extapps.py", line 261:
    env["EXT_APPS"][app.appid] = app_artifacts = app_builder.build()
  File "C:\Users\nazar\.ufbt\current\scripts\fbt_tools\fbt_extapps.py", line 48:
    self._setup_app_env()
  File "C:\Users\nazar\.ufbt\current\scripts\fbt_tools\fbt_extapps.py", line 61:
    ("FAP_VERSION", f'\\"{".".join(map(str, self.app.fap_version))}\\"'),

Problem:

The issue originates from a TypeError in the file fbt_extapps.py, where the function is attempting to iterate over a float value. Specifically, the error is caused by the line that tries to join elements of self.app.fap_version:

("FAP_VERSION", f'\\"{".".join(map(str, self.app.fap_version))}\\"')

If self.app.fap_version contains float values, it will cause an issue since join expects an iterable of strings, and map(str, self.app.fap_version) will fail if fap_version is not an iterable of strings.

Proposed Solution:

To fix the issue, the code should be updated to ensure that self.app.fap_version is properly converted to strings before attempting to join them. The updated function should look like this:

def _setup_app_env(self):
    # Clone the environment
    self.app_env = self.fw_env.Clone(
        FAP_SRC_DIR=self.app._appdir,
        FAP_WORK_DIR=self.app_work_dir,
    )

    # Ensure fap_version is a list of strings
    fap_version_str = '.'.join(map(str, self.app.fap_version))  # Convert elements to strings before joining

    # Add the version and other defines
    self.app_env.Append(
        CPPDEFINES=[
            ("FAP_VERSION", f'\\"{fap_version_str}\\"'),
            *self.app.cdefines,
        ],
    )

    # Set the variant directory for the build
    self.app_env.VariantDir(self.app_work_dir, self.app._appdir, duplicate=False)

This change ensures that the fap_version is always treated as a sequence of strings, preventing the TypeError from occurring.

Additional Information:

  • The issue occurs during the build process when using the ufbt build command.
  • It is critical to properly convert fap_version to a string format to ensure the correct handling of the version number.
  • After ufbt -c fix automatically deletes and changes to old version, I set for now 'Only reading' flag

nazarhktwitch avatar Feb 24 '25 15:02 nazarhktwitch