Skip to content

Reading iOS logs requires sudo access: "log: Must be admin to run 'stream' command" #18409

@ghost

Description

@ghost

@csterritt commented on Jun 12, 2018, 12:07 AM UTC:

Steps to Reproduce

Ran flutter create first_try, cd'd into that directory. flutter run works, comes up fine in the iOS emulator. I can run in IntelliJ with the "Run" command (green triangle), but no hot-reload.

If I run with "Debug" command (green bug), I get the empty white screen on the iOS emulator, and the following output:

Launching lib/main.dart on iPhone X in debug mode...
log: Must be admin to run 'stream' command
Script started, output file is /dev/null

Script done, output file is /dev/null
Starting Xcode build...
Xcode build done.

Version info

$ flutter doctor -v
[✓] Flutter (Channel beta, v0.4.4, on Mac OS X 10.13.5 17F77, locale en-US)
• Flutter version 0.4.4 at /Volumes/Second/Chris/hacks/flutter/flutter
• Framework revision f9bb4289e9 (4 weeks ago), 2018-05-11 21:44:54 -0700
• Engine revision 06afdfe54e
• Dart version 2.0.0-dev.54.0.flutter-46ab040e58

[!] Android toolchain - develop for Android devices (Android SDK 28.0.0)
• Android SDK at /Users/chris/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.0
• Java binary at: /Users/chris/hacks/flutter/jdk-10.0.1.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 10.0.1+10)
✗ Android license status unknown.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4, Build version 9F1027a
• ios-deploy 1.9.2
• CocoaPods version 1.5.3

[✗] Android Studio (not installed)
• Android Studio not found; download from [https://developer.android.com/studio/index.html](https://developer.android.com/studio/index.html)
(or visit [https://flutter.io/setup/#android-setup](https://flutter.io/setup/#android-setup) for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2018.1.4)
• IntelliJ at /Users/chris/Applications/IntelliJ IDEA CE.app
• Flutter plugin version 25.0.2
• Dart plugin version 181.4892.1

[!] VS Code (version 1.24.0)
• VS Code at /Users/chris/Applications/Visual Studio Code.app/Contents
• Dart Code extension not installed; install from
[https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code](https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code)

[✓] Connected devices (1 available)
• iPhone X • D34D5096-B3F9-4930-822B-48D3BD71B83D • ios • iOS 11.4 (simulator)

! Doctor found issues in 3 categories.

This issue was moved by devoncarew from flutter/flutter-intellij/issues/2360.

Activity

ghost

ghost commented on Jun 12, 2018

@ghost

@devoncarew commented on Jun 12, 2018, 12:34 AM UTC:

@xster, @cbracken, re: the:

log: Must be admin to run 'stream' command

Do you have a sense for where this is coming from?

ghost

ghost commented on Jun 12, 2018

@ghost

@xster commented on Jun 12, 2018, 12:38 AM UTC:

More interesting was for me:
Script started, output file is but that string (or parts of it) don't appear in our repo. Was this on a custom fork branch?

ghost

ghost commented on Jun 12, 2018

@ghost

@csterritt commented on Jun 12, 2018, 1:05 AM UTC:

@xster Not sure if this is useful to your question, but I just downloaded the Mac installer from flutter.io, I didn't build from github or anything like that.

Thanks for the quick responses!

ghost

ghost commented on Jun 12, 2018

@ghost

@devoncarew commented on Jun 12, 2018, 5:57 PM UTC:

I suspect this is coming from a native tool that we're invoking? In anticipation of that, I'm going to route this to the flutter/flutter repo as a flutter_tools issue.

added
toolAffects the "flutter" command-line tool. See also t: labels.
platform-iosiOS applications specifically
on Jun 12, 2018
jaxondu

jaxondu commented on Jul 19, 2018

@jaxondu

I encounter this same message when running on a friend's Mac where the machine user account I signed in has no admin access. On terminal flutter create myapp, cd to myapp and flutter run. The basic template app can run fine on iOS simulator. Next I try to use Visual Studio Code. No luck only blank white screen on the Simulator.

zoechi

zoechi commented on Jul 24, 2018

@zoechi
Contributor

The section from the flutter run -v output

[  +42 ms] Building Runner.app for 114D27CF-C563-4427-AA18-64034F48DE28.
[   +8 ms] /Users/zoechi/flutter/flutter/bin/cache/dart-sdk/bin/dart /Users/zoechi/flutter/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root /Users/zoechi/flutter/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --strong --target=flutter --no-link-platform --incremental --packages /Users/zoechi/dart/playground/flutter/flutter_19692_tabbar_gridview_2/.packages --output-dill build/app.dill --depfile build/snapshot_blob.bin.d /Users/zoechi/dart/playground/flutter/flutter_19692_tabbar_gridview_2/lib/main.dart
[   +1 ms] script /dev/null /usr/bin/log stream --style syslog --predicate processImagePath CONTAINS "114D27CF-C563-4427-AA18-64034F48DE28"
[  +80 ms] [DEVICE LOG] log: Must be admin to run 'stream' command
[  +11 ms] [DEVICE LOG] Script started, output file is /dev/null
[        ] [DEVICE LOG] 
[        ] [DEVICE LOG] Script done, output file is /dev/null
[        ] log: Must be admin to run 'stream' command
[        ] Script started, output file is /dev/null
[        ] Script done, output file is /dev/null
[+4484 ms] Building bundle
[        ] Writing asset files to build/flutter_assets
zoechi

zoechi commented on Jul 24, 2018

@zoechi
Contributor

No luck only blank white screen on the Simulator.

I opened XCode and got asked if I want to install additional components.
After they were installed I could flutter run from terminal, but from IntelliJ it still only showed a white screen

added this to the Stretch Goals milestone on Jul 24, 2018
eugenious

eugenious commented on Aug 15, 2018

@eugenious

I'm getting the same error too, in VS Code. I am running flutter from a non-admin account, using High Sierra 10.13.6.

In VS Code:

  • Debug | Start Debugging will show the flutter application in the iOS simulator with a blank white screen
  • Debug | Start Without Debugging will launch the application properly.

I feel this issue should be raised higher in priority. I encountered it in my first hour of using flutter, I think there's an issues label for that? It blocks the hot reloading functionality for me.

A more accurate title for this issue might be: "Hot reloading broken for iOS simulator when user is not admin".

The exact error is easy to reproduce in terminal:

> /usr/bin/log stream
log: Must be admin to run 'stream' command

If I were to venture a guess at what the problem is, it seems that the "stream" feature of the /usr/bin/log utility can only be used by an admin user. This might be a recent change in MacOS.

I'm not sure how this feature is used by flutter, it's not clear why the log output is being dumped to /dev/null.

At any rate, the current workaround (your developer account needs to be an admin account) is clearly undesirable.

AskYous

AskYous commented on Aug 21, 2018

@AskYous

I had this problem too. I solved it (somehow) by adding the following to my ~/.bash_profile:

# Flutter
export PATH=~/flutter/bin:$PATH

Then running flutter run in a terminal window (as opposed to Android Studio). Mines works now. Idk why.

DanTup

DanTup commented on Aug 22, 2018

@DanTup
Contributor

The issues seems to be in this code:

/// Launches the device log reader process on the host.
Future<Process> launchDeviceLogTool(IOSSimulator device) async {
// Versions of iOS prior to iOS 11 log to the simulator syslog file.
if (await device.sdkMajorVersion < 11)
return runCommand(<String>['tail', '-n', '0', '-F', device.logFilePath]);
// For iOS 11 and above, use /usr/bin/log to tail process logs.
// Run in interactive mode (via script), otherwise /usr/bin/log buffers in 4k chunks. (radar: 34420207)
return runCommand(<String>[
'script', '/dev/null', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
]);
}

For iOS >= 11 we call /usr/bin/log stream which doesn't work for non-admins. Trying to find answers, I found lots of people complaining that Xcode is broken after this upgrade for non-Admins too (and the fixes all seem hit and miss).

(cc @cbracken - it was a while ago, but you worked on this in #12079 - do you know if there might be any alternatives?)

34 remaining items

added this to the New Stretch Goals milestone on Jan 7, 2020
changed the title [-]Odd logging error message with IntelliJ, "log: Must be admin to run 'stream' command"[/-] [+]Reading iOS logs requires sudo access: "log: Must be admin to run 'stream' command"[/+] on Jan 23, 2020
leogny

leogny commented on Jan 23, 2020

@leogny

Struggled with this problem for a good two weeks.

Deleting flutter/bin/cache solved the issue.

preetjdp

preetjdp commented on Feb 6, 2020

@preetjdp

Hi are there any updates to this.
As is @ryanheise I'm trying to get this working with MacInCloud.
And the solution that @keng42 suggested will not work as MacInCloud does not give "sudo" access.

cfanatic

cfanatic commented on Apr 4, 2020

@cfanatic

My workaround

Change

return runCommand(<String>[
'script', '/dev/null', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
]);

to

  return runCommand(<String>[
    'script', '/dev/null', 'sudo', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
  ]);

(add 'sudo',)

And add this rule to /etc/sudoers

myuser          ALL = (root) NOPASSWD: /usr/bin/log

and delete flutter/bin/cache so it gets rebuilt

God, I am so glad I stumbled over this advice after half a day of troubleshooting while trying to proceed on https://flutter.dev/docs/get-started/test-drive?tab=vscode. I was always getting a white screen on my simulated iOS device. After making sure that log runs with sudo, I was able to get the app to run and test hot reload.

My setup:
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E266, locale en-DE)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
[✓] VS Code (version 1.43.2)
[✓] Connected device (1 available)

zanderso

zanderso commented on Apr 6, 2020

@zanderso
Member

@christopherfujino @jmagman any advice on this issue?

jmagman

jmagman commented on Apr 6, 2020

@jmagman
Member

This doesn't work for real devices anyway. I wonder if there are permission issues with switching this to xcrun simctl spawn <device-id> log stream for simulators?

self-assigned this
on Apr 6, 2020
lock

lock commented on Apr 25, 2020

@lock

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

locked and limited conversation to collaborators on Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: regressionIt was better in the past than it is nowplatform-iosiOS applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @cbracken@zoechi@Hixie@fuerst@jmagman

    Issue actions

      Reading iOS logs requires sudo access: "log: Must be admin to run 'stream' command" · Issue #18409 · flutter/flutter