I have an error compiling a cloud function with Dart 3.1
Here is some information :
Function is in auto-deploy from Github on a self-hosted instance
".env" has these two lines and Dart 3.1 is correctly detected
_APP_FUNCTIONS_RUNTIMES=node-16.0,php-8.0,python-3.9,ruby-3.0,dart-3.1
_APP_FUNCTIONS_ENVS=node-16.0,php-7.4,python-3.9,ruby-3.0,dart-3.1
here is my "pubspec.yaml"
name: starter_template
version: 1.0.0
environment:
sdk: ^3.1.0
dependencies:
dart_appwrite: ^10.0.0
dev_dependencies:
lints: ^3.0.0
here is my dart code in "lib/main.dart" code
import "dart:async";
import "dart:io";
import "package:dart_appwrite/dart_appwrite.dart";
Future<dynamic> main(final context) async {
final Map<String, String> envVars = Platform.environment;
final client = Client()
.setEndpoint("https://backend.diskmth.fr/v1")
.setProject(envVars["APPWRITE_FUNCTION_PROJECT_ID"])
.setKey(envVars["APPWRITE_API_KEY"]);
context.log("Hello, Logs!");
context.log(envVars);
context.error("Hello, Errors!");
if (context.req.method == "GET") {
return context.res.send("Hello, World!");
}
return context.res.json({
"motto": "Build like a team of hundreds_",
"learn": "https://appwrite.io/docs",
"connect": "https://appwrite.io/discord",
"getInspired": "https://builtwith.appwrite.io",
});
}
and finally here is the error I get during the deployement
Docker Error: Preparing for build ...
Resolving dependencies...
+ async 2.11.0
+ boolean_selector 2.1.1
+ collection 1.18.0
+ matcher 0.12.16
+ meta 1.11.0
+ path 1.8.3
+ pub_semver 2.1.4
+ pubspec 2.3.0
+ quiver 3.2.1
+ source_span 1.10.0
+ stack_trace 1.11.1
+ stream_channel 2.1.2
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ test_api 0.6.1
+ uri 1.0.0
+ yaml 3.1.2
Changed 17 dependencies!
found user package starter_template
added user package as dependency to server.
Updated server import of user code
Building ...
Resolving dependencies...
+ async 2.11.0
+ collection 1.18.0
+ dart_appwrite 10.0.0
+ http 1.0.0 (1.1.0 available)
+ http_parser 4.0.2
+ meta 1.11.0
+ path 1.8.3
+ shelf 1.4.1
+ source_span 1.10.0
+ stack_trace 1.11.1
+ starter_template 1.0.0 from path /usr/local/build
+ stream_channel 2.1.2
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ typed_data 1.3.2
Changed 15 dependencies!
Compiling ...
src/server.dart:5:8: Error: Error when reading '../build/lib/lin/main.dart': No such file or directory
import 'package:starter_template/lin/main.dart' as user_code;
^
src/server.dart:115:25: Error: Method not found: 'main'.
user_code.main(context)
^^^^
src/server.dart:125:38: Error: Method not found: 'main'.
output = await user_code.main(context);
^^^^
Error: AOT compilation failed
Generating AOT kernel dill failed!
If you have any ideas as to why I'm getting this error, I'd love some help.
Thanks in advance
What's your folder structure and what are the function root and entrypoint options for your function?
The root is the root of my repo branch and my entry point is lib/main.dart
And my branch looks like this :
Discord
Would you please share a screenshot?
Yep
Discord
You have a typo in your entrypoint
Oh f***, my bad I'll correct tomorrow and closed the ticket if it's good. If it's just this, sorry for the time waste π₯Ί
No worries!
Ok the function deploy now works thanks π
[SOLVED] Function compilation error Dart 3.1
Recommended threads
- [SOLVED] curl error Number: 6 β function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- ClientException with SocketException: Cl...
hi <@564158268319203348> i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as reque...
- NEW ERROR Invalid document structure: At...
Error: ```AppwriteException: document_invalid_structure, Invalid document structure: Attribute "pb.kmsgxPkgInfo.id_info" must be an array (400)``` Iβm encounter...