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

fix(cli): Fixes errors on command output, closes #8110 #8162

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

olivierlemasle
Copy link
Contributor

@olivierlemasle olivierlemasle commented Nov 2, 2023

Command output was fixed in #8042; however it also created two issues:

std::thread::spawn(move || {
let mut line = String::new();
let mut lines = stderr_lines_.lock().unwrap();
loop {
line.clear();
if let Ok(0) = stderr.read_line(&mut line) {
break;
}
debug!(action = "stderr"; "{}", &line[0..line.len() - 1]);
lines.extend(line.as_bytes().to_vec());
}
});

  • If read_line returns Err (which happens if the stream contains an invalid UTF-8 character), line is empty and &line[0..line.len() - 1] fails (attempt to subtract with overflow)
    That happens on macos with bundle_dmg.sh when the product name contains a Chinese character or an emoji (cf "--verbose" parameter cause "cargo tauri build" error #8110).
  • If the stream ends with no linebreak (just EOF), line does not end with \n. Therefore, the last byte of the stream is removed. If this is e.g. an ASCII character, it's just one character missing in the output. If the last character is multi-bytes, it throws an error (byte index xxx is not a char boundary; it is inside xxx)

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

Fixes #8110

@olivierlemasle olivierlemasle requested a review from a team as a code owner November 2, 2023 15:57
@olivierlemasle olivierlemasle changed the title fix: Fixes errors on command output, closes #8110 fix(cli): Fixes errors on command output, closes #8110 Nov 2, 2023
The error occurs when the command output stream contains an invalid
UTF-8 character, or ends with a multi-bytes UTF-8 character.

Fixes tauri-apps#8110
Copy link
Member

@lucasfernog lucasfernog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thank you ❤️

@lucasfernog lucasfernog merged commit 1d5aa38 into tauri-apps:1.x Nov 9, 2023
14 checks passed
@olivierlemasle olivierlemasle deleted the fix-command-verbose branch November 9, 2023 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants