-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Description
Steps to reproduce
- Configure a flutter project to run on MacOS (darwin) device
- Run the app in debug mode from VSCode or MacOS terminal [Ventura 13.7.7]
Expected results
The application simulator for the MacOS device should launch and become functional when the project is ran from VSCode GUI or using the flutter run command in the terminal.
Actual results
The application simulator for the MacOS device builds the application but appears as a blank black screen when launching from the VSCode GUI (Debug console, Run in the Menu Bar, Run Icon, etc.). When launching the application simulator from the terminal (i.e. flutter run
, flutter run -d macos
), the application is built and may be functional and navigable, but the process crashes after connecting to the VM service. The debug toolbar is missing hot reload and hot restart icons. In both cases, a 'PathAccessException' prevents _createDevFS from creating a temporary directory in '/tmp'. As a result, this error asynchronously suspends various other DevFS and VMService tools.
The only fix that has enabled a fully functional MacOS simulator runtime is to run flutter run --no-hot -d macos
or without the device specification if it has already been defined.
Failed Workarounds:
- Set a 'TMPDIR' environment variable in 'launch.json' to reflect a path that is in the users directory does not appear to be respected
- Set a global
export TMPDIR
in ~/.zshrc - Launched VSCode directly from terminal to force inheritance of the TMPDIR variable
- Granted Full Disk Access to VSCode, Terminal app, and the Flutter binary itself
- Removed extended attributes from /private/tmp
- Resolved dependencies
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Command
flutter run -d macos -v
Full Output
Crash Report (Error Section of Full Log)
RPCError: _createDevFS: (-32603) Internal error
_createDevFS: Unexpected exception:PathAccessException: Creation of temporary directory failed, path = '/tmp' (OS Error: Operation not permitted, errno = 1)
#0 _checkForErrorResponse (dart:io/common.dart:58:9)
#1 _Directory.createTemp.<anonymous closure> (dart:io/directory_impl.dart:173:7)
<asynchronous suspension>
#2 createTempDirCallback (dart:vmservice_io:121:16)
<asynchronous suspension>
#3 DevFS._createDevFS (dart:_vmservice/devfs.dart:197:21)
<asynchronous suspension>
#4 VMService._routeRequestImpl (dart:_vmservice:842:16)
<asynchronous suspension>
#5 VMService.routeRequest (dart:_vmservice:805:22)
<asynchronous suspension>
#6 WebSocketClient.post (dart:vmservice_io/vmservice_server.dart:64:3)
<asynchronous suspension>
#0 new _OutstandingRequest (package:vm_service/src/vm_service.dart:265:34)
#1 VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1921:25)
#2 VmService._call (package:vm_service/src/vm_service.dart:1933:8)
#3 VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1872:14)
#4 FlutterVmService.createDevFS (package:flutter_tools/src/vmservice.dart:942:20)
#5 DevFS.create (package:flutter_tools/src/devfs.dart:518:61)
#6 FlutterDevice.setupDevFS (package:flutter_tools/src/resident_runner.dart:369:19)
#7 HotRunner._initDevFS (package:flutter_tools/src/run_hot.dart:488:23)
#8 HotRunner._attach (package:flutter_tools/src/run_hot.dart:290:41)
<asynchronous suspension>
#9 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:861:27)
<asynchronous suspension>
#10 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1563:27)
<asynchronous suspension>
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#12 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#13 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:494:9)
<asynchronous suspension>
#14 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)
<asynchronous suspension>
#16 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:98:11)
<asynchronous suspension>
#17 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#18 main (package:flutter_tools/executable.dart:102:3)
<asynchronous suspension>
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.8, on macOS 13.7.7 22H722 darwin-x64, locale en-US) [1,448ms]
• Flutter version 3.32.8 on channel stable at /Users/user/dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision edada7c56e (2 weeks ago), 2025-07-25 14:08:03 +0000
• Engine revision ef0cd00091
• Dart version 3.8.1
• DevTools version 2.45.1
[✗] Android toolchain - develop for Android devices [1,139ms]
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[!] Xcode - develop for iOS and macOS (Xcode 15.2) [6.5s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
✗ Unable to get list of installed Simulator runtimes.
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [51ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (not installed) [49ms]
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
[✓] VS Code (version 1.103.0) [48ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.116.0
[✓] Connected device (2 available) [10.3s]
• macOS (desktop) • macos • darwin-x64 • macOS 13.7.7 22H722 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 139.0.7258.66
[✓] Network resources [1,328ms]
• All expected network resources are available.
! Doctor found issues in 3 categories.