Skip to content

fix(Roseta): fixed Roseta enablement on macOS Tahoe with Podman 5.6+ - #16924

Merged
gastoner merged 4 commits into
podman-desktop:mainfrom
gastoner:roseta_fix
Apr 13, 2026
Merged

fix(Roseta): fixed Roseta enablement on macOS Tahoe with Podman 5.6+#16924
gastoner merged 4 commits into
podman-desktop:mainfrom
gastoner:roseta_fix

Conversation

@gastoner

@gastoner gastoner commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds a fix from https://blog.podman.io/2025/08/podman-5-6-released-rosetta-status-update/ to creation/starting of podman machine on macOS Tahoe with podman 5.6+

Screenshot / video of UI

What issues does this PR fix or reference?

Closes #16168

How to test this PR?

Create podman machine from podman desktop (production version) - applev provider
Start the machine, run podman machine ssh "cat /proc/sys/fs/binfmt_misc/rosetta" (for podman-machine-default) - you should see cat: /proc/sys/fs/binfmt_misc/rosetta: No such file or directory

Run PD from this PR, try to stop/start the machine
run podman machine ssh "cat /proc/sys/fs/binfmt_misc/rosetta"
You should see: ±

enabled
interpreter /mnt/rosetta
flags: POCF
offset 0
magic 7f454c4602010100000000000000000002003e00
mask fffffffffffefe00fffffffffffffffffeffffff

Delete the machine, create new machine (also with appleV)
run the command again, you should see the same output

  • Tests are covering the bug fix or the new feature

@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a RosettaProvisioner injectable and integrates Rosetta enablement into Podman machine start/create flows on macOS/arm64/applehv + Podman >=5.6: determines need, optionally SSH-writes /etc/containers/enable-rosetta, restarts the VM when required, updates Inversify bindings, and expands unit tests and console mocks.

Changes

Cohort / File(s) Summary
Extension core
extensions/podman/packages/extension/src/extension.ts
Injects RosettaProvisioner; on startMachine queries Podman binary info and calls provisionAndRestartForRosetta before provider.updateStatus('started') when applicable; createMachine handles --now and stopped-machine provisioning flows and logs failures with console.warn.
Rosetta utilities
extensions/podman/packages/extension/src/utils/rosetta.ts
Introduces ROSETTA_ENABLE_FILE and RosettaProvisioner with needsRosettaEnableFile, enableRosettaInMachine, and provisionAndRestartForRosetta; gates on macOS/arch/vmType/Podman version/config, performs SSH test -f and sudo touch, and stops/starts VM when file is created.
Rosetta tests
extensions/podman/packages/extension/src/utils/rosetta.spec.ts
Reworks tests to instantiate RosettaProvisioner, mock execPodman, and add comprehensive matrices and control-flow tests for needsRosettaEnableFile, enableRosettaInMachine, and provisionAndRestartForRosetta, including error and VM-type paths.
Extension tests
extensions/podman/packages/extension/src/extension.spec.ts
Wires ROSETTA_PROVISIONER_MOCK into test container, extends vi.mock('./utils/rosetta'), expands console stubbing (warn, trace, error), and adds tests verifying startMachine and createMachine Rosetta provisioning behavior across success, rejection, missing version, --now, and SSH-touch behavior.
Inversify binding
extensions/podman/packages/extension/src/inject/inversify-binding.ts, extensions/podman/packages/extension/src/inject/inversify-binding.spec.ts
Registers RosettaProvisioner as a singleton in DI container and adds a spec asserting the binding resolves to a RosettaProvisioner instance.

Sequence Diagram(s)

