Description
Describe the problem
When an Arduino boards platform is installed to <directories.user>/hardware
without a version folder, Arduino CLI uses the version
property of platform.txt
to identify the platform's version.
The Arduino platform properties system allows us to reference previously defined properties within a property's definitions, and have those properties be expanded by Arduino CLI while processing the platform's configuration files.
🐛 Property reference expansion does not work in the version
property of platform.txt
. Arduino CLI panics while processing platforms installed to <directories.user>
which have references in the version
property.
To reproduce
$ arduino-cli version
arduino-cli.exe Version: git-snapshot Commit: 2dd89766 Date: 2022-08-04T04:26:26Z
$ export ARDUINO_DIRECTORIES_USER="/tmp/arduino-cli-directories-user"
$ git clone https://github.com/SpenceKonde/DxCore --depth 1 -b 1.4.10 "${ARDUINO_DIRECTORIES_USER}/hardware/DxCore-dev"
$ sed -n 12,17p "${ARDUINO_DIRECTORIES_USER}/hardware/DxCore-dev/megaavr/platform.txt"
versionnum.major=1
versionnum.minor=4
versionnum.patch=10
versionnum.postfix=
versionnum.released=1
version={versionnum.major}.{versionnum.minor}.{versionnum.patch}{versionnum.postfix}
$ arduino-cli core list
panic: no major version found
goroutine 1 [running]:
go.bug.st/relaxed-semver.MustParse(...)
C:/Users/per/go/pkg/mod/go.bug.st/relaxed-semver@v0.9.0/parser.go:18
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*PackageManager).loadPlatform(0xc0000764e0, 0xc0003a4c80, {0xc000499851, 0x0}, 0xc00006ad50)
E:/electronics/git-nobackup/arduino-cli/arduino/cores/packagemanager/loader.go:199 +0x14a5
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*PackageManager).loadPlatforms(0xc0000764e0, 0xc0003a4c80, 0xc00006abf0)
E:/electronics/git-nobackup/arduino-cli/arduino/cores/packagemanager/loader.go:166 +0x3aa
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*PackageManager).LoadHardwareFromDirectory(0xc0000764e0, 0xc00006b140)
E:/electronics/git-nobackup/arduino-cli/arduino/cores/packagemanager/loader.go:124 +0xb58
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*PackageManager).LoadHardwareFromDirectories(0xc00024d5d8, {0xc00006b150, 0x2, 0xc00024d5d8})
E:/electronics/git-nobackup/arduino-cli/arduino/cores/packagemanager/loader.go:50 +0xc9
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*PackageManager).LoadHardware(0xc0000764e0)
E:/electronics/git-nobackup/arduino-cli/arduino/cores/packagemanager/loader.go:38 +0x3f
github.com/arduino/arduino-cli/commands.Init(0xc00024dbc8, 0xc00024dc18)
E:/electronics/git-nobackup/arduino-cli/commands/instances.go:243 +0x34d
github.com/arduino/arduino-cli/cli/instance.InitWithProfile(0xc000044960, {0x0, 0x0}, 0x0)
E:/electronics/git-nobackup/arduino-cli/cli/instance/instance.go:99 +0x20b
github.com/arduino/arduino-cli/cli/instance.CreateAndInitWithProfile({0x0, 0x0}, 0x8010103)
E:/electronics/git-nobackup/arduino-cli/cli/instance/instance.go:53 +0x13f
github.com/arduino/arduino-cli/cli/instance.CreateAndInit(...)
E:/electronics/git-nobackup/arduino-cli/cli/instance/instance.go:40
github.com/arduino/arduino-cli/cli/core.runListCommand(0xc000310c80, {0x1ba1418, 0x0, 0x0})
E:/electronics/git-nobackup/arduino-cli/cli/core/list.go:52 +0x31
github.com/spf13/cobra.(*Command).execute(0xc000310c80, {0x1ba1418, 0x0, 0x0})
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc000239400)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
E:/electronics/git-nobackup/arduino-cli/main.go:31 +0x77
🐛 What should be considered a perfectly valid platform configuration causes Arduino CLI to panic.
Expected behavior
Properties are expanded in the version
property of platform.txt
just as they are in any other property.
Arduino CLI version
Operating system
Windows, Ubuntu
Operating system version
Windows 10, Ubuntu 20.04
Additional context
This approach was supported up until Arduino IDE 1.8.14, and is in use in multiple prominent Arduino boards platforms, including:
Originally reported at:
- Arduino IDE 2.0 beta MCUdude/MightyCore#215
- https://forum.arduino.cc/t/panic-no-major-version-found/876644
- 2.0: panic: no major version found SpenceKonde/ATTinyCore#703
- Check keywords.txt now spews hundreds of errors SpenceKonde/megaTinyCore#748 (comment)
- Documentation Notes - "Getting Started" SpenceKonde/megaTinyCore#701
- relocation truncated to fit: R_AVR_13_PCREL against `no symbol' SpenceKonde/megaTinyCore#575 (comment)
- v2.0.0 - can't compile for ATtiny861 with legacy pin mapping + USI on port A SpenceKonde/ATTinyCore#689
- I2C issues using ATTiny88 MH-ET board (noob) SpenceKonde/ATTinyCore#690 (comment)
- arduino 1.8.16 Attiny1607 board SpenceKonde/megaTinyCore#542 (reply in thread)
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details