Skip to content

bug: Build fails due to macro redefined error #6173

Closed

Description

@jnsh

Building any Flet application suddenly fails.

This can be reproduced with:

flet create
flet build linux

The build fails with the following error:

[16:04:05] Created app shell ✅                                                                                       
[16:04:19] Packaged Python app ✅                                                                                     
[16:04:25] Customized app icons ✅                                                                                    
[16:04:29] Generated app icons ✅                                                                                     
[16:05:37] Resolving dependencies...                                                                                  
           Downloading packages...                                                                                    
             characters 1.4.0 (1.4.1 available)                                                                       
           ! flet 0.80.5 (overridden)                                                                                 
             flutter_lints 2.0.3 (6.0.0 available)                                                                    
             flutter_native_splash 2.4.6 (2.4.7 available)                                                            
             lints 2.1.1 (6.1.0 available)                                                                            
             material_color_utilities 0.11.1 (0.13.0 available)                                                       
             meta 1.17.0 (1.18.1 available)                                                                           
           ! package_info_plus 9.0.0 (overridden)                                                                     
             petitparser 6.1.0 (7.0.2 available)                                                                      
             shared_preferences 2.5.3 (2.5.4 available)                                                               
             toml 0.15.0 (0.18.0 available)                                                                           
           ! wakelock_plus 1.4.0 (overridden)                                                                         
             xml 6.5.0 (6.6.1 available)                                                                              
           Got dependencies!                                                                                          
           10 packages have newer versions incompatible with dependency constraints.                                  
           Try `flutter pub outdated` for more information.                                                           
           Building Linux application...                                                                              
                                                                                                                      
           /home/work/flet-build-test/build/flutter/build/linux/x64/release/python/include/python3.12/pyconfig.h:1877:
           9: error: '_POSIX_C_SOURCE' macro redefined [-Werror,-Wmacro-redefined]                                    
           /home/work/flet-build-test/build/flutter/build/linux/x64/release/python/include/python3.12/pyconfig.h:1898:
           9: error: '_XOPEN_SOURCE' macro redefined [-Werror,-Wmacro-redefined]                                      
           Build process failed                                                                                       
                                                                                                                      
[16:05:38] Doctor summary (to see all details, run flutter doctor -v):                                                
           [!] Flutter (Channel stable, 3.38.7, on Arch Linux 6.18.9-zen1-2-zen, locale en_US.UTF-8)                  
               ! The flutter binary is not on your path. Consider adding /home/work/flutter/3.38.7/bin to your path.  
               ! The dart binary is not on your path. Consider adding /home/work/flutter/3.38.7/bin to your path.     
           [✗] Android toolchain - develop for Android devices                                                        
               ✗ Unable to locate Android SDK.                                                                        
                 Install Android Studio from: https://developer.android.com/studio/index.html                         
                 On first launch it will assist you in installing the Android SDK components.                         
                 (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).                     
                 If the Android SDK has been installed to a custom location, please use                               
                 `flutter config --android-sdk` to update to that location.                                           
                                                                                                                      
           [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)                          
               ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.                            
           [✓] Linux toolchain - develop for Linux desktop                                                            
               ! Unable to access driver information using 'eglinfo'.                                                 
                 It is likely available from your distribution (e.g.: apt install mesa-utils)                         
           [✓] Connected device (1 available)                                                                         
           [✓] Network resources                                                                                      
                                                                                                                      
           ! Doctor found issues in 3 categories.                                                                     
                                                                                                                      
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Error building Flet app - see the log of failed command above.                                                     │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Operating system: Arch Linux

Flet version:

$ flet --version
Flet: 0.80.5
Flutter: 3.38.7
Pyodide: 0.27.7

I have been able to build successfully with Flet 0.80.* series before, but not sure if I tested on 0.80.5 specifically.

I attempted to build with Flet 0.80.4, but that failed with a different error:

Different build error on 0.80.4
$ flet build linux
[16:15:34] Created app shell ✅                                                                                       
[16:15:50] Running build hooks...Running build hooks...Running package command                                        
           Extra PyPi indexes:                                                                                        
           Creating asset directory: /home/work/flet-build-test/build/flutter/app                                     
           Created temp directory: /tmp/serious_python_tempNWOXWK                                                     
           Copying Python app from /home/work/flet-build-test/src to a temp directory                                 
           Configured Linux/ platform with sitecustomize.py                                                           
           Installing  with pip command to /home/work/flet-build-test/build/site-packages                             
           Downloading Python distributive from                                                                       
           https://github.com/astral-sh/python-build-standalone/releases/download/20250205/cpython-3.12.9+20250205-x86
           _64-unknown-linux-gnu-install_only_stripped.tar.gz to a build directory                                    
           Extracting Python distributive                                                                             

           ERROR: Exception:                                                                                          
           Traceback (most recent call last):                                                                         
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/shutil.py", line 
           847, in move                                                                                               
               os.rename(src, real_dst)                                                                               
           OSError: [Errno 18] Invalid cross-device link: '/tmp/pip-target-pe5rfkmx/lib/python/flet-0.80.5.dist-info' 
           -> '/home/work/flet-build-test/build/site-packages/flet-0.80.5.dist-info'                                  
                                                                                                                      
           During handling of the above exception, another exception occurred:                                        
                                                                                                                      
           Traceback (most recent call last):                                                                         
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/site-packages/pip
           /_internal/cli/base_command.py", line 105, in _run_wrapper                                                 
               status = _inner_run()                                                                                  
                        ^^^^^^^^^^^^                                                                                  
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/site-packages/pip
           /_internal/cli/base_command.py", line 96, in _inner_run                                                    
               return self.run(options, args)                                                                         
                      ^^^^^^^^^^^^^^^^^^^^^^^                                                                         
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/site-packages/pip
           /_internal/cli/req_command.py", line 67, in wrapper                                                        
               return func(self, options, args)                                                                       
                      ^^^^^^^^^^^^^^^^^^^^^^^^^                                                                       
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/site-packages/pip
           /_internal/commands/install.py", line 519, in run                                                          
               self._handle_target_dir(                                                                               
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/site-packages/pip
           /_internal/commands/install.py", line 578, in _handle_target_dir                                           
               shutil.move(os.path.join(lib_dir, item), target_item_dir)                                              
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/shutil.py", line 
           863, in move                                                                                               
               copytree(src, real_dst, copy_function=copy_function,                                                   
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/shutil.py", line 
           600, in copytree                                                                                           
               return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,                                 
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                 
             File                                                                                                     
           "/home/work/flet-build-test/build/flutter/build/build_python_3.12.9/python/lib/python3.12/shutil.py", line 
           498, in _copytree                                                                                          
               os.makedirs(dst, exist_ok=dirs_exist_ok)                                                               
             File "<frozen os>", line 225, in makedirs                                                                
           OSError: [Errno 28] No space left on device:                                                               
           '/home/work/flet-build-test/build/site-packages/flet-0.80.5.dist-info'                                     
                                                                                                                      
[16:15:51] Doctor summary (to see all details, run flutter doctor -v):                                                
           [!] Flutter (Channel stable, 3.38.7, on Arch Linux 6.18.9-zen1-2-zen, locale en_US.UTF-8)                  
               ! The flutter binary is not on your path. Consider adding /home/work/flutter/3.38.7/bin to your path.  
               ! The dart binary is not on your path. Consider adding /home/work/flutter/3.38.7/bin to your path.     
           [✗] Android toolchain - develop for Android devices                                                        
               ✗ Unable to locate Android SDK.                                                                        
                 Install Android Studio from: https://developer.android.com/studio/index.html                         
                 On first launch it will assist you in installing the Android SDK components.                         
                 (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).                     
                 If the Android SDK has been installed to a custom location, please use                               
                 `flutter config --android-sdk` to update to that location.                                           
                                                                                                                      
           [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)                          
               ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.                            
           [✓] Linux toolchain - develop for Linux desktop                                                            
               ! Unable to access driver information using 'eglinfo'.                                                 
                 It is likely available from your distribution (e.g.: apt install mesa-utils)                         
           [✓] Connected device (1 available)                                                                         
           [✓] Network resources                                                                                      
                                                                                                                      
           ! Doctor found issues in 3 categories.                                                                     
                                                                                                                      
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Error building Flet app - see the log of failed command above.                                                     │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Activity

  1. bekemax commented on Jul 4, 2026

    @bekemax

    Same issue, Ubuntu 26.04, Flet 0.85.3, Flutter 3.41.7

  2. jnsh commented on Jul 6, 2026

    @jnsh
    Author

    As a workaround, you can patch the build files with this:

    --- build/flutter/build/linux/x64/release/python/include/python3.12/pyconfig.h.old	2026-02-27 00:59:10.383306869 +0200
    +++ build/flutter/build/linux/x64/release/python/include/python3.12/pyconfig.h	2026-02-27 01:00:48.793494327 +0200
    @@ -1874,7 +1874,9 @@
     #define _NETBSD_SOURCE 1
     
     /* Define to activate features from IEEE Stds 1003.1-2008 */
    -#define _POSIX_C_SOURCE 200809L
    +#ifndef _POSIX_C_SOURCE
    +# define _POSIX_C_SOURCE 200809L
    +#endif
     
     /* Define if you have POSIX threads, and your system does not define that. */
     /* #undef _POSIX_THREADS */
    @@ -1895,7 +1897,9 @@
     /* #undef _WASI_EMULATED_SIGNAL */
     
     /* Define to the level of X/Open that your system supports */
    -#define _XOPEN_SOURCE 700
    +#ifndef _XOPEN_SOURCE
    +# define _XOPEN_SOURCE 700
    +#endif
     
     /* Define to activate Unix95-and-earlier features */
     #define _XOPEN_SOURCE_EXTENDED 1

    Run flet build linux once to generate the build files and apply the patch once the build fails. After that re-building works for me.

  3. FeodorFitsner commented on Jul 6, 2026

    @FeodorFitsner
    Contributor

    Flet 0.86.0 doesn't have this bug as Python runtime management moved to a separate library.

  4. self-assigned this
    on Jul 6, 2026
  5. added this to the 0.86.0 milestone on Jul 8, 2026
  6. moved this from 🆕 New to 🏗 In progress in Flet Developmenton Jul 8, 2026
  7. ndonkoHenri commented on Sep 12, 2026

    @ndonkoHenri
    Contributor

    Closing — this was fixed in Flet 0.86.0.

    Why it appeared out of nowhere

    The trigger wasn't Flet, it was glibc 2.43. pyconfig.h defines _POSIX_C_SOURCE and_XOPEN_SOURCE unguarded, and up to glibc 2.42 it defined them to exactly the values glibc's own features.h uses — so the redefinition was token-identical and the preprocessor said nothing. glibc 2.43 raised them:

    glibc _POSIX_C_SOURCE _XOPEN_SOURCE
    ≤ 2.42 200809L 700
    ≥ 2.43 202405L 800

    (glibc commit a5cc3018f31a, "Add feature test macros for POSIX.1-2024".)

    From that point the redefinition genuinely differs, -Wmacro-redefined fires, and the -Werror in the Flutter Linux runner turns it into a build failure. It's -Werror doing the promoting, not clang specifically — GCC fails the same way.

    That also explains the timing and who was hit. @jnsh — Arch shipped glibc 2.43+r5 on 2026-02-09, one week before you filed this, and the package before it (26 Jan) still had the old values. That matches your "I have been able to build successfully with Flet 0.80.* series before": same Flet, new glibc. @bekemax — Ubuntu 26.04 also ships 2.43. Anyone on glibc ≤ 2.42 (Ubuntu 24.04, our CI) never saw it, which is why this looked so sporadic.

    The Flet-side precondition was serious_python_linux <= 2.0.0: its GTK plugin did #include <Python.h> after <gtk/gtk.h> had already pulled in features.h, with the extracted CPython headers on the include path — hence build/linux/x64/release/python/include/python3.12/pyconfig.h in the error.

    What fixed it

    flet-dev/serious-python#209 removed both the #include <Python.h> and the CPython include directory from the Linux plugin — the Python lifecycle now lives in a prebuilt libdart_bridge.so. That shipped as serious_python_linux 3.0.0 and reached Flet in #6601.

    Nothing in a stock flet build linux compiles against CPython headers any more, so the header is never reached on any glibc. The released pins go straight from serious_python 1.0.1 (v0.85.3, affected) to 4.3.2 (v0.86.0, clean), which makes 0.86.0 a clean boundary. Confirmed by inspection on 0.86.5, 1.0.0.dev2 and main.

    If you're on 0.85.3 or older

    The fix can't be backported — those releases resolve their build template by version, and their serious_python constraint can't reach the fixed release. Locally, either:

    One caveat worth recording

    The fix is that nothing compiles the header any more, not that the header was fixed. pyconfig.h still ships with the unguarded defines and the Linux template still applies -Werror to every plugin target, so a third-party Flet extension whose Linux plugin embeds CPython can still hit this on glibc ≥ 2.43 — -Wno-macro-redefined is the answer there too.

    Thanks @jnsh for the precise patch, and @bekemax for the second data point. If anyone still sees this on 0.86.5+ after a flet clean, comment here and I'll reopen.

  8. moved this from 🏗 In progress to ✅ Done in Flet Developmenton Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions