10
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Mac / Apple Silicon】Rancher Desktop + AWS SAMでローカル実行ができない問題

Last updated at Posted at 2025-12-04

はじめに

MacのRancher Desktopを使用した環境でAWS SAMをローカル実行すると、エラーが発生して動かない問題にぶつかりました。
Docker Desktopを使っていたときは問題なく動作していただけに、原因が分からず盛大にハマりました...

少しニッチなケースかもしれませんが、同じ状況で困っている方の参考になれば幸いです。

環境情報

以下の環境でエラーを確認しました。

PC1

  • MacBook Pro(M4, 2024)
  • macOS: Sequoia 15.6
  • Rancher Desktop Version 1.20.1
  • SAM CLI, Version 1.142.1

PC2

  • MacBook Air(M1, 2020)
  • macOS: Sonoma 14.8.2
  • Rancher Desktop Version 1.20.1
  • SAM CLI, Version 1.148.0

発生したエラー

ランタイムはnodejs22.xruby3.4python3.9 それぞれで確認しました。
また、sam initで作成できるテンプレート「Hello World Example」を使用して検証しています。

sam local invoke でローカル実行を試みると、exec format error が発生し最終的にコンテナとの接続が確立できずタイムアウトする挙動でした。

発生したエラー
$ sam local invoke

exec /var/rapid/aws-lambda-rie: exec format error
Timed out while attempting to establish a connection to the container. You can increase this timeout by setting the                                    
SAM_CLI_CONTAINER_CONNECTION_TIMEOUT environment variable. The current timeout is 20.0 (seconds).   

解決

Rancher DesktopのメインウィンドウからPreferences > Virtual Machine > Emulationを開き、以下オプションにチェックを入れることでエラーが解消しました。
※インストール直後はQEMUにチェックが入っていました。

  • Virtual Machine > VZ
  • VZ Option > Enable Rosetta support

スクリーンショット 2025-11-26 21.39.25.png

おまけ

PC2はもともとmacOSがVentura 13.7.6でした。
このときに今回ご紹介した解決策を試しても別のエラーが発生しました。
使用するLambdaのアーキテクチャをarm64に変更することで解消できましたが、個人的にはmacOSをSonoma以上にアップデートしたほうが無難だと感じました。

発生したエラー
rosetta error: unhandled auxillary vector type 28

template.yamlでアーキテクチャをx86_64からarm64に変更します。

template.yaml
Properties:
  Runtime: nodejs22.x
  Architectures:
    - arm64

その後、ビルドして再度実行すればエラーは解消し正常に動作しました。

$ sam build   
$ sam local invoke
10
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?