sequenceDiagram
    participant Extension as Extension
    participant Rosetta as RosettaProvisioner
    participant PodmanCLI as Podman CLI
    participant VM as Machine VM

    Extension->>PodmanCLI: startMachine()
    PodmanCLI->>VM: machine start
    VM-->>PodmanCLI: started
    PodmanCLI-->>Extension: start success

    Extension->>PodmanCLI: getBinaryInfo()
    PodmanCLI-->>Extension: podman version

    alt macOS + arm64 + podman >= 5.6 + vmType applehv
        Extension->>Rosetta: provisionAndRestartForRosetta(machineName, provider, options)
        Rosetta->>PodmanCLI: machine ssh "test -f /etc/containers/enable-rosetta"
        PodmanCLI-->>Rosetta: file exists / not found
        alt file missing
            Rosetta->>PodmanCLI: machine ssh "sudo touch /etc/containers/enable-rosetta"
            PodmanCLI-->>Rosetta: file created
            Rosetta->>PodmanCLI: machine stop
            PodmanCLI-->>VM: stop
            PodmanCLI-->>Rosetta: stopped
            Rosetta->>PodmanCLI: machine start (forwarded options)
            PodmanCLI-->>VM: start
            PodmanCLI-->>Rosetta: restarted
        else file exists
            PodmanCLI-->>Rosetta: no-op
        end
    else skip provisioning
    end

    Extension-->>Extension: provider.updateStatus('started')
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing Rosetta enablement on macOS Tahoe with Podman 5.6+, which directly matches the code changes implementing Rosetta provisioning logic.
Description check ✅ Passed The description explains what the PR does (adds Rosetta fix from Podman blog), references the related issue (#16168), provides test instructions, and notes that tests cover the fix.
Linked Issues check ✅ Passed The PR implements the required fix for #16168: it adds Rosetta enablement provisioning during VM creation/start by creating /etc/containers/enable-rosetta and restarting the machine, directly addressing the issue's core problem.
Out of Scope Changes check ✅ Passed All changes are scoped to Rosetta provisioning implementation: new RosettaProvisioner class, integration into extension.ts for machine creation/start flows, corresponding test coverage, and Inversify binding. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/podman/packages/extension/src/extension.spec.ts`:
- Around line 966-1035: Add unit tests covering the new Rosetta provisioning
paths in extension.createMachine (the --now immediate-start branch and the
stopped-creation branch) similar to the existing startMachine suite: spy/mocked
PODMAN_BINARY_MOCK.getBinaryInfo and enableRosettaInMachine to simulate (a)
no-op (file exists), (b) file-created (requires stop/start sequence), and (c)
thrown error (warning-only); assert calls to extensionApi.process.exec (using
podmanCli.getPodmanCli and the expected ['machine','stop', name] /
['machine','start', name] sequences and counts), that enableRosettaInMachine
is/isn't called appropriately, console.warn is invoked on errors, and
provider.updateStatus is eventually called with 'started' for both --now and
stopped createMachine flows.

In `@extensions/podman/packages/extension/src/extension.ts`:
- Around line 889-906: The try/catch around enableRosettaInMachine + the calls
to execPodman(['machine','stop'...]) and execPodman(['machine','start'...])
swallows errors after the VM state has already been mutated, which can leave the
VM in the wrong state while startMachine() still reports "started"; change this
to attempt to restore the original VM state on failure and surface the error
instead of silently logging it: after a failed
execPodman(['machine','start'...']) (or any error inside that try block) call
execPodman(['machine','start', machineInfo.name], machineInfo.vmType) if the VM
was stopped by your code to restore state (or attempt
execPodman(['machine','stop'...]) if you need to revert a started VM), log both
the restoration attempt result, and then rethrow the original error so callers
see the failure; apply the same change to the other identical block referenced
(around lines 2209-2235) and use the same functions enableRosettaInMachine,
execPodman and LoggerDelegator in the restoration/error handling logic.

In `@extensions/podman/packages/extension/src/utils/rosetta.spec.ts`:
- Around line 151-155: The test for enableRosettaInMachine relies on previous
state because vi.resetAllMocks() doesn't restore envAPI.isMac; make the
non-macOS scenario deterministic by explicitly setting envAPI.isMac = false in
that test (or reset env flags in the test suite beforeEach), ensuring the test
for enableRosettaInMachine (and the expect(execPodman).not.toBeCalled()) runs
with envAPI.isMac false rather than depending on arch() being unset.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts`:
- Around line 42-55: Function needsRosettaEnableFile currently doesn't scope to
the AppleHV provider; update it to check the machine/provider type (e.g.,
podmanConfiguration.vmType) and return false unless it equals the AppleHV
provider constant (use APPLE_HV_VM_TYPE or the existing AppleHV identifier), so
the Rosetta-enable file path only runs for AppleHV machines; also apply the same
vmType/provider check to the other similar predicate at lines 68-74 (the
analogous function) and ensure enableRosettaInMachine/execPodman continue to
receive the provider info if needed.
- Line 49: Replace the global parseInt usage in the darwinMajor assignment with
the Number namespace: change the expression in const darwinMajor (currently
parseInt(release().split('.')[0], 10)) to use
Number.parseInt(release().split('.')[0], 10) so it complies with the
useNumberNamespace rule.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e4be6ac-4fe8-480d-be99-5777f2fbd5ec

📥 Commits

Reviewing files that changed from the base of the PR and between c4255b0 and d3eed07.

📒 Files selected for processing (4)
  • extensions/podman/packages/extension/src/extension.spec.ts
  • extensions/podman/packages/extension/src/extension.ts
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts
  • extensions/podman/packages/extension/src/utils/rosetta.ts

Comment thread extensions/podman/packages/extension/src/extension.spec.ts
Comment on lines +889 to +906
const podmanInstallation = await podmanBinary.getBinaryInfo();
if (podmanInstallation?.version) {
try {
const fileCreated = await enableRosettaInMachine(
machineInfo.name,
machineInfo.vmType,
podmanConfiguration,
podmanInstallation.version,
);
if (fileCreated) {
await execPodman(['machine', 'stop', machineInfo.name], machineInfo.vmType);
await execPodman(['machine', 'start', machineInfo.name], machineInfo.vmType, {
logger: new LoggerDelegator(context, logger),
});
}
} catch (err) {
console.warn(`Failed to set up Rosetta enable file during machine start: ${err}`);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don’t swallow failures after the machine state has already changed.

Once fileCreated/setupNeeded is true, these branches start mutating VM state. If machine stop succeeds and the following machine start fails, startMachine() still reports started; likewise the temporary create-time start/stop path can return with the VM left in the wrong final state. Only downgrade pre-transition checks to warnings, or restore the original state before swallowing the error.

Also applies to: 2209-2235

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/extension.ts` around lines 889 -
906, The try/catch around enableRosettaInMachine + the calls to
execPodman(['machine','stop'...]) and execPodman(['machine','start'...])
swallows errors after the VM state has already been mutated, which can leave the
VM in the wrong state while startMachine() still reports "started"; change this
to attempt to restore the original VM state on failure and surface the error
instead of silently logging it: after a failed
execPodman(['machine','start'...']) (or any error inside that try block) call
execPodman(['machine','start', machineInfo.name], machineInfo.vmType) if the VM
was stopped by your code to restore state (or attempt
execPodman(['machine','stop'...]) if you need to revert a started VM), log both
the restoration attempt result, and then rethrow the original error so callers
see the failure; apply the same change to the other identical block referenced
(around lines 2209-2235) and use the same functions enableRosettaInMachine,
execPodman and LoggerDelegator in the restoration/error handling logic.

Comment thread extensions/podman/packages/extension/src/utils/rosetta.spec.ts
Comment thread extensions/podman/packages/extension/src/utils/rosetta.ts Outdated
Comment thread extensions/podman/packages/extension/src/utils/rosetta.ts Outdated
@gastoner
gastoner marked this pull request as draft April 2, 2026 05:13
@gastoner
gastoner marked this pull request as ready for review April 2, 2026 05:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
extensions/podman/packages/extension/src/utils/rosetta.ts (1)

53-53: ⚠️ Potential issue | 🟡 Minor

Use Number.parseInt here.

Biome still flags Line 53, so this helper will fail lint until the global parseInt is replaced.

🧹 Minimal fix
-  const darwinMajor = parseInt(release().split('.')[0], 10);
+  const darwinMajor = Number.parseInt(release().split('.')[0], 10);

As per coding guidelines, **/*.{ts,tsx,js,jsx,svelte}: Follow ESLint and Biome rules for code style and formatting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts` at line 53,
Replace the global parseInt call with the namespaced Number.parseInt for the
darwinMajor assignment: update the expression that sets const darwinMajor
(currently using parseInt(release().split('.')[0], 10)) to use
Number.parseInt(...) so it satisfies Biome/ESLint rules and removes the lint
flag.
extensions/podman/packages/extension/src/extension.ts (1)

2203-2221: ⚠️ Potential issue | 🟠 Major

Don't swallow Rosetta setup errors after the VM state has changed.

This catch still hides failures after the code has already started/stopped the machine. On the --now path, a failed restart from provisionAndRestartForRosetta() can leave the VM stopped; on the non---now path, a failed final machine stop leaves it running, yet createMachine() still returns success. If you want a best-effort preflight, keep the warning before any machine start, but rethrow once this block begins mutating VM state.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/extension.ts` around lines 2203 -
2221, The try/catch currently swallows errors even after we've mutated VM state;
change it to only "best-effort" warn before any machine start, but rethrow if
any mutation occurred. Add a local boolean (e.g., mutationOccurred) and set it
true immediately before calling provisionAndRestartForRosetta(...) or before
execPodman(['machine','start',...])/execPodman(['machine','stop',...]) in the
non-`--now` path; in the catch block, if mutationOccurred is true then rethrow
the caught error (preserve original error), otherwise keep the console.warn
as-is. Use the existing symbols provisionAndRestartForRosetta,
needsRosettaEnableFile, execPodman and ROSETTA_ENABLE_FILE to locate the
relevant calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/podman/packages/extension/src/utils/rosetta.ts`:
- Around line 111-115: The catch block around enableRosettaInMachine currently
swallows errors and returns false (same as "no-op"), so update the handler to
propagate the failure instead of masking it: either remove the try/catch so the
exception bubbles up, or rethrow a new Error with context (e.g., `throw new
Error(\`Failed to provision Rosetta enable file for ${machineName}: ${err}\`)`)
so callers like startMachine and createMachine can detect and surface the
provisioning failure rather than treating it as "nothing to do". Ensure
references to enableRosettaInMachine, startMachine, and createMachine are
preserved when adjusting control flow.

---

Duplicate comments:
In `@extensions/podman/packages/extension/src/extension.ts`:
- Around line 2203-2221: The try/catch currently swallows errors even after
we've mutated VM state; change it to only "best-effort" warn before any machine
start, but rethrow if any mutation occurred. Add a local boolean (e.g.,
mutationOccurred) and set it true immediately before calling
provisionAndRestartForRosetta(...) or before
execPodman(['machine','start',...])/execPodman(['machine','stop',...]) in the
non-`--now` path; in the catch block, if mutationOccurred is true then rethrow
the caught error (preserve original error), otherwise keep the console.warn
as-is. Use the existing symbols provisionAndRestartForRosetta,
needsRosettaEnableFile, execPodman and ROSETTA_ENABLE_FILE to locate the
relevant calls.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts`:
- Line 53: Replace the global parseInt call with the namespaced Number.parseInt
for the darwinMajor assignment: update the expression that sets const
darwinMajor (currently using parseInt(release().split('.')[0], 10)) to use
Number.parseInt(...) so it satisfies Biome/ESLint rules and removes the lint
flag.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b4843b1-ba12-4737-86fa-f34cad3bb6bb

📥 Commits

Reviewing files that changed from the base of the PR and between d3eed07 and 9c7f94f.

📒 Files selected for processing (4)
  • extensions/podman/packages/extension/src/extension.spec.ts
  • extensions/podman/packages/extension/src/extension.ts
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts
  • extensions/podman/packages/extension/src/utils/rosetta.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts
  • extensions/podman/packages/extension/src/extension.spec.ts

Comment thread extensions/podman/packages/extension/src/utils/rosetta.ts Outdated
@gastoner
gastoner marked this pull request as draft April 2, 2026 07:54
@gastoner
gastoner marked this pull request as ready for review April 2, 2026 08:35
@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ensions/podman/packages/extension/src/extension.ts 90.47% 2 Missing ⚠️
...ons/podman/packages/extension/src/utils/rosetta.ts 95.45% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
extensions/podman/packages/extension/src/utils/rosetta.ts (1)

111-116: ⚠️ Potential issue | 🟠 Major

Bubble Rosetta provisioning failures up to the caller.

Returning false here makes SSH/touch failures indistinguishable from “already configured”, so startMachine() and createMachine(... --now) can keep going and report success even when Rosetta is still inactive.

🔧 Suggested change
   try {
     fileCreated = await enableRosettaInMachine(machineName, vmType, podmanConfiguration, podmanVersion);
   } catch (err) {
-    console.warn(`Failed to provision Rosetta enable file: ${err}`);
-    return false;
+    throw new Error(`Failed to provision Rosetta enable file for ${machineName}: ${String(err)}`);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts` around lines 111 -
116, The catch block around enableRosettaInMachine currently swallows errors and
returns false, making provisioning failures indistinguishable from a no-op;
change this so provisioning errors bubble to the caller (startMachine /
createMachine) by removing the swallow-and-return-false behavior — either remove
the try/catch or rethrow the caught error (or throw a new Error with contextual
info) from the catch in the function that calls enableRosettaInMachine so
callers can detect and handle real Rosetta provisioning failures.
extensions/podman/packages/extension/src/extension.ts (1)

2202-2221: ⚠️ Potential issue | 🟠 Major

Don't downgrade create-time Rosetta failures to warnings after mutating VM state.

This catch wraps branches that may already have started or restarted the VM. If a later start/stop fails, createMachine() still resolves even though the machine can be left in the wrong final state.

🔧 Suggested change
   if (extensionApi.env.isMac && version) {
-    try {
-      if (params['podman.factory.machine.now']) {
-        await provisionAndRestartForRosetta(machineName, provider, podmanConfiguration, version, { logger });
-      } else {
-        // Machine is stopped. Check conditions without SSH first; only start/stop
-        // the machine temporarily when actually needed.
-        const setupNeeded = await needsRosettaEnableFile(podmanConfiguration, version, provider);
-        if (setupNeeded) {
-          await execPodman(['machine', 'start', machineName], provider, { logger });
-          try {
-            await execPodman(['machine', 'ssh', machineName, `sudo touch ${ROSETTA_ENABLE_FILE}`], provider);
-          } finally {
-            await execPodman(['machine', 'stop', machineName], provider);
-          }
-        }
-      }
-    } catch (err) {
-      console.warn(`Failed to set up Rosetta enable file during machine creation: ${err}`);
+    if (params['podman.factory.machine.now']) {
+      await provisionAndRestartForRosetta(machineName, provider, podmanConfiguration, version, { logger });
+    } else {
+      const setupNeeded = await needsRosettaEnableFile(podmanConfiguration, version, provider);
+      if (setupNeeded) {
+        await execPodman(['machine', 'start', machineName], provider, { logger });
+        try {
+          await execPodman(['machine', 'ssh', machineName, `sudo touch ${ROSETTA_ENABLE_FILE}`], provider, {
+            logger,
+          });
+        } finally {
+          await execPodman(['machine', 'stop', machineName], provider, { logger });
+        }
+      }
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/extension.ts` around lines 2202 -
2221, The current try/catch around the Rosetta setup swallows errors that can
leave the VM in a mutated state (started/stopped) during
provisionAndRestartForRosetta, needsRosettaEnableFile, and execPodman calls;
change it so errors are not downgraded to warnings—either narrow the try/catch
to only non-mutating checks or, if you keep this outer try/catch, log the error
(using console.warn or logger) and then rethrow it so createMachine() (or its
caller) can fail and handle rollback; ensure this applies to
provisionAndRestartForRosetta, needsRosettaEnableFile, and the execPodman
start/stop/ssh sequences.
🧹 Nitpick comments (1)
extensions/podman/packages/extension/src/extension.spec.ts (1)

1015-1084: Pin these create-time Rosetta tests to VMTYPE.APPLEHV.

createMachineBaseParams never selects the Apple provider, so this suite can still pass while exercising the default macOS provider path. Please set the provider explicitly and assert that exact value is forwarded to the Rosetta helpers.

🧪 Suggested change
   const createMachineBaseParams = {
     'podman.factory.machine.cpus': '2',
     'podman.factory.machine.memory': '1048000000',
     'podman.factory.machine.diskSize': '250000000000',
     'podman.factory.machine.image': 'path',
+    'podman.factory.machine.provider': VMTYPE.APPLEHV,
   };
@@
     expect(provisionAndRestartForRosetta).toHaveBeenCalledWith(
       'podman-machine-default',
-      expect.any(String),
+      VMTYPE.APPLEHV,
       podmanConfiguration,
       '5.7.0',
       expect.anything(),
     );
@@
-    expect(needsRosettaEnableFile).toHaveBeenCalledWith(podmanConfiguration, '5.7.0', expect.any(String));
+    expect(needsRosettaEnableFile).toHaveBeenCalledWith(podmanConfiguration, '5.7.0', VMTYPE.APPLEHV);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/extension.spec.ts` around lines 1015
- 1084, The tests for createMachine Rosetta provisioning don't pin the VM
provider so they may pass without exercising the Apple Hypervisor path; update
createMachineBaseParams in this spec to include the vmType/provider key set to
VMTYPE.APPLEHV (use the same symbol or constant used in production code), and
adjust assertions to expect that vmType value is forwarded to
needsRosettaEnableFile and provisionAndRestartForRosetta when calling
extension.createMachine; ensure the tests reference createMachineBaseParams, and
verify calls to needsRosettaEnableFile and provisionAndRestartForRosetta include
the exact VMTYPE.APPLEHV string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@extensions/podman/packages/extension/src/extension.ts`:
- Around line 2202-2221: The current try/catch around the Rosetta setup swallows
errors that can leave the VM in a mutated state (started/stopped) during
provisionAndRestartForRosetta, needsRosettaEnableFile, and execPodman calls;
change it so errors are not downgraded to warnings—either narrow the try/catch
to only non-mutating checks or, if you keep this outer try/catch, log the error
(using console.warn or logger) and then rethrow it so createMachine() (or its
caller) can fail and handle rollback; ensure this applies to
provisionAndRestartForRosetta, needsRosettaEnableFile, and the execPodman
start/stop/ssh sequences.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts`:
- Around line 111-116: The catch block around enableRosettaInMachine currently
swallows errors and returns false, making provisioning failures
indistinguishable from a no-op; change this so provisioning errors bubble to the
caller (startMachine / createMachine) by removing the swallow-and-return-false
behavior — either remove the try/catch or rethrow the caught error (or throw a
new Error with contextual info) from the catch in the function that calls
enableRosettaInMachine so callers can detect and handle real Rosetta
provisioning failures.

---

Nitpick comments:
In `@extensions/podman/packages/extension/src/extension.spec.ts`:
- Around line 1015-1084: The tests for createMachine Rosetta provisioning don't
pin the VM provider so they may pass without exercising the Apple Hypervisor
path; update createMachineBaseParams in this spec to include the vmType/provider
key set to VMTYPE.APPLEHV (use the same symbol or constant used in production
code), and adjust assertions to expect that vmType value is forwarded to
needsRosettaEnableFile and provisionAndRestartForRosetta when calling
extension.createMachine; ensure the tests reference createMachineBaseParams, and
verify calls to needsRosettaEnableFile and provisionAndRestartForRosetta include
the exact VMTYPE.APPLEHV string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32a70281-e908-43f3-b5ec-190415ae7b18

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7f94f and 0006e97.

📒 Files selected for processing (4)
  • extensions/podman/packages/extension/src/extension.spec.ts
  • extensions/podman/packages/extension/src/extension.ts
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts
  • extensions/podman/packages/extension/src/utils/rosetta.ts

@benoitf benoitf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we've enabled inversify in this extension so we should not bring any exported function but only bring injection of objects / classes

@gastoner

gastoner commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

@benoitf updated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
extensions/podman/packages/extension/src/utils/rosetta.ts (1)

120-125: ⚠️ Potential issue | 🟠 Major

Propagate Rosetta provisioning failures instead of returning false.

This catch makes "SSH/touch failed" indistinguishable from "already configured", so callers can continue and report a healthy machine while Rosetta is still inactive. Let this reject, or return a distinct failure state that the caller must surface.

Suggested change
     try {
       fileCreated = await this.enableRosettaInMachine(machineName, vmType, podmanConfiguration, podmanVersion);
     } catch (err) {
-      console.warn(`Failed to provision Rosetta enable file: ${err}`);
-      return false;
+      throw new Error(`Failed to provision Rosetta enable file for ${machineName}: ${String(err)}`);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/utils/rosetta.ts` around lines 120 -
125, The catch in the Rosetta provisioning call swallows errors and returns
false, making "SSH/touch failed" indistinguishable from "already configured";
update the error handling in the block that calls enableRosettaInMachine (the
try/catch around fileCreated = await this.enableRosettaInMachine(...)) to either
rethrow the caught error (throw err) so callers can surface a provisioning
failure, or return a distinct failure value/object (e.g., { success: false,
reason: err }) and update callers accordingly; ensure you reference
enableRosettaInMachine and the surrounding provisioning routine so callers can
differentiate and report Rosetta provisioning failures.
extensions/podman/packages/extension/src/extension.ts (1)

2206-2225: ⚠️ Potential issue | 🟠 Major

Don’t downgrade create-time Rosetta setup failures to a warning after the VM state changes.

Once this block starts the machine or calls provisionAndRestartForRosetta(), a failed restart/stop can leave the VM in the wrong final state while createMachine() still resolves successfully. Re-throw after any best-effort rollback so callers don’t treat a partially configured machine as ready.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/podman/packages/extension/src/extension.ts` around lines 2206 -
2225, The catch block currently logs failures when setting up Rosetta during
machine creation but swallows the error, allowing createMachine (and callers) to
treat a partially-configured VM as successful; instead, after performing any
best-effort rollback/cleanup (e.g., the existing finally that stops the machine
after execPodman calls), re-throw the caught error so callers observe the
failure. Concretely: in the try/catch around
rosettaProvisioner.provisionAndRestartForRosetta and execPodman calls, replace
the console.warn in the catch with a logger.error (or keep the warn) and then
throw err (re-throw) so failures in
rosettaProvisioner.provisionAndRestartForRosetta, execPodman(['machine',
'start'...]), or the SSH touch are propagated to callers of createMachine;
ensure you don’t remove existing cleanup finally blocks (e.g., the inner finally
that calls execPodman(['machine','stop',...])).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@extensions/podman/packages/extension/src/extension.ts`:
- Around line 2206-2225: The catch block currently logs failures when setting up
Rosetta during machine creation but swallows the error, allowing createMachine
(and callers) to treat a partially-configured VM as successful; instead, after
performing any best-effort rollback/cleanup (e.g., the existing finally that
stops the machine after execPodman calls), re-throw the caught error so callers
observe the failure. Concretely: in the try/catch around
rosettaProvisioner.provisionAndRestartForRosetta and execPodman calls, replace
the console.warn in the catch with a logger.error (or keep the warn) and then
throw err (re-throw) so failures in
rosettaProvisioner.provisionAndRestartForRosetta, execPodman(['machine',
'start'...]), or the SSH touch are propagated to callers of createMachine;
ensure you don’t remove existing cleanup finally blocks (e.g., the inner finally
that calls execPodman(['machine','stop',...])).

In `@extensions/podman/packages/extension/src/utils/rosetta.ts`:
- Around line 120-125: The catch in the Rosetta provisioning call swallows
errors and returns false, making "SSH/touch failed" indistinguishable from
"already configured"; update the error handling in the block that calls
enableRosettaInMachine (the try/catch around fileCreated = await
this.enableRosettaInMachine(...)) to either rethrow the caught error (throw err)
so callers can surface a provisioning failure, or return a distinct failure
value/object (e.g., { success: false, reason: err }) and update callers
accordingly; ensure you reference enableRosettaInMachine and the surrounding
provisioning routine so callers can differentiate and report Rosetta
provisioning failures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 38881b61-0c35-42bb-9b75-beff1d59d4ef

📥 Commits

Reviewing files that changed from the base of the PR and between 0006e97 and 6ff0216.

📒 Files selected for processing (6)
  • extensions/podman/packages/extension/src/extension.spec.ts
  • extensions/podman/packages/extension/src/extension.ts
  • extensions/podman/packages/extension/src/inject/inversify-binding.spec.ts
  • extensions/podman/packages/extension/src/inject/inversify-binding.ts
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts
  • extensions/podman/packages/extension/src/utils/rosetta.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • extensions/podman/packages/extension/src/extension.spec.ts
  • extensions/podman/packages/extension/src/utils/rosetta.spec.ts

}

// name at the end
let machineName = 'podman-machine-default';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need to get the default machine name

the command 'podman machine ssh' works without provide the default name of the machine

if podman cli decides to rename the default machine name from 'podman-machine-default' to 'default' we're screwed here

I think it should provide the name of the machine later only if it's defined, else it should assume the default naming

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the default name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to push it :D

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gastoner I think it should not be empty machine name but when you call the 'podman machine ssh' the element should not be there

like you prepare the argument, if there is a custom machine name, you add the machine name to the array else you keep the arguments

@benoitf
benoitf requested a review from a team April 9, 2026 17:43
@podman-desktop-triager
podman-desktop-triager Bot requested a review from benoitf April 9, 2026 17:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/podman/packages/extension/src/extension.ts`:
- Around line 2156-2158: The code sets machineName = '' when the param is absent
and then always passes it to podman commands, causing podman to receive an
empty-string argument instead of omitting the option; change the
command-argument construction so the machineName string is only included/spread
into the args array when machineName is truthy (non-empty). Locate uses of the
machineName variable around the podman machine command invocations (the places
that build args for "podman machine start"/"stop"/etc.) and conditionally
push/spread machineName into those args arrays (and apply the same conditional
pattern to the earlier occurrence where machineName is used) so that when
machineName === '' the argument is omitted entirely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39f56f09-4b9a-4b4b-8123-71a75d3aca08

📥 Commits

Reviewing files that changed from the base of the PR and between 6ff0216 and 0ddc478.

📒 Files selected for processing (1)
  • extensions/podman/packages/extension/src/extension.ts

Comment thread extensions/podman/packages/extension/src/extension.ts

@amisskii amisskii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Functionality tested only

gastoner and others added 4 commits April 13, 2026 19:45
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
@gastoner

Copy link
Copy Markdown
Contributor Author

Rebasing based on latest main

@gastoner
gastoner enabled auto-merge (squash) April 13, 2026 17:45
@gastoner
gastoner merged commit 834f3d3 into podman-desktop:main Apr 13, 2026
40 of 43 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.27.0 milestone Apr 13, 2026
@dgolovin dgolovin changed the title fix(Roseta): fixed roseta enablement on macOS Tahoe with Podman 5.6+ fix(Roseta): fixed Roseta enablement on macOS Tahoe with Podman 5.6+ Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/containers/reviewed qe/testing-required Use when QE testing is needed on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enabling rosetta in the UI should enable it in the VM, but it doesn't

4 participants