Skip to content

vm-service crashes if path to flutter starts with two slashes (/) #7279

Closed

Description

@sethladd

http://stackoverflow.com/questions/41187802/issue-building-flutter-on-a-mac

Flutter was working just fine a few weeks ago, however it appears to be broken on my system. I cleaned my existing install and re-cloned and installed flutter, but it seems to fail with the following problem:

    Akshays-MacBook-Pro-2:~ akshaydashrath$ flutter doctor
    Downloading Dart SDK 1.21.0...
    #################################################################100.0%
    Building flutter tool...
    vm-service: Error: Unhandled exception:
    Unsupported operation: Cannot extract a non-Windows file path from a 
    file URI with an authority
    \#0      _SimpleUri._toFilePath (dart:core/uri.dart:4423)
    \#1      _SimpleUri.toFilePath (dart:core/uri.dart:4417)
    \#2      _loadFile (loader.dart:407:26)
    \#3      _handleResourceRequest (loader.dart:510:5)
    \#4      _processLoadRequest (loader.dart:941:7)
    \#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

I've recently updated MacOS to 10.12.2 apart from that I can't identify any other changes I've made that could affect the system.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    c: regressionIt was better in the past than it is now
    on Dec 16, 2016
  2. added this to the 0: Today milestone on Dec 16, 2016
  3. sethladd commented on Dec 16, 2016

    @sethladd
    ContributorAuthor

    Related Dart SDK issue: dart-lang/sdk#28143

    I will now upgrade my laptop's OS, because I <3 my users. :)

  4. sethladd commented on Dec 16, 2016

    @sethladd
    ContributorAuthor
  5. sethladd commented on Dec 16, 2016

    @sethladd
    ContributorAuthor

    I upgraded to 10.12.2 and flutter doctor works for me. Maybe the error only happens when we're downloading the Dart SDK?

    I deleted my flutter/bin/cache and reran flutter doctor and it succeeded.

  6. sethladd commented on Dec 16, 2016

    @sethladd
    ContributorAuthor

    @akshaydashrath

    Can you please add the following to your $FLUTTER_HOME/bin/flutter script?

        set # <====== add this
        (cd "$FLUTTER_TOOLS_DIR"; rm -f pubspec.lock; "../../bin/cache/dart-sdk/bin/pub" get --verbosity=error --no-packages-dir)
        "$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
        echo "FINISHED SNAPSHOT" # <====== add this
    

    And copy the results to this issue.

    Thanks!

  7. akshaydashrath commented on Dec 17, 2016

    @akshaydashrath

    Hey Seth,

    Tried a cache clean but that didn't work, however I did paste your code and it appears it's a PATH issue, which I don't understand, I'll go through my
    Just as reference here's the output

    ANDROID_HOME=/Users/akshaydashrath/Android/SDK Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.cgDXublCs1/Render BASH=/bin/bash BASH_ARGC=([0]="1") BASH_ARGV=([0]="doctor") BASH_LINENO=([0]="0") BASH_SOURCE=([0]="/Users/akshaydashrath/sdk/flutter/bin/flutter") BASH_VERSINFO=([0]="3" [1]="2" [2]="57" [3]="1" [4]="release" [5]="x86_64-apple-darwin16") BASH_VERSION='3.2.57(1)-release' DIRSTACK=() EUID=501 FLUTTER_HOME=/Users/akshaydashrath/sdk/flutter GOPATH=/Users/akshaydashrath/.go GROUPS=() HOME=/Users/akshaydashrath HOSTNAME=Akshays-MBP-2 HOSTTYPE=x86_64 IFS=$' \t\n' LANG=en_GB.UTF-8 LOGNAME=akshaydashrath MACHTYPE=x86_64-apple-darwin16 OPTERR=1 OPTIND=1 OSTYPE=darwin16 PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/akshaydashrath/Android/SDK/tools:/Users/akshaydashrath/Android/SDK/platform-tools:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/akshaydashrath/Android/SDK/tools:/Users/akshaydashrath/Android/SDK/platform-tools:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/akshaydashrath/Android/SDK/tools:/Users/akshaydashrath/Android/SDK/platform-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/akshaydashrath/Android/SDK/build-tools/22.0.1/:/Users/akshaydashrath/sdk/appengine/bin/://Users/akshaydashrath/.go/bin://Users/akshaydashrath/sdk/flutter/bin:/Users/akshaydashrath/Android/SDK/build-tools/22.0.1/:/Users/akshaydashrath/sdk/appengine/bin/://Users/akshaydashrath/.go/bin:/Users/akshaydashrath/sdk/flutter/bin:/Users/akshaydashrath/Android/SDK/build-tools/22.0.1/:/Users/akshaydashrath/sdk/appengine/bin/://Users/akshaydashrath/.go/bin:/Users/akshaydashrath/sdk/flutter/bin PIPESTATUS=([0]="0") PPID=38745 PS4='+ ' PWD=/Users/akshaydashrath/sdk/flutter/bin SHELL=/bin/bash SHELLOPTS=braceexpand:errexit:hashall:interactive-comments SHLVL=2 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.2uYhVU321X/Listeners TERM=xterm-256color TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=388 TERM_SESSION_ID=B31FF374-DC04-4AB5-B381-D8E2C36537A7 TMPDIR=/var/folders/lq/50s7k5p930z0619cl2khwk5r0000gn/T/ UID=501 USER=akshaydashrath XPC_FLAGS=0x0 XPC_SERVICE_NAME=0 _=-e __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2 //Users/akshaydashrath/sdk/flutter/bin/flutter: line 9: ../../bin/cache/dart-sdk/bin/pub: No such file or directory

    As you see in the last line theres a

    //Users/akshaydashrath/sdk/flutter/bin/flutter: line 9: ../../bin/cache/dart-sdk/bin/pub: No such file or directory
    instead of
    /Users/akshaydashrath/sdk/flutter/bin/flutter: line 9: ../../bin/cache/dart-sdk/bin/pub: No such file or directory

    My apologies for wasting your time. I tried executing flutter directly from root of the SDK and it works, however I have no clue if the path is gone off why its being picked up by the terminal or why it stopped working all of a sudden. I'll do a bit more digging but I'm guessing its my machine.

  8. akshaydashrath commented on Dec 17, 2016

    @akshaydashrath

    Also just as a reference this is my .bash_profile

    export ANDROID_HOME=/Users/akshaydashrath/Android/SDK
    export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH:$ANDROID_HOME/build-tools/22.0.1/"
    export PATH="$PATH:/Users/akshaydashrath/sdk/appengine/bin/"

    PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
    export PATH

    export GOPATH=$HOME/.go
    export PATH="$PATH:/$GOPATH/bin"

    export FLUTTER_HOME=/Users/akshaydashrath/sdk/flutter
    export PATH="$FLUTTER_HOME/bin:$PATH"

  9. eseidelGoogle commented on Dec 17, 2016

    @eseidelGoogle
    Contributor

    Lol. I was able to repro by changing my $PATH:

    Now I'm adding //src/flutter/bin to my PATH instead of /src/flutter/bin and BAM:

    %flutter doctor                                                                                  [~]
    vm-service: Error: Unhandled exception:
    Unsupported operation: Cannot extract a non-Windows file path from a file URI with an authority
    #0      _SimpleUri._toFilePath (dart:core/uri.dart:4423)
    #1      _SimpleUri.toFilePath (dart:core/uri.dart:4417)
    #2      _loadFile (loader.dart:407:26)
    #3      _handleResourceRequest (loader.dart:510:5)
    #4      _processLoadRequest (loader.dart:941:7)
    #5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
    

    @johnmccutchan

  10. changed the title [-]Unable to run flutter doctor on Mac[/-] [+]vm-service crashes if path to flutter has extra / in it[/+] on Dec 17, 2016
  11. eseidelGoogle commented on Dec 17, 2016

    @eseidelGoogle
    Contributor

    Possibly two bugs. One being in dart:core path handling/url canonicalization. And second being a missing abspath call wherever we're handling the incoming flutter path.

  12. johnmccutchan commented on Dec 19, 2016

    @johnmccutchan
    Contributor

    I've reopened dart-lang/sdk#28143 for the VM side.

  13. changed the title [-]vm-service crashes if path to flutter has extra / in it[/-] [+]vm-service crashes if path to flutter starts with two slashes (/)[/+] on Dec 19, 2016
  14. jason-simmons commented on Dec 19, 2016

    @jason-simmons
    Member

    This can be reproduced by running:

    bin/cache/dart-sdk/bin/dart //path/to/flutter/bin/cache/flutter_tools.snapshot
    

    using an absolute path with two leading slashes.

    Dart's Uri.parse() interprets the characters after the two slashes as the authority part of the URL, which seems accurate based on https://tools.ietf.org/html/rfc3986#section-3.3

    As a result, _resolveScriptUri converts the snapshot path to a URI like:

    file://path/to/flutter/bin/cache/flutter_tools.snapshot
    

    which doesn't load.

    Dart's main.cc is passing the script file command line argument directly to the URI parser. If this argument is supposed to be in URI format, then the bin/flutter script will need to convert the filesystem path.

  15. Hixie commented on Dec 19, 2016

    @Hixie
    Contributor

    Please disregard the IETF draft. The correct spec for URL parsing is https://url.spec.whatwg.org/.

  16. sethladd commented on Dec 20, 2016

    @sethladd
    ContributorAuthor

    Thanks for the additional info and quick fix.

  17. github-actions commented on Sep 5, 2021

    @github-actions

    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.

  18. locked as resolved and limited conversation to collaborators on Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions