Unable to run any flutter commands 'The flutter tool cannot access the file or directory'
Solution 1
My problem was importing a project from Windows. I compared the imported folder with one that was created on MacOS and the difference was that appeared extended attribute. So my solution was to remove the extended attributes via command line:
$ sudo xattr -c -r <project_folder>
Solution 2
I also faced same issue when i migrate flutter version to 2.0. Only the solution was grant permission to the user for that location.
you may simply run this command :
$ sudo chown -R <username> /Users/<username>/.config
should be replaced with your user name.
Solution 3
go to flutter sdk folder then,inside bin folder open this path in terminal.now run a command "git stash"
now perform your command "flutter channel beta"
Related videos on Youtube
MrHarvey
Updated on June 04, 2022Comments
-
MrHarvey almost 2 years
Whenever I run a flutter command including:
- flutter doctor
- flutter clean
- flutter channel [any channel]
- etc
I get the following error:
Gregorys-MacBook-Pro:~ gregory$ flutter doctor Unhandled exception: Exception: Flutter failed to create a directory at "/Users/gregory/.config/flutter". The flutter tool cannot access the file or directory. Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user. #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 _throwFileSystemException (package:flutter_tools/src/base/error_handling_io.dart:749:3) #2 _handlePosixException (package:flutter_tools/src/base/error_handling_io.dart:697:3) #3 _runSync (package:flutter_tools/src/base/error_handling_io.dart:561:7) #4 ErrorHandlingDirectory.createSync (package:flutter_tools/src/base/error_handling_io.dart:408:12) #5 new Config (package:flutter_tools/src/base/config.dart:33:17) #6 runInContext.<anonymous closure> (package:flutter_tools/src/context_runner.dart:146:21) #7 AppContext._generateIfNecessary.<anonymous closure> (package:flutter_tools/src/base/context.dart:104:41) #8 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:311:23) #9 AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:92:20) #10 AppContext.get (package:flutter_tools/src/base/context.dart:121:32) #11 config (package:flutter_tools/src/globals.dart:47:30) #12 getBuildDirectory (package:flutter_tools/src/build_info.dart:673:48) #13 defaultDepfilePath (package:flutter_tools/src/bundle.dart:29:55) #14 new BuildBundleCommand (package:flutter_tools/src/commands/build_bundle.dart:24:42) #15 new BuildCommand (package:flutter_tools/src/commands/build.dart:33:19) #16 main.<anonymous closure> (package:flutter_tools/executable.dart:102:5) #17 run.<anonymous closure> (package:flutter_tools/runner.dart:50:13) <asynchronous suspension> #18 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #19 AppContext.run (package:flutter_tools/src/base/context.dart:149:12) <asynchronous suspension> #20 runInContext (package:flutter_tools/src/context_runner.dart:73:10) <asynchronous suspension> #21 main (package:flutter_tools/executable.dart:90:3) <asynchronous suspension>
Just before I started getting this error I did the following:
- Deleted Library/developer/coresimulator/caches folder
- Changed flutter channel to
beta
I was trying to get disk space for an xcode update.
-
MrHarvey about 3 yearsHere is my git status in flutter folder:
Gregorys-MacBook-Pro:flutter gregory$ git status warning: unable to access '/Users/gregory/.config/git/attributes': Permission denied On branch beta Your branch is up to date with 'origin/beta'. nothing to commit, working tree clean
-
MrHarvey about 3 yearsI seem to get the same problem
Gregorys-MacBook-Pro:bin gregory$ git stash warning: unable to access '/Users/gregory/.config/git/attributes': Permission denied
-
MrHarvey about 3 yearsYes I am sure, it has not changed location since I installed it and I have never seen this error before. The actual location of my flutter folder is
/Users/gregory/Dev/flutter
so I'm not sure why it is saying.config/flutter
-
Zeeshan Mehdi over 2 yearsthis resolved my issue.