[Bug 2132941] Re: env: Rust unwrap with UTF-8 symbols in environment variables
Sylvestre Ledru
2132941 at bugs.launchpad.net
Wed Nov 26 12:47:00 UTC 2025
the panic is still a valid bug :)
** Changed in: rust-coreutils (Ubuntu)
Status: Invalid => Confirmed
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to rust-coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/2132941
Title:
env: Rust unwrap with UTF-8 symbols in environment variables
Status in rust-coreutils package in Ubuntu:
Confirmed
Bug description:
In Ubuntu 25.10, if an environment variable or its value contains a UTF-8 character, coreutils will unwrap in Rust's library/std/src/env.rs.
Expected behavior is either to handle the UTF-8 character like any other character or to print an error message.
Simple reproducer (tested with Bash):
STR=$(echo -e "foo\xA0")
# Generate environment variable 'foo' with UTF-8 value
foo=$STR env | grep foo
# Generate environment variable with UTF-8 name
declare "$STR=bar" ; env | grep $STR
The second command triggers this unwrap message in Ubuntu 25.10, but works fine on Fedora 43:
thread 'main' panicked at library/std/src/env.rs:163:83:
called `Result::unwrap()` on an `Err` value: "foo\xA0"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The third command fails with "declare: `foo�=bar': not a valid identifier" (same on Ubuntu 25.10 and Fedora 43).
Using `printf -v` shows the same error message.
This behavior might be fine, but it can be bypassed by e.g. Perl:
#!/usr/bin/perl
$str = "foo\x{A0}";
$ENV{$str} = 'bar';
use open IN => ":raw";
my @env = `env`;
chomp (my @env = grep { s/^$str=// } @env);
die("@env not equal to 'bar'") if "@env" ne "bar"
This Perl script executes fine on Fedora 43, but triggers the following error in Ubuntu 25.10:
thread 'main' panicked at library/std/src/env.rs:163:57:
called `Result::unwrap()` on an `Err` value: "foo\xA0"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2132941/+subscriptions
More information about the foundations-bugs
mailing list