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

termsize::get() returns (0, 0) when building for release #19

Closed
redpenguinyt opened this issue May 2, 2024 · 6 comments
Closed

termsize::get() returns (0, 0) when building for release #19

redpenguinyt opened this issue May 2, 2024 · 6 comments

Comments

@redpenguinyt
Copy link

currently running arch linux with zsh as the shell, and finding this to be an issue in both the kitty terminal and vscode's built in terminal. the following program returns my actual terminal size when building with cargo build and (0, 0) when building with cargo build --release:

fn main() {
    println!("{:?}", termsize::get());
}

this issue is present on all versions of termsize, though only a few months ago this wasnt a problem

@0x6b
Copy link

0x6b commented May 22, 2024

@redpenguinyt Although I'm not an owner of this repo, I want to put my two cents in. I have the same issue on macOS, and found that the following commit a.k.a. rust-lang/rust#120055 (stable as of Rust 1.78) introduced this issue, using cargo-bisect-rustc.

Since the change was significant (LLVM 17→18) I'm unsure how to proceed for any fix, but I found the following workarounds.

  • Set opt-level to 0 or 1 for the release profile with Cargo.toml i.e.

    # Cargo.toml
    [profile.release]
    opt-level = 0 # or 1 will work. 2, 3, "s", "z" will introduce the issue.
  • Pin Rust toolchain to 1.77.2 with the toolchain file i.e.

    # rust-toolchain.toml
    [toolchain]
    channel = "1.77.2"

Hope this helps. Thanks!

@softprops
Copy link
Owner

Hi folks. Someone had kindly contributed a pull request that I still own a crate version publish for that might address this #18

@nidnogg
Copy link

nidnogg commented May 28, 2024

Hi! I noticed that PR #18 got merged in. @softprops any chance it might be getting published to Cargo soon?

Yomguithereal added a commit to medialab/xan that referenced this issue May 31, 2024
The function is erroneously returnin zero
See softprops/termsize#19 for details
@bb-Ricardo
Copy link

Hi, would highly appreciate a 0.1.7 version on crates.io.

Thank you

@softprops
Copy link
Owner

Hi, would highly appreciate a 0.1.7 version on crates.io.

done! https://crates.io/crates/termsize

@bb-Ricardo
Copy link

Amazing, thank you.

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

No branches or pull requests

5 participants