fix: Jaspr Build Fail On New Project
Description
Jaspr fails when trying to start a new project in a container. The issue was not observed outside a container.
Output
The below output was run inside a container. Based on the below output, does jaspr build currently fail if there is any stderr output from flutter? Running as root is common in containers and the message from flutter is expected. Other than that, nothing useful from --verbose. This is my usual flutter dev environment I always use.
root@c-nixos:/workspaces/voyver_website (jaspr)$ jaspr create voyver_website
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
Select a rendering mode: static: Build a statically pre-rendered site.
(Recommended) Enable automatic hydration on the client? (Y/n) Yes
Setup routing for different pages of your site? (Y/n) Yes
(Recommended) Use multi-page (server-side) routing? Choosing [no] sets up a single-page application with client-side routing instead. (Y/n) Yes
Setup Flutter web embedding? (y/N) No
Enable support for using Flutter web plugins in your project? (Y/n) Yes
β Generated 25 file(s) (0.2s)
β [CLI] [ERROR] Woah! You appear to be trying to run flutter as root. (5ms)
[CLI] [ERROR] We strongly recommend running the flutter tool without superuser privileges.
[CLI] [ERROR] /
[CLI] [ERROR] π
β [CLI] (15.4s)
Created project voyver_website! In order to get started, run the following commands:
cd voyver_website
jaspr serve
root@c-nixos:/workspaces/voyver_website (jaspr)$ cd voyver_website/
root@c-nixos:/workspaces/voyver_website/voyver_website (jaspr)$ jaspr serve
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
Running jaspr in static rendering mode.
[BUILDER] [ERROR] Unsupported operation: Calling "flutter doctor" resulted in: " Woah! You appear to be trying to run flutter as root.
[BUILDER] [ERROR] We strongly recommend running the flutter tool without superuser privileges.
[BUILDER] [ERROR] /
[BUILDER] [ERROR] π
[BUILDER] [ERROR] ". Make sure flutter is installed and setup correctly.
Bad state: Unable to start build daemon.
root@c-nixos:/workspaces/voyver_website/voyver_website (jaspr)$ jaspr doctor
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
[β] Jaspr CLI (Version 0.15.1)
β’ Dart Version 3.5.2 (stable) (Wed Aug 28 10:01:20 2024 +0000) on "linux_x64" at /usr/local/flutter/bin/cache/dart-sdk/bin/dart
β’ Running on linux Linux 6.9.7 #1-NixOS SMP PREEMPT_DYNAMIC Thu Jun 27 11:52:32 UTC 2024 - Locale en_US.UTF-8
β’ Analytics: Enabled
[β] Current Project
β’ Dependencies on core packages:
β’ jaspr: ^0.15.1
β’ jaspr_builder: ^0.15.1 (dev)
β’ jaspr_web_compilers: ^4.0.10 (dev)
β’ jaspr_router: ^0.5.1
β’ Rendering mode: static
β’ Uses jaspr compilers: true
β’ Uses flutter embedding: false
root@c-nixos:/workspaces/voyver_website/voyver_website (jaspr)$ jaspr build --verbose
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
Building jaspr for static rendering mode.
Building web assets...
[BUILDER] Generating build script...
[BUILDER] Generating build script completed, took 297ms
[BUILDER] Invalidated precompiled build script due to missing asset graph.
[BUILDER] Precompiling build script......
[BUILDER] Precompiling build script... completed, took 642ms
[BUILDER] Starting daemon...
[BUILDER] [ERROR] Unsupported operation: Calling "flutter doctor" resulted in: " Woah! You appear to be trying to run flutter as root.
[BUILDER] [ERROR] We strongly recommend running the flutter tool without superuser privileges.
[BUILDER] [ERROR] /
[BUILDER] [ERROR] π
[BUILDER] [ERROR] ". Make sure flutter is installed and setup correctly.
Bad state: Unable to start build daemon.
This isn't really something jaspr can control I think cause it needs to run flutter for certain things. The proper solution would be to create a non-root user.
If you don't need flutter plugin support, you can also select 'No' for "Enable support for using Flutter web plugins in your project? (Y/n)", which should workaround that.
Just to clarify, Flutter runs fine in my container. It's just that warning message is expected. My only thought was, maybe Jaspr is failing because it gets a message on stderr, then that is something Jaspr can fix. If this is not the case, then this is still a bug as I expect Jaspr to work since this environment has everything Jaspr should need.
Ah thanks for clarifying. That could be the case.
To make it easier for me to debug, can you run 'dart run build_runnrr build' instead of jaspr build and see of it also fails?
Sure
root@c-nixos:/workspaces/voyver_website/voyver_website (jaspr)$ dart run build_runner build
Building package executable... (2.4s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 177ms
[WARNING] Invalidated precompiled build script due to core package update
[INFO] Precompiling build script... completed, took 2.4s
[SEVERE]
Unsupported operation: Calling "flutter doctor" resulted in: " Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
". Make sure flutter is installed and setup correctly.
package:jaspr_web_compilers/src/common.dart 20:5 webSdkDir.<fn>
package:jaspr_web_compilers/src/common.dart 36:3 webSdkDir
package:jaspr_web_compilers/src/common.dart webSdkDir
package:jaspr_web_compilers/builders.dart 58:20 ddcKernelBuilder
package:build_runner BuildCommand._run
package:args/command_runner.dart 212:13 CommandRunner.runCommand
package:build_runner run
.dart_tool/build/entrypoint/build.dart 229:16 main
root@c-nixos:/workspaces/voyver_website/voyver_website (jaspr)$ flutter --version
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
π
Flutter 3.24.2 β’ channel stable β’ https://github.com/flutter/flutter.git
Framework β’ revision 4cf269e36d (2 weeks ago) β’ 2024-09-03 14:30:00 -0700
Engine β’ revision a6bd3f1de1
Tools β’ Dart 3.5.2 β’ DevTools 2.37.2
This does seem to be the case
https://github.com/schultek/build/blob/5f5e40806899ff71fe611af5d691320240a60206/jaspr_web_compilers/lib/src/common.dart#L19
Checking exit code may be a better idea
I'm also running into this when trying to build/deploy my website
@mcmah309 Can you try with jaspr_web_compilers: 4.0.10+1
Sure, but there doesn't seem to be a change to the file I linked to, so I'm almost positive it will still fail. Unless I missed something?
The newest version 4.1.0 is released now and includes the fix.
A little dishonest to merge the fix I had in a PR months ago as your own work.. but at least itβs fixed
@mcmah309 Can you try with
jaspr_web_compilers: 4.0.10+1
I had it already done and released there, just not merged to master.