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

Cannot start flutter analyse, dart analyse nor dartanalyzer -h #118

Closed
KaioOCarvalho opened this issue Apr 26, 2022 · 5 comments
Closed
Labels

Comments

@KaioOCarvalho
Copy link

Our team is using SonarQube 9.3.0, running on a Ubuntu 20.04 AWS machine and I've added the plugin sonar-flutter-plugin-0.4.0.jar to the plugins folder. We have a mobile flutter project. By the way, our Java is 11.

I'm trying to use it with GitHub, but on every PR, it was showing no code problems. I then checked the terminal on GitHub and saw this:

INFO: Running 'flutter analyze'...

ERROR: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.

java.io.IOException: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.

And a few lines below I've got this:

Caused by: java.io.IOException: Cannot run program "flutter": error=2, No such file or directory

So I think SonarQube is not finding my flutter. But when I run the following, as you can see, I have flutter and dart installed and on my path, and also Java.

xxxx@ip-xxx-xx-xx-xx:~$ which flutter
/snap/bin/flutter
xxxx@ip-xxx-xx-xx-xx:~$ which dart
/usr/bin/dart
xxxx@ip-xxx-xx-xx-xx:~$ which java
/usr/bin/java
xxxx@ip-xxx-xx-xx-xx:~$ java --version
openjdk 11.0.14.1 2022-02-08
OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

Here is my config files:

.github/workflows/build.yml

name: Build
on:
  push:
    branches: [master, develop] # or the name of your main branch
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
      # If you wish to fail your job when the Quality Gate is red, uncomment the
      # following lines. This would typically be used to fail a deployment.
      # We do not recommend to use this in a pull request. Prefer using pull request
      # decoration instead.
      # - uses: sonarsource/sonarqube-quality-gate-action@master
      #   timeout-minutes: 5
      #   env:
      #     SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

# Project identification
sonar.projectKey=my_key

# Source code location.
# Path is relative to the sonar-project.properties file. Defaults to .
# Use commas to specify more than one folder.
sonar.sources=proj/lib    
# sonar.tests=test

# Encoding of the source code. Default is default system encoding.
sonar.sourceEncoding=UTF-8

# Allows reuse of an existing analyzer report
# sonar.dart.analysis.reportPath=

# Analyzer mode
# Can be:
# - flutter (flutter analyze) - default
# - dart (dart analyze)
# - legacy (dartanalyzer)
# sonar.flutter.analyzer.mode= 

Changing the sonar.flutter.analyzer.mode to dart or legacy just yielded the same problem for dartanalyser -h and dart analyse.

I'm not sure if this is actually a bug, but I've been trying for days to do it, and I've searched a lot.

@hlebmymo
Copy link

hlebmymo commented May 6, 2022

have the same issue...

@hlebmymo
Copy link

hlebmymo commented May 7, 2022

Let's try to use it. Seems like this case works.

name: Sonar
on:
  workflow_dispatch:
  push:
  branches: 
    - dev
 
jobs:

sonarqube:

  runs-on: ubuntu-latest

  steps:

  - name: Checkout the code
    uses: actions/checkout@v2

  - name: Install and set Flutter version
    uses: subosito/flutter-action@v2
    with:
      flutter-version: '2.10.3'
      channel: 'stable'
    
  - name: Run Flutter doctor
    run: |
      flutter doctor -v
                   
  - name: Sonar-scanner
    env:
      SONAR_SCANNER_VER: sonar-scanner-cli-4.7.0.2747-linux
      SONAR_SCANNER_PATH: sonar-scanner-4.7.0.2747-linux/bin
    run: |
      wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
      unzip sonar-scanner-cli-4.7.0.2747-linux.zip
      $SONAR_SCANNER_PATH/sonar-scanner -v
      $SONAR_SCANNER_PATH/sonar-scanner \
        -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
        -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
        -Dsonar.projectKey=${{ secrets.PROJECT_KEY }} \
        -Dsonar.sources=.

@phuc-tranh-otsv
Copy link

@KaioOCarvalho
I think you need add step "subosito/flutter-action@v2" to make sure you installed flutter before sonarqube scanner run flutter analyze.

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label Oct 30, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

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

3 participants