Skip to content
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

[Bug]: Give more context for [CLI]: Failed to read tuono.config.ts #578

Closed
jacobhq opened this issue Feb 17, 2025 · 9 comments · Fixed by #579
Closed

[Bug]: Give more context for [CLI]: Failed to read tuono.config.ts #578

jacobhq opened this issue Feb 17, 2025 · 9 comments · Fixed by #579
Assignees
Labels
bug Something isn't working

Comments

@jacobhq
Copy link
Member

jacobhq commented Feb 17, 2025

Description

When I get this error I have no idea what to do.

Some things that can (but don't always) cause this:

  • Mismatched tuono CLI and project versions (we should print both versions for tuono dev, but out of scope of this issue)

Expected behaviour

tuono dev to run as normal.

How to reproduce

Difficult to do. Here's where I get the issue now:

https://github.com/Robert-maker1994/tuono
cd tuono
git checkout feat/gracefull-shutdown
cargo build
cd examples/tuono-app
# or any other example
../../target/debug/tuono.exe dev

This is not caused by the PR on that branch I don't think.

Screenshots

No response

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 5700G with Radeon Graphics
    Memory: 1.26 GB / 15.37 GB
  Binaries:
    Node: 22.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Local\pnpm\yarn.CMD
    npm: 11.0.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.2.1 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.1.42 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (131.0.2903.112)

# Don't worry I don't actually use Edge ;)

System info (Rust)

rustc 1.83.0 (90b35a623 2024-11-26)
cargo 1.83.0 (5ffbef321 2024-10-29)
tuono 0.17.8

Additional context

No response

@jacobhq jacobhq added the bug Something isn't working label Feb 17, 2025
@marcalexiei
Copy link
Member

marcalexiei commented Feb 17, 2025

I think you forgot to run pnpm install and pnpm build before changing folder (cd examples/tuono-app):

# download zip of feat/gracefull-shutdown branch
cargo build
pnpm install
pnpm run build
cd examples/tuono-app
# or any other example
../../target/debug/tuono.exe dev

A more detailed error message could have made it easier to identify the issue quickly.
Would you like to try to improve this behaviour?

@jacobhq
Copy link
Member Author

jacobhq commented Feb 17, 2025

pnpm run build

Yep, I'd forgotten to build 🤦

Would you like to try to improve this behaviour?

Definitely! I think from my understanding this error has two causes:

  • Version mismatch as mentioned
  • Forgetting to build (Is that specific to the tuono monorepo?)

So we should create mitigations and provide error messages for both cases:

  • During tuono dev, print CLI and project version
  • Provide a list of common fixes when [CLI]: Failed to read tuono.config.ts is printed
  • Give the CLI some kind of more verbose logging option

WDYT?

@marcalexiei
Copy link
Member

Provide a list of common fixes when [CLI]: Failed to read tuono.config.ts is printed

Personally I don't like the idea to have the CLI printing a troubleshooting guide.
We should point the user straight to the error:

Version mismatch

We should trow an error on this scenario,
having a version mismatch could lead to pretty unpredictable scenarios.

Forgetting to build

There are already few check in place around rust source code . E.g.:

if !Path::new(BUILD_JS_SCRIPT).exists() {
error!("Failed to find the build script. Please run `npm install`");
std::process::exit(1);

Probably we need to refine the error better when building the config.

Is that specific to the tuono monorepo?

I don't think so,
if someone create a new project from scratch
or doesn't run install node dependencies after tuono new
its most likely that they will encounter this very same error.

The error occurred on rust side?

The current error is actually fine.

The error occurred due to a JS runtime error?

This already happened in the past:

The error should be something like:

[CLI]: Failed to build tuono.config.ts. 
Error: "{{message of the error that caused the build to fail}}"

Give the CLI some kind of more verbose logging option

@Valerioageno already had setup this via tracing crate:

Are you suggesting to add a new flag to the tuono CLI instead of setting RUST_LOG env variable?

@jacobhq
Copy link
Member Author

jacobhq commented Feb 18, 2025

Version mismatch

Completely agree. Only thing to be careful of is when working on projects in this monorepo, you are technically using a newer version in the project than in the CLI. This is usually not an issue, but because of #565, I think there are a few issues now. I haven't opened an issue because in next release, this will be solved because #565 code will be in the CLI also.

Forgetting to build

The existing checks are good, and have saved me a few times, we might just need to add some more.

The error occurred due to a JS runtime error?

Yeah you're right, I think we do need an additional error there.

Are you suggesting to add a new flag to the tuono CLI instead of setting RUST_LOG env variable?

Something like a --log-level verbose or a --verbose flag would be really useful.

We also silence stuff in our tuono npm package. I don't know if this is necessarily a bad thing (I haven't done much work in this package), but we might be able to at least show warnings? (I haven't look at this in detail, just noticed it during a PR a few weeks ago)

logLevel: 'silent',

I think maybe we should make one of the big issues like we did for our doc writing to track progress on errors. WDYT @marcalexiei @Valerioageno? Maybe just use this one since we are having a big discussion, the scope of which may be wider than this issue IMHO.

@marcalexiei
Copy link
Member

marcalexiei commented Feb 18, 2025

Note

To avoid discussing many things in this issue I would consider focus solely on the following point:

Forgetting to build

The existing checks are good, and have saved me a few times, we might just need to add some more.

What additional error you would like to add?


Note

To avoid to lose track of the other points I linked / create a project task for each of them.

@jacobhq
Copy link
Member Author

jacobhq commented Feb 18, 2025

What additional error you would like to add?

I would like it to give me more information. Config::get() returns a Result<T, E>, I think we should give the user the full error.

if let Ok(config) = Config::get() {
self.config = Some(config);
} else {
eprintln!("[CLI] Failed to read tuono.config.ts");
std::process::exit(1);
};

Just refactor to use a match and do something like:

eprintln!("[CLI] Failed to read tuono.config.ts: {}", err);

I think from there, it should be easier for the developer to deduce what the problem is.

@marcalexiei
Copy link
Member

I would consider to print the error on a new line to better distinct it from the [CLI] Failed to read tuono.config.ts: message.

@github-project-automation github-project-automation bot moved this to Backlog in Road to V1 Feb 18, 2025
@marcalexiei marcalexiei moved this from Backlog to Ready in Road to V1 Feb 18, 2025
@jacobhq
Copy link
Member Author

jacobhq commented Feb 18, 2025

Sounds good! Shall I start work in a PR?

@marcalexiei
Copy link
Member

Yes, thank you

@Valerioageno Valerioageno moved this from Ready to In progress in Road to V1 Feb 23, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in Road to V1 Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants