8000 🐛 Bug Report: Dart Runtime expects the `entrypoint` file to be inside `lib` folder · Issue #6202 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🐛 Bug Report: Dart Runtime expects the entrypoint file to be inside lib folder #6202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
ItzNotABug opened this issue Sep 9, 2023 · 4 comments
Closed
2 tasks done
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@ItzNotABug
Copy link
Member

👟 Reproduction steps

This issue has been moved here from open-runtimes#194, as suggested by Steven on Discord.


Previously on 1.3x the entry point file was allowed to be used in the root directory & it wasn't necessary that it should be inside lib directory.

However, on 1.4x function building fails.
Even the default path for the entry point is lib/main.dart if Platform.environment['OPEN_RUNTIMES_ENTRYPOINT'] is null.

If the entry point is in the root directory, the build fails with below error:

server.dart:5:8: Error: Error when reading 'lib/main.dart': No such file or directory
import 'package:packageName/main.dart' as user_code;
       ^
server.dart:107:25: Error: Method not found: 'main'.
              user_code.main(context)
                        ^^^^
server.dart:117:38: Error: Method not found: 'main'.
            output = await user_code.main(context);

Build works fine if the main.dart is inside the lib folder.


The error stems from here, I believe:

serv = serv.replaceAll('{entrypoint}', "package:$packageName/" + fileName);

Proposed solution:

  1. Add relevant info to docs to follow the standard Dart file structure convention
  2. Move the entry point inside the lib directory when building the function.

👍 Expected behavior

  1. Like previous versions, allow using the entrypoint as mentioned while deploying the Function.
  2. Use the Dart's standard file structure convention and let the developer know about this via Docs.
  3. Simply move the entrypoint file inside the lib folder when preparing for the build.

👎 Actual Behavior

Function build process fails with below error:

Error: Method not found: 'main'.
              user_code.main(context)
                        ^^^^
server.dart:117:38: Error: Method not found: 'main'.
            output = await user_code.main(context);

🎲 Appwrite version

Version 1.4.x

💻 Operating system

Linux

🧱 Your Environment

Nothing fancy, just the same old localhost.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@ItzNotABug ItzNotABug added the bug Something isn't working label Sep 9, 2023
@eldadfux eldadfux added the product / functions Fixes and upgrades for the Appwrite Functions. label Sep 9, 2023
@Meldiron
Copy link
Contributor

Heyy 👋
No final decision yet, but we are considering enforcing lib folder. It's a good practice, and trying to support functions without lib folder might be tricky. We cant simply move files in 1.4, as we now support rootDirectory and custom build commands.

@ItzNotABug
Copy link
Member Author

Hmm, even I believe enforcing lib folder structure is a good way.
I suggest implementing standard structures for other languages as well, if common or standard conventions exist.

@JimWuerch
Copy link

This breaks having multiple dirs, and the entry point being in a lib dir not off of root, as in myproject/function/lib/main.dart

@stnguyen90
Copy link
Contributor

This breaks having multiple dirs, and the entry point being in a lib dir not off of root, as in myproject/function/lib/main.dart

@JimWuerch, I typically deploy using the root directory of myproject/function so that in the function, lib is still at the root.

@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

5 participants
0