为什么Flutter仅以超级用户身份运行?

时间:2018-07-16 03:51:38

标签: android ios macos dart flutter

我最近尝试在Macbook Pro上安装Flutter框架(2015年初,MacOS v10.13.6)。我在/Applications目录中解压缩了软件包,并在bash配置文件中创建了相应的路径。但是,在终端上以默认用户身份运行flutter doctor命令时,遇到以下错误。

shlock: open(/Applications/flutter/bin/cache/shlock2538): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2540): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2542): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2544): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2546): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2548): Permission denied
shlock: open(/Applications/flutter/bin/cache/shlock2550): Permission denied

当我使用超级用户特权(flutter doctor)运行sudo命令时,它就可以运行,并且得到以下终端输出。

Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
        For more info, see https://flutter.io/platform-plugins
      To install:
        brew install cocoapods
        pod setup
[✓] Android Studio (version 3.1)
[!] Connected devices
    ! No devices available

! Doctor found issues in 2 categories.

我宁愿以Flutter作为默认用户而不是具有超级用户特权运行(即使自框架收到警告后也要以默认用户身份运行)。

任何人都可以帮助我了解如何解决此错误并开始使用默认用户帐户运行Flutter框架吗?谢谢。

2 个答案:

答案 0 :(得分:1)

Flutter在其安装目录中维护着多个文件,例如Dart快照文件,这就是为什么/Applications(默认情况下仅对root用户具有写权限)不是安装Flutter的好地方的原因。

/Users/yourUser/flutter在没有root特权的情况下可以正常工作。

答案 1 :(得分:0)

我尝试更改颤振的位置,正如GünterZöchbauer回答的那样。但是,扑打仍然需要超级用户特权。所以,我像这样直接给了他们

sudo chown -R $USER /Users/yourUser/flutter/

这对我来说很好。基本上,向用户授予特定文件夹的权限。