arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.32k stars 373 forks source link

`core list` command gives no output when no platforms are installed #2220

Closed aliphys closed 1 year ago

aliphys commented 1 year ago

Describe the problem

I want to see the list of currently installed cores on my system. But cannot. image

To reproduce

  1. Type arduino-cli core list in the terminal.
  2. Hit Enter
  3. Nothing happens

Expected behavior

I get a list of available cores on the system

Arduino CLI version

Version: 0.33.0 Commit: ca60d4b4 Date: 2023-05-30T12:14:01Z

Operating system

Windows

Operating system version

Windows 11

Additional context

I can see a list of installable/installed cores by appending the --all argument.

PS C:\Users\Ali Jahangiri\Documents\GitHub\nicla-sense-me-fw> arduino-cli core list --all
ID                      Installed Latest    Name                                                                                 
arduino:avr                       1.8.6     Arduino AVR Boards                                                                   
arduino:mbed_edge                 4.0.2     Arduino Mbed OS Edge Boards                                                          
arduino:mbed_giga                 4.0.2     Arduino Mbed OS Giga Boards                                                       

arduino:mbed_nano                 4.0.2     Arduino Mbed OS Nano Boards                                                       

arduino:mbed_nicla                4.0.2     Arduino Mbed OS Nicla Boards                                                      

arduino:mbed_opta                 4.0.2     Arduino Mbed OS Opta Boards                                                       

arduino:mbed_portenta             4.0.2     Arduino Mbed OS Portenta Boards                                                   

arduino:mbed_rp2040               4.0.2     Arduino Mbed OS RP2040 Boards                                                     

arduino:megaavr                   1.8.8     Arduino megaAVR Boards                                                            

arduino:nrf52                     1.0.2     Arduino nRF52 Boards                                                              

arduino:sam                       1.6.12    Arduino SAM Boards (32-bits ARM Cortex-M3)                                        

arduino:samd                      1.8.13    Arduino SAMD Boards (32-bits ARM Cortex-M0+)                                      

Arrow:samd                        2.1.0     Arrow Boards                                                                      

atmel-avr-xminis:avr              0.6.0     Atmel AVR Xplained-minis                                                          

emoro:avr                         3.2.2     EMORO 2560                                                                        

industruino:samd                  1.0.1     Industruino SAMD Boards (32-bits ARM Cortex-M0+)                                  

Intel:arc32                       2.0.6     Intel Curie Boards                                                                

Intel:i586                        1.6.7+1.0 Intel i586 Boards                                                                 

Intel:i686                        1.6.7+1.0 Intel i686 Boards                                                                 

littleBits:avr                    1.0.0     littleBits Arduino AVR Modules                                                    

renesas:rl78g22_fpb               2.0.0     RL78/G22 Fast Prototyping Board                                                   

renesas:rl78g23_fpb_p64           2.0.0     RL78/G23-64p Fast Prototyping Board                                               

Microsoft:win10                   1.1.2     Windows 10 Iot Core                                                               

arduino:mbed                      3.3.0     [DEPRECATED] [DEPRECATED - Please install standalone packages] Arduino Mbed OS Boards

The arduino-cli board list correctly identities the connected board name, FQBN and the core (arduino:mbed_nicla).

PS C:\Users\Ali Jahangiri\Documents\GitHub\nicla-sense-me-fw> arduino-cli board list
Port Protocol Type              Board Name           FQBN                            Core
COM3 serial   Serial Port       Unknown
COM4 serial   Serial Port       Unknown
COM7 serial   Serial Port (USB) Arduino Nicla Vision arduino:mbed_nicla:nicla_vision arduino:mbed_nicla

Issue checklist

aliphys commented 1 year ago

This is a newly setup laptop, so there were no cores installed previously. I have not installed the Arduino 2.x IDE either. I installed the core for the Nicla Vision, which triggered the install of USB drivers as well.

PS C:\Users\Ali Jahangiri\Documents\GitHub\nicla-sense-me-fw> arduino-cli core install arduino:mbed_nicla
Downloading packages...
arduino:openocd@0.11.0-arduino2 downloaded
arduino:arm-none-eabi-gcc@7-2017q4 downloaded
arduino:bossac@1.9.1-arduino2 downloaded
arduino:dfu-util@0.10.0-arduino1 downloaded
arduino:rp2040tools@1.0.6 downloaded
arduino:mbed_nicla@4.0.2 downloaded
Installing arduino:openocd@0.11.0-arduino2...
Configuring tool....
arduino:openocd@0.11.0-arduino2 installed
Installing arduino:arm-none-eabi-gcc@7-2017q4...
Configuring tool....
arduino:arm-none-eabi-gcc@7-2017q4 installed
Installing arduino:bossac@1.9.1-arduino2...
Configuring tool....
arduino:bossac@1.9.1-arduino2 installed
Installing arduino:dfu-util@0.10.0-arduino1...
Configuring tool....
arduino:dfu-util@0.10.0-arduino1 installed
Installing arduino:rp2040tools@1.0.6...
Configuring tool....
arduino:rp2040tools@1.0.6 installed
Installing platform arduino:mbed_nicla@4.0.2...
Configuring platform....
Platform arduino:mbed_nicla@4.0.2 installed

When the arduino-cli core list command after the core is installed is run, the newly installed core is displayed.

PS C:\Users\Ali Jahangiri\Documents\GitHub\nicla-sense-me-fw> arduino-cli core list      
ID                 Installed Latest Name
arduino:mbed_nicla 4.0.2     4.0.2  Arduino Mbed OS Nicla Boards
aliphys commented 1 year ago

Possible solution: replace this line https://github.com/arduino/arduino-cli/blob/642996ffb25218e006b0cb6a793fb34d688fd8aa/commands/core/list.go#L88 With this

// Inform user if there are no installed platforms, 
if len(res) == 0 {
    return nil, fmt.Errorf("No platforms installed.")
}
return &rpc.PlatformListResponse{InstalledPlatforms: res}, nil
alessio-perugini commented 1 year ago

@aliphys :wave: Thanks for reporting this. I agree with you. When we have no installed cores it's not clear what's going on. Currently, when no cores are installed, we print only if we pass the --format json flag. (The result is an empty array []).

I wouldn't return any error on the API level, as this kind of thing should be inferred by the length of the data we receive. But your suggestion is still valid it just needs to be implemented in a different place :nerd_face:

We have two options:

  1. Print a self-explanatory message like your suggestion:

    $ arduino-cli core list
    No platforms installed.
  2. Print only the table headers:

    
    $ arduino-cli core list
    ID Installed Latest Name