Closed eugeneromero closed 9 months ago
Hi,
Thanks for this excellent software. I have used bat as an aliased replacement of cat
for about a year with no issues, and I do "batcats" on a daily basis on git repos. Let me contribute with a small comment :)
I started seeing the error today. I have NOT upgraded my Ubuntu distribution, but is certainly a change in the libraries what causes the problem. I installed a couple of terminal applications (Tilix and Kitty) to replace my old Terminator and the bug happened right after that. By looking at their dependencies and the backtrace it looks that the glibc version changed as part of these installations, and bat stopped working.
My Ubuntu has the latest package available bat v0.12.1
.
The problem is gone now but it was easily reproducible:
$ cd mkdir -p boom/.git
$ cd boom/.git
$ touch README.md
# ALL GOOD
$ batcat README.md
───────┬────────────────────────────────────────────────────────────────────────
│ File: README.md <EMPTY>
───────┴────────────────────────────────────────────────────────────────────────
$ git init
Initialized empty Git repository in /tmp/boom/.git/.git/
$ batcat README.md
thread 'main' panicked at 'attempted to zero-initialize type `libgit2_sys::git_diff_options`, which is invalid', /usr/share/cargo/registry/bat-0.12.1/debian/cargo_registry/git2-0.8.0/src/diff.rs:451:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The full backtrace points the libc
.
RUST_BACKTRACE=full cat README.md
thread 'main' panicked at 'attempted to zero-initialize type `libgit2_sys::git_diff_options`, which is invalid', /usr/share/cargo/registry/bat-0.12.1/debian/cargo_registry/git2-0.8.0/src/diff.rs:451:27
stack backtrace:
...
20: 0x7feeb6175083 - __libc_start_main
at /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
21: 0x561c42198bee - <unknown>
22: 0x0 - <unknown>
Yes, this library was affected during the software install.
To solve the problem, I simply removed bat with apt remove bat
and downloaded from the releases tab bat_0.22.1_amd64.deb
and installed it.
We are back on track now.
Thank you for your comment @alombarte! I can indeed confirm that the latest version available here fixes the issue. In my case I did not even remove the old version with apt remove
, I simply installed the new one which automatically replaced the old. I also had to update the old alias, as in these new versions the executable is now called bat
as opposed to batcat
.
I will however leave the bug report open and wait on the developers to decide what they want to do with it, since it is an issue on the latest official version of a still supported Ubuntu LTS release.
@alombarte Do you have unattended-upgrade
configured? For me, it looks like an update happened yesterday. From /var/log/apt/history.log
, I see:
Start-Date: 2022-09-15 06:35:24
Commandline: /usr/bin/unattended-upgrade
Upgrade: bat:amd64 (0.12.1-1build1, 0.12.1-1ubuntu0.1)
End-Date: 2022-09-15 06:35:24
I'm curious why the latest available version for Ubuntu 20.04 is 0.12.1
, when the latest release (0.22.1
) from the repository has no (apparent) issues running on Ubuntu 20.04. That being said, the documentation for installation via Ubuntu/apt does indicate that the release may not be the latest, and one can install the latest via dpkg
.
Thank you for reporting this. I still don't fully understand where this came from? Did Ubuntu publish an update to the bat
package that broke things? If so, shouldn't this be reported on the Ubuntu issue tracker?
Hey @sharkdp, thanks for getting back to us on this. I am not sure what the process is for a package to end up in the Ubuntu repos. Therefore, here seemed like the most logical place to report this issue. Should this be notified somewhere else?
Maybe @paride could help out here (only if interested of course)?
For me, I can reproduce by:
cargo uninstall bat
cargo install bat
$ bat --version
bat 0.22.1
$ cargo --version
cargo 1.61.0 (a028ae4 2022-04-29)
This is an Ubuntu specific bug caused by a security upload to Focal (src:rust-bat 0.12.1-1ubuntu0.1). I filed a bug for the Ubuntu package on Launchpad, and tagged it regression-update (per [1]):
https://bugs.launchpad.net/ubuntu/+source/rust-bat/+bug/1995868
I tried downgrading to 0.12.1-1build1 and that version works.
Cc: @litios
@paride thanks for the heads up. I'll update it here when the solution is released.
A new version has been released to address this issue, 0.12.1-1ubuntu0.2.
The issue was tracked down to the git2
dependency due to an incompatibility with the current rustc
available in focal and fixes have been released for all affected packages.
Since the latest update in Ubuntu 20.04, from about one month ago, bat (or batcat as it is named in my system) throws an error when trying to open some files. From some light testing, it seems that the files it chokes on are files living inside a git repo. Copying a non-working file outside the git repo, allows bat to open it successfully.
What steps will reproduce the bug?
git status
should return something)batcat ANYFILE
What happens?
batcat
throws an error:Setting the envvar as suggested:
Setting the new envvar:
What did you expect to happen instead?
batcat
should display the file as usual.How did you install
bat
?Installed it by means of the official
apt
package in Ubuntu 20.04. It seems that 0.12.1 is the latest version here, and was updated on August 18, 2022, according to the changelog.bat version and environment system
$ uname -srm Linux 5.4.0-125-generic x86_64
$ lsb_release -a No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
bat
$ batcat --version bat 0.12.1
$ env
bat_config
bat_wrapper
No wrapper script for 'bat'.
No wrapper script for 'batcat'.
bat_wrapper_function
No wrapper function for 'bat'.
$ /bin/bash --login -i -c type cat
No wrapper function for 'batcat'.
tool
$ less --version less 551 (GNU regular expressions)