Giter VIP home page Giter VIP logo

Comments (6)

ellie avatar ellie commented on July 17, 2024

Judging by the issue you've opened with webstorm, and that this doesn't occur in other terminals, I suspect it's just a webstorm problem. I haven't heard of anyone else having problems with Chinese input methods

from atuin.

akinomyoga avatar akinomyoga commented on July 17, 2024

The panic is reproducible with the following command.

$ a='\x80' atuin search
thread 'main' panicked at library/std/src/env.rs:171:83:
called `Result::unwrap()` on an `Err` value: "\x80"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is probably related: https://doc.rust-lang.org/std/env/fn.vars.html#panics

This means that any Rust programs using std.env.vars somewhere will panic if any environment variables (including the ones that the program doesn't use) contain binary data or a string in a different encoding.

This implies that when a user switches the locale by setting e.g. LANG, LC_CTYPE, or LC_ALL, all the environment variables need to be cleared for Rust programs to work. This is a strange requirement by Rust.

from atuin.

ellie avatar ellie commented on July 17, 2024

Hm that doesn't reproduce the issue for me 🤔

Is there a specific terminal or setup you're using?

from atuin.

akinomyoga avatar akinomyoga commented on July 17, 2024
  • I tried release version of v18.2.0 and both the debug/release builds of commit eebfd04. In all the binaries I could test, the problem reproduces. However, the current main branch doesn't compile in my host, so I haven't tested the latest main branch.
  • I don't think the terminal is related when using the above command (because the part a=$'\x80' mimics the terminal's behavior in the report), but I tried different terminals. The panic reproduces with all the terminals I quickly tried, including GNU Screen, Terminology, and Mintty, Alacritty, and Kitty.
  • The panic reproduces with all of the cases LC_CTYPE='en_US.UTF-8', LC_CTYPE='ja_JP.UTF-8', LC_CTYPE='C.UTF-8', and LC_CTYPE='C'
  • The panic also reproduces with the default .config/atuin/config.toml (i.e., the one generated when it is missing).
  • The panic reproduces also with an empty command history.
  • I also tried it with Zsh, Bash/bash-preexec, and Bash/ble.sh. In all the cases, the problem reproduces.

from atuin.

ellie avatar ellie commented on July 17, 2024

Ah I see, got it. Thanks

This implies that when a user switches the locale by setting e.g. LANG, LC_CTYPE, or LC_ALL, all the environment variables need to be cleared for Rust programs to work. This is a strange requirement by Rust.

It's actually just the usage of std::env::vars, which uses a String. These require utf8 encoding.

std::env::vars_os uses an OsString, which does not. We could probably wrap this and then only use the values internally that are valid utf-8, and ignore the rest rather than panicking

Regardless of this, I'm still curious as to why this only happens with webstorm (for OP)

This problem occurs when typing Chinese content with Chinese input methods, and only occurs in the webstorm terminal.

from atuin.

akinomyoga avatar akinomyoga commented on July 17, 2024

Regardless of this, I'm still curious as to why this only happens with webstorm (for OP)

This problem occurs when typing Chinese content with Chinese input methods, and only occurs in the webstorm terminal.

This is just my guess, but I think the WebStorm terminal sends the user input with an encoding different from UTF-8. Then, the shell receives the data and stores it in an environment variable. This behavior might be caused by just the user's configuration for the terminal encoding, or it might be the WebStorm terminal's issue with handling the data from the system's input method.

So, I think the reported problem could be solved if the WebStorm terminal is properly configured or fixed. Nevertheless, I see it as also a problem that crate config scans the environment variables that the program doesn't even use and panics with a non-UTF-8 environment variable unused by the program. Atuin shouldn't be affected by random environment variables that it doesn't use.

For the non-UTF-8 environment variables that Atuin actually uses, I'm not sure about the desired behavior. It may just ignore the environment variable or print a warning message.

from atuin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.