From 1038a310fe129e891b6fd7e69e516e827303cdac Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 26 Nov 2026 23:38:07 +0000 Subject: [PATCH] fix: apply `--profile` in `profiles` `eb-local profiles` ignored `--profile` and kept the `EB_LOCAL_PROFILE` environment variable or `default_profile`. The option now selects the profile, and an unknown name is refused before the list is printed. --- changelog.d/+profiles-option.bugfix.md | 3 +++ src/main.zig | 2 +- tests/test_config_cli.py | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelog.d/+profiles-option.bugfix.md diff --git a/changelog.d/+profiles-option.bugfix.md b/changelog.d/+profiles-option.bugfix.md new file mode 100644 index 00000000..47b4c621 --- /dev/null +++ b/changelog.d/+profiles-option.bugfix.md @@ -0,0 +1,3 @@ +`--profile` now selects the profile for `eb-local profiles`. It wins +over `EB_LOCAL_PROFILE` and `default_profile`, and an unknown name is +refused. diff --git a/src/main.zig b/src/main.zig index 700afd3a..ab9d4d74 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2796,7 +2796,7 @@ fn cmdProfiles(c: Ctx, g: Global) u8 { const sources = configSources(c, g); // Loading checks every profile in every file. var d: config.Diagnostic = .{}; - _ = config.load(a, sources, c.env, .{}, &d) catch |e| switch (e) { + _ = config.load(a, sources, c.env, .{ .profile = g.profile, .project = g.project, .buildenv = g.buildenv }, &d) catch |e| switch (e) { error.Invalid => die("{s}", .{d.message}), error.OutOfMemory => oom(), }; diff --git a/tests/test_config_cli.py b/tests/test_config_cli.py index 393ce0b4..707bec7f 100644 --- a/tests/test_config_cli.py +++ b/tests/test_config_cli.py @@ -301,6 +301,15 @@ def test_profiles_lists_every_profile(self): self.assertIn("mine", run.stdout) self.assertIn("licensed", run.stdout) + def test_profiles_option_overrides_environment_profile(self): + missing = self.run_tool(["--profile", "nope", "profiles"], EB_LOCAL_PROFILE="mine") + self.assertEqual(missing.returncode, 2, missing.stderr) + self.assertIn("no profile 'nope'", missing.stderr) + named = self.run_tool(["--profile", "mine", "profiles"], EB_LOCAL_PROFILE="nope") + self.assertEqual(named.returncode, 0, named.stderr) + self.assertIn("mine", named.stdout) + self.assertIn("licensed", named.stdout) + def test_default_profile_type_checked_when_overridden(self): self.user.write_text('default_profile = 123\n\n[profile.mine]\nprefix = "/tmp/p"\n') for args, extra_env in (