Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter projects are excluded if analysis_options exclusions begin with /** #4083

Closed
mdeandrea-mrmilu opened this issue Aug 3, 2022 · 9 comments
Labels
Milestone

Comments

@mdeandrea-mrmilu
Copy link

Describe the bug

When update to version 3.46.0 and has a FVM config in my machine, the Dart Code extension only found a Dart SDK from FVM and don't found a Flutter SDK

To Reproduce
Steps to reproduce the behavior:
0. Has installed a FVM

  1. Update to 3.46.0
  2. Open a Flutter project using Flutter version from FVM
  3. Error: Dart code don't found the Flutter SDK, only de Dart SDK

Expected behavior

Found Flutter SDK when has a Flutter project and a FVM config

Screenshots

Screenshot 2022-08-03 at 08 40 36

When open one file in this Flutter project, show me this instead Flutter 3.0.5:
Screenshot 2022-08-03 at 08 41 59

Please complete the following information:

  • Operating System and version: MacOS Monterey 12.4
  • VS Code version: 1.69.2
  • Dart extension version: 3.46.0
  • Dart/Flutter SDK version: 2.17.6 / 3.0.5
  • Target device (if the issue relates to Flutter debugging):

VS Code config (only related to Dart Code extension):

{
    "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.selectionHighlight": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets"
    },
    "dart.flutterSdkPath": ".fvm/flutter_sdk",
    "dart.flutterSdkPaths": [
        "/Users/Matias/fvm/versions"
    ],
    "search.exclude": {
        "**/.fvm": true
    },
    "files.watcherExclude": {
        "**/.fvm": true
    },
    "dart.showInspectorNotificationsForWidgetErrors": false,
    "dart.debugExternalPackageLibraries": false,
    "dart.debugSdkLibraries": false,
    "dartImport.fixOnSave": true,
    "dartImport.showInfoMessages": false,
    "dart.previewFlutterUiGuides": true,
    "dart.showIgnoreQuickFixes": false,
    "dart.flutterOutline": false,
    "dart.renameFilesWithClasses": "prompt",
    "dart.warnWhenEditingFilesOutsideWorkspace": false
}
@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

Can you open this project and then run the Dart: Open Extension Log and provide the log here (be sure to remove anything sensitive first)?

Thanks!

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Aug 3, 2022
@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

Can you also attach the pubspec.yaml for your project (again, with anything sensitive removed). In particular, the dependencies: section.

@mdeandrea-mrmilu
Copy link
Author

mdeandrea-mrmilu commented Aug 3, 2022

Hi @DanTup, thanks for faster replay

pubspec.yaml
name: private_project
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.1+1

environment:
  sdk: ">=2.17.5 <3.0.0"
  flutter: ">=3.0.0"

dependencies:
  auto_route: 4.2.0
  cupertino_icons: 1.0.5
  easy_localization: 3.0.1
  faker_dart: 0.1.6
  flutter:
    sdk: flutter
  flutter_form_builder: 7.4.0
  flutter_riverpod: 2.0.0-dev.9
  flutter_svg: 1.1.1+1
  freezed_annotation: 2.0.3
  injectable: 1.5.3
  intl: 0.17.0
  json_annotation: 4.6.0
  get_it: 7.2.0
  riverpod: 2.0.0-dev.9

dev_dependencies:
  auto_route_generator: 4.2.0
  build_runner: 2.1.11
  flutter_lints: 2.0.1
  flutter_test:
    sdk: flutter
  freezed: 2.0.4
  index_generator: 3.3.0
  injectable_generator: 1.5.3
  json_serializable: 6.3.1
  
dependency_overrides: 
  analyzer: 4.2.0

flutter:
  uses-material-design: true

  assets:
         ...

The only replace that I made, was the string private.project

Extension log
!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.46.0
Flutter extension: 3.46.0 (not activated)

App: Visual Studio Code
Version: 1.69.2
Platform: mac

HTTP_PROXY: undefined
NO_PROXY: undefined

Logging Categories:
    General

Wed Aug 03 2022 [12:12:39 GMT+0200 (Central European Summer Time)] Log file started
[12:12:39 PM] [General] [Info] Searching for SDKs...
[12:12:39 PM] [General] [Info] Environment PATH:
[12:12:39 PM] [General] [Info]     /usr/local/opt/php@7.4/sbin
[12:12:39 PM] [General] [Info]     /usr/local/opt/php@7.4/bin
[12:12:39 PM] [General] [Info]     /Users/matias/.nvm/versions/node/v16.8.0/bin
[12:12:39 PM] [General] [Info]     /Applications/Android Studio.app/Contents/jre/Contents/Home//bin
[12:12:39 PM] [General] [Info]     /usr/local/bin
[12:12:39 PM] [General] [Info]     /usr/bin
[12:12:39 PM] [General] [Info]     /bin
[12:12:39 PM] [General] [Info]     /usr/sbin
[12:12:39 PM] [General] [Info]     /sbin
[12:12:39 PM] [General] [Info]     /Library/Apple/usr/bin
[12:12:39 PM] [General] [Info]     /Users/matias/Library/Android/sdk/tools
[12:12:39 PM] [General] [Info]     /Users/matias/Library/Android/sdk/platform-tools
[12:12:39 PM] [General] [Info]     /Users/matias/.pub-cache/bin
[12:12:39 PM] [General] [Info] Took 336ms to search for projects (5 levels)
[12:12:39 PM] [General] [Info] Took 4ms to filter out excluded projects (6 exclusion rules)
[12:12:39 PM] [General] [Info] Searching for flutter
[12:12:39 PM] [General] [Info]     Looking for flutter in:
[12:12:39 PM] [General] [Info]         /private/var/mrmilu/private.project/.fvm/flutter_sdk
[12:12:39 PM] [General] [Info]         /private/var/mrmilu/private.project/.fvm/flutter_sdk/bin
[12:12:39 PM] [General] [Info]         /Users/matias/flutter-sdk
[12:12:39 PM] [General] [Info]         /Users/matias/flutter-sdk/bin
[12:12:39 PM] [General] [Info]         /google/flutter
[12:12:39 PM] [General] [Info]         /google/flutter/bin
[12:12:39 PM] [General] [Info]         /usr/local/opt/php@7.4/sbin
[12:12:39 PM] [General] [Info]         /usr/local/opt/php@7.4/bin
[12:12:39 PM] [General] [Info]         /Users/matias/.nvm/versions/node/v16.8.0/bin
[12:12:39 PM] [General] [Info]         /Applications/Android Studio.app/Contents/jre/Contents/Home//bin
[12:12:39 PM] [General] [Info]         /usr/local/bin
[12:12:39 PM] [General] [Info]         /usr/bin
[12:12:39 PM] [General] [Info]         /bin
[12:12:39 PM] [General] [Info]         /usr/sbin
[12:12:39 PM] [General] [Info]         /sbin
[12:12:39 PM] [General] [Info]         /Library/Apple/usr/bin
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/tools
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/tools/bin
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/platform-tools
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/platform-tools/bin
[12:12:39 PM] [General] [Info]         /Users/matias/.pub-cache/bin
[12:12:39 PM] [General] [Info]     Found at:
[12:12:39 PM] [General] [Info]         /private/var/mrmilu/private.project/.fvm/flutter_sdk/bin
[12:12:39 PM] [General] [Info] Following symlink: /private/var/mrmilu/private.project/.fvm/flutter_sdk/bin/flutter ==> /Users/matias/fvm/versions/3.0.5/bin/flutter
[12:12:39 PM] [General] [Info]     Candidate paths to be post-filtered:
[12:12:39 PM] [General] [Info]         /Users/matias/fvm/versions/3.0.5
[12:12:39 PM] [General] [Info]     Found at /Users/matias/fvm/versions/3.0.5
[12:12:39 PM] [General] [Info]     Returning SDK path /Users/matias/fvm/versions/3.0.5 for flutter
[12:12:39 PM] [General] [Info] Searching for dart
[12:12:39 PM] [General] [Info]     Looking for dart in:
[12:12:39 PM] [General] [Info]         /usr/local/opt/php@7.4/sbin
[12:12:39 PM] [General] [Info]         /usr/local/opt/php@7.4/bin
[12:12:39 PM] [General] [Info]         /Users/matias/.nvm/versions/node/v16.8.0/bin
[12:12:39 PM] [General] [Info]         /Applications/Android Studio.app/Contents/jre/Contents/Home//bin
[12:12:39 PM] [General] [Info]         /usr/local/bin
[12:12:39 PM] [General] [Info]         /usr/bin
[12:12:39 PM] [General] [Info]         /bin
[12:12:39 PM] [General] [Info]         /usr/sbin
[12:12:39 PM] [General] [Info]         /sbin
[12:12:39 PM] [General] [Info]         /Library/Apple/usr/bin
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/tools
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/tools/bin
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/platform-tools
[12:12:39 PM] [General] [Info]         /Users/matias/Library/Android/sdk/platform-tools/bin
[12:12:39 PM] [General] [Info]         /Users/matias/.pub-cache/bin
[12:12:39 PM] [General] [Info]         /Users/matias/fvm/versions/3.0.5/bin/cache/dart-sdk
[12:12:39 PM] [General] [Info]         /Users/matias/fvm/versions/3.0.5/bin/cache/dart-sdk/bin
[12:12:39 PM] [General] [Info]     Found at:
[12:12:39 PM] [General] [Info]         /usr/local/bin
[12:12:39 PM] [General] [Info]         /Users/matias/fvm/versions/3.0.5/bin/cache/dart-sdk/bin
[12:12:39 PM] [General] [Info] Following symlink: /usr/local/bin/dart ==> /usr/local/Cellar/dart/2.17.6/libexec/bin/dart
[12:12:39 PM] [General] [Info]     Candidate paths to be post-filtered:
[12:12:39 PM] [General] [Info]         /usr/local/Cellar/dart/2.17.6/libexec
[12:12:39 PM] [General] [Info]         /Users/matias/fvm/versions/3.0.5/bin/cache/dart-sdk
[12:12:39 PM] [General] [Info]     Found at /usr/local/Cellar/dart/2.17.6/libexec
[12:12:39 PM] [General] [Info]     Returning SDK path /usr/local/Cellar/dart/2.17.6/libexec for dart
[12:12:39 PM] [General] [Info] !! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.46.0
Flutter extension: 3.46.0 (not activated)

App: Visual Studio Code
Version: 1.69.2
Platform: mac

Workspace type: Dart
Analyzer type: LSP
Multi-root?: false

Dart SDK:
    Loc: /usr/local/Cellar/dart/2.17.6/libexec
    Ver: 2.17.6
Flutter SDK:
    Loc: /Users/matias/fvm/versions/3.0.5
    Ver: 3.0.5

HTTP_PROXY: undefined
NO_PROXY: undefined
[12:12:39 PM] [General] [Info] Returning cached results for project search
[12:12:39 PM] [General] [Info] Extension:Startup timing: 457ms
[12:12:39 PM] [General] [Info] Found 0 folders requiring "pub get":
[12:12:39 PM] [General] [Info] Caching Pub package names from pub.dev...
[12:12:40 PM] [General] [Info] Analyzer:Startup timing: 743ms
[12:12:40 PM] [General] [Info] Returning cached results for project search
[12:12:44 PM] [General] [Info] Analyzer:FirstAnalysis timing: 3367ms

@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

Can you confirm which folder(s) you're opening in VS Code, and where the pubspec.yaml is in relation to that?

The log suggests either we didn't find any Flutter projects (that is, we didn't see sdk: flutter in any pubspec.yamls), or they were filtered out by either dart.analysisExcludedFolders or exclusions in analysis_options.yaml. Excluding using analysis_options.yaml is new in the latest version - is it possible you're excluding the project there? (the log above suggests you have 6 exclusion rules).

@mdeandrea-mrmilu
Copy link
Author

I used this project folder: /private/var/mrmilu/private.project/ and pubspec.yaml is here /private/var/mrmilu/private.project/pubspec.yaml

My analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
  exclude:
    - lib/**/*.g.dart
    - lib/**/*.config.dart
    - test/**/*.mocks.dart
    - /**/generated/*
    - lib/**/*.freezed.dart
    - lib/generated_plugin_registrant.dart
linter:
  rules:
    - unnecessary_parenthesis
    - prefer_single_quotes
    - prefer_relative_imports
    - require_trailing_commas

@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

Ah, thanks! The issue is this:

    - /**/generated/*

The code we're using to handle these exclusions is naive and not handling this ** correctly (we're ignoring everything after the ** which doesn't make sense here). I'll work on a fix, but as a workaround, you could change the line to this:

    - "**/generated/*"

Not having the leading slash prevents us from interpreting this rule, so it should prevent the project being excluded.

@DanTup DanTup removed the awaiting info Requires more information from the customer to progress label Aug 3, 2022
@DanTup DanTup changed the title Don't found Flutter SDK (FVM) Flutter projects are excluded if analysis_options exclusions begin with /** Aug 3, 2022
@DanTup DanTup added this to the v3.46.1 milestone Aug 3, 2022
@mdeandrea-mrmilu
Copy link
Author

Nice catch!

I change /**/generated/* to lib/**/generated/* and works fine.

Thanks a lot for help

@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

Re-opening this as I'm going to ship a better fix that doesn't handle ** so badly.

@DanTup DanTup reopened this Aug 3, 2022
@DanTup DanTup closed this as completed in 61fc81d Aug 3, 2022
@DanTup
Copy link
Member

DanTup commented Aug 3, 2022

A better fix shipped in v3.46.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants