[Bug 2132941] [NEW] Rust unwrap with UTF-8 symbols in environment variables
Launchpad Bug Tracker
2132941 at bugs.launchpad.net
Tue Nov 25 23:40:15 UTC 2025
You have been subscribed to a public bug:
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
** Affects: rust-coreutils (Ubuntu)
Importance: Undecided
Status: New
--
Rust unwrap with UTF-8 symbols in environment variables
https://bugs.launchpad.net/bugs/2132941
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to rust-coreutils in Ubuntu.
More information about the foundations-bugs
mailing list