Skip to content

[grpc] lib list and board details throw incorrect error when directories.data folder does not exist at daemon startup #1262

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

Closed
kittaakos opened this issue Apr 12, 2021 · 4 comments
Assignees
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@kittaakos
Copy link
Contributor

Bug Report

As a gRPC consumer of the CLI, I receive an incorrect error message from lib list when the directories.data location does not exist before the InitRequest.

Current behavior

I cannot attach code, but this is my workflow:

  • Clean directories.data location (on macOS is it rm -rf ~/Library/Arduino15/),
  • Create a client with the InitRequest.
  • Note: at this point, the Arduino15 folder exists on my filesystem:
Arduino15 % ls -al
total 8
drwxr-xr-x   6 akos.kitta  staff   192 Apr 12 17:02 .
drwx------@ 92 akos.kitta  staff  2944 Apr 12 17:02 ..
-rw-r--r--   1 akos.kitta  staff   104 Apr 12 17:02 inventory.yaml
drwxr-xr-x   3 akos.kitta  staff    96 Apr 12 17:02 packages
drwxr-xr-x   3 akos.kitta  staff    96 Apr 12 17:02 staging
drwxr-xr-x   2 akos.kitta  staff    64 Apr 12 17:02 tmp
  • Run a LibraryListRequest
{
  "instance": { "id": 1 },
  "all": true,
  "updatable": false,
  "name": "",
  "fqbn": "arduino:samd:arduino_zero_edbg"
}
  • It fails, but with an incorrect error message:
2 UNKNOWN: loading board data: unknown package arduino

Expected behavior

  • The LibraryListRequest fails, but with the following error message:
2 UNKNOWN: loading board data: platform arduino:samd is not installed

Environment

  • CLI version (output of arduino-cli version): arduino-cli alpha Version: nightly-20210408 Commit: a4ee670a Date: 2021-04-08T01:26:00Z
  • OS and platform:

Additional context

  • I had my Arduino Zero board attached.
  • I used the default CLI config with two additional 3rd party URLs.
  • I tried to run a RescanRequest right after the InitRequest and before the LibraryListRequest. The RescanResponse was completely broken on my side: it had one library and multiple platform errors.
@kittaakos
Copy link
Contributor Author

The same error happens when I do board details instead of lib list.

@kittaakos kittaakos changed the title [grpc] lib list --fqbn the:board:fqn --all throws incorrect error when directories.data folder does not exist at daemon startup [grpc] lib list and board details throw incorrect error when directories.data folder does not exist at daemon startup Apr 12, 2021
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Apr 12, 2021
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Apr 14, 2021
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Apr 14, 2021
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Apr 14, 2021
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Mar 31, 2022
@per1234 per1234 self-assigned this Mar 31, 2022
@umbynos umbynos assigned cmaglie and unassigned per1234 Nov 30, 2022
@umbynos umbynos added this to the Arduino CLI 0.30.0 milestone Nov 30, 2022
@umbynos umbynos assigned Bikappa and unassigned cmaglie Jan 18, 2023
@kittaakos kittaakos self-assigned this Jan 23, 2023
@kittaakos
Copy link
Contributor Author

kittaakos commented Jan 23, 2023

This issue works as expected when using the CLI from a terminal:

./arduino-cli version
arduino-cli  Version: git-snapshot Commit: a58d5adb Date: 2023-01-23T09:37:23Z
rm -rf ~/Library/Arduino15
rm -rf ~/Documents/Arduino/libraries
./arduino-cli lib list -b arduino:samd:arduino_zero_edbg --format json
{
  "error": "Error listing Libraries: Unknown FQBN: platform arduino:samd is not installed"
}
rm -rf ~/Library/Arduino15
rm -rf ~/Documents/Arduino/libraries
./arduino-cli board details -b arduino:samd:arduino_zero_edbg --format json
{
  "error": "Error getting board details: Unknown FQBN: platform arduino:samd is not installed"
}

When using the gRPC APIs, the libraries and platform index must be updated before the InitRequest. This is precisely what IDE2 does here. The CLI version is here. Otherwise, the core client is not functional. Steps with grpcurl:

grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create
{
  "instance": {
    "id": 1
  }
}
grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.UpdateIndex
{
  "downloadProgress": {
    "start": {
      "url": "https://downloads.arduino.cc/packages/package_index.tar.bz2",
      "label": "Downloading index: package_index.tar.bz2"
    }
  }
}
{
  "downloadProgress": {
    "update": {
      "downloaded": "45861",
      "totalSize": "45861"
    }
  }
}
{
  "downloadProgress": {
    "end": {
      "success": true
    }
  }
}
grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.UpdateLibrariesIndex
{
  "downloadProgress": {
    "start": {
      "url": "https://downloads.arduino.cc/libraries/library_index.tar.bz2",
      "label": "Downloading index: library_index.tar.bz2"
    }
  }
}
{
  "downloadProgress": {
    "update": {
      "downloaded": "1678461",
      "totalSize": "2357079"
    }
  }
}
{
  "downloadProgress": {
    "update": {
      "downloaded": "2357079",
      "totalSize": "2357079"
    }
  }
}
{
  "downloadProgress": {
    "end": {
      "success": true
    }
  }
}
{
  
}
grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init
{
  "initProgress": {
    "taskProgress": {
      "name": "Downloading missing tool builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "start": {
        "url": "https://downloads.arduino.cc/discovery/mdns-discovery/mdns-discovery_v1.0.6_macOS_64bit.tar.gz",
        "label": "builtin:[email protected]"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "1612012",
        "totalSize": "2418658"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "2418658",
        "totalSize": "2418658"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "end": {
        "success": true
      }
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Installing builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "message": "builtin:[email protected] installed",
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Downloading missing tool builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "start": {
        "url": "https://downloads.arduino.cc/monitor/serial-monitor/serial-monitor_v0.12.0_macOS_64bit.tar.gz",
        "label": "builtin:[email protected]"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "1321196",
        "totalSize": "1881420"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "1881420",
        "totalSize": "1881420"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "end": {
        "success": true
      }
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Installing builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "message": "builtin:[email protected] installed",
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Downloading missing tool builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "start": {
        "url": "https://downloads.arduino.cc/tools/ctags-5.8-arduino11-pm-x86_64-apple-darwin.zip",
        "label": "builtin:[email protected]"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "118296",
        "totalSize": "118296"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "end": {
        "success": true
      }
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Installing builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "message": "builtin:[email protected] installed",
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Downloading missing tool builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "start": {
        "url": "https://downloads.arduino.cc/discovery/serial-discovery/serial-discovery_v1.3.3_macOS_64bit.tar.gz",
        "label": "builtin:[email protected]"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "1182856",
        "totalSize": "1699756"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "update": {
        "downloaded": "1699756",
        "totalSize": "1699756"
      }
    }
  }
}
{
  "initProgress": {
    "downloadProgress": {
      "end": {
        "success": true
      }
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "completed": true
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "name": "Installing builtin:[email protected]"
    }
  }
}
{
  "initProgress": {
    "taskProgress": {
      "message": "builtin:[email protected] installed",
      "completed": true
    }
  }
}
grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "fqbn": "arduino:samd:arduino_zero_edbg"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryList
ERROR:
  Code: NotFound
  Message: Unknown FQBN: platform arduino:samd is not installed
grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "fqbn": "arduino:samd:arduino_zero_edbg"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.BoardDetails
ERROR:
  Code: NotFound
  Message: Unknown FQBN: platform arduino:samd is not installed

I also verified the behavior in IDE2.

  • Arduino SAMD Boards (32-bits ARM Cortex-M0+) [v 1.8.13] is installed,
  • Select the Arduino Zero (Programming Port),
  • Quit IDE2,
  • Delete directories.data and directoties.user/libraries,
  • Start IDE2

The caught exceptions on the IDE2 side do not contain this unknown error message anymore. Errors were:

{"code":9,"details":"Platform 'arduino:samd' not found: platform arduino:samd is not installed","metadata":{"content-type":["application/grpc"]}}
{"code":5,"details":"Unknown FQBN: platform arduino:samd is not installed","metadata":{"content-type":["application/grpc"]}}

The (gRPC) commands where

  • lib list -b
  • board details -b
  • (and getting the user fields)

  • I do not know why the responses are not in JSON.
  • I do not know why there is an empty object ({}) during the update progress.
  • The error message in terminal should use lower case letters: "error": "Error listing Libraries: Unknown FQBN: platform arduino:samd is not installed" should be "error": "Error listing libraries: Unknown FQBN: platform arduino:samd is not installed"

Feel free to close it.

@kittaakos kittaakos removed their assignment Jan 23, 2023
@Bikappa
Copy link
Contributor

Bikappa commented Jan 23, 2023

@kittaakos regarding the error formatting, that comes from gprcurl. There is a dedicated -format-error option
Try:

grpcurl \
 -plaintext \
 -import-path ./rpc \
 -proto cc/arduino/cli/commands/v1/commands.proto \
 -d '{"instance": {"id": 1}, "fqbn": "arduino:samd:arduino_zero_edbg"}' \
 -format-error \
 127.0.0.1:50051 \
 cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryList

I'll create an issue for each of the other two points

@Bikappa Bikappa closed this as completed Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

5 participants