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

CLI: each input leads to a warning msg "WARN RS - rustyline:718 - cannot read initial cursor location" #6641

Open
Shangbaize-Daoye opened this issue Jul 5, 2020 · 4 comments

Comments

@Shangbaize-Daoye
Copy link

@Shangbaize-Daoye Shangbaize-Daoye commented Jul 5, 2020

OS is Ubuntu 20.04

cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"

Each time when inputing something in CLI, I got a msg "WARN RS - rustyline:718 - cannot read initial cursor location".

$ deno
Deno 1.1.3
exit using ctrl+d or close()
WARN RS - rustyline:718 - cannot read initial cursor location
> "hello"
hello
WARN RS - rustyline:718 - cannot read initial cursor location
> "world"
world
WARN RS - rustyline:718 - cannot read initial cursor location
>

Source code for that warning:

From "https://github.com/kkawakam/rustyline/blob/master/src/tty/unix.rs"

    fn move_cursor_at_leftmost(&mut self, rdr: &mut PosixRawReader) -> Result<()> {
        if rdr.poll(0)? != 0 {
            debug!(target: "rustyline", "cannot request cursor location");
            return Ok(());
        }
        /* Report cursor location */
        self.write_and_flush(b"\x1b[6n")?;
        /* Read the response: ESC [ rows ; cols R */
        if rdr.poll(100)? == 0
            || rdr.next_char()? != '\x1b'
            || rdr.next_char()? != '['
            || read_digits_until(rdr, ';')?.is_none()
        {
            warn!(target: "rustyline", "cannot read initial cursor location");
            return Ok(());
        }
        let col = read_digits_until(rdr, 'R')?;
        debug!(target: "rustyline", "initial cursor location: {:?}", col);
        if col.is_some() && col != Some(1) {
            self.write_and_flush(b"\n")?;
        }
        Ok(())
    }

Don't know how this comes up but I always get that warning on my own server. OS was upgraded from 18.04 to 20.04 online.
However, on another machine with newly installed Ubuntu 20.04, this problem nerver happens. Can't reproduce it on the second machine.

Not familiar with Rust, what I want to know is:

  • 1. Possible causes of that warning "WARN RS - rustyline:718 - cannot read initial cursor location".
  • 2. How could I solve that?

Thanks for any useful help! :D

@ry ry added bug cli labels Jul 6, 2020
@bartlomieju
Copy link
Contributor

@bartlomieju bartlomieju commented Jul 14, 2020

I'm not sure, but it seems that our filter level for log is wrong and allows for WARN messages to be shown in addition to ERROR. Marking as "help wanted" as it should be straight-forward to repeat and track the problem down for anyone wanting to play with Rust.

@brendanboyle87
Copy link

@brendanboyle87 brendanboyle87 commented Jul 21, 2020

I'd like to take this issue. Should be able to just up the log level to warn when no log_level flag is provided here ->

https://github.com/denoland/deno/blob/master/cli/main.rs#L697
let log_level = match flags.log_level { Some(level) => level, None => Level::Info, // Default log level }; log::set_max_level(log_level.to_level_filter());

@brendanboyle87
Copy link

@brendanboyle87 brendanboyle87 commented Jul 21, 2020

Opened a PR above, happy to update a test but I am new to the project/Rust and was struggling to find the right place to test an update to the main.rs file.

@JayHelton
Copy link
Contributor

@JayHelton JayHelton commented Aug 4, 2020

@brendanboyle87 Are you actively working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.