Describe the problem
Arduino Lint leverages some of the capabilities implemented in the Arduino CLI tool, via its github.com/arduino/arduino-cli Go module dependency.
Sketches may contain a sketch project file. Arduino CLI parses the content of the file when processing the sketch content.
The sketch project file may contain build profiles, which define the dependencies of the sketch.
Support for specifying dependencies on local libraries was recently added to Arduino CLI (arduino/arduino-cli#2930).
Use of the capabilities of Arduino CLI by other Go applications via the github.com/arduino/arduino-cli Go module was explicitly supported at the time Arduino Lint was written. However, it was later decided that maintaining a vast public API was simply not feasible. For this reason, almost the entire API of the Arduino CLI was made internal; only for use within the Arduino CLI application itself. This makes it impossible to update Arduino Lint's github.com/arduino/arduino-cli Go module dependency past the point when that change was made. So Arduino Lint is stuck using the outdated version arduino/arduino-cli@1f8d0f6c0dd3.
When the local library dependency feature of the build profiles system is used, the libraries sequence has a mapping type. Since prior to the introduction of the feature, the elements could only have a string type, older versions of Arduino CLI such as the one used by Arduino Lint do not have the ability to parse build profiles that contain local library dependencies.
🐛 Arduino Lint panics when linting a sketch that contains a build profile with a local library dependency.
To reproduce
- Click the following link to download a demonstration sketch:
FooSketch.zip
- Wait for the download to finish.
- Extract the downloaded archive.
- Run Arduino Lint in the extracted folder.
ⓘ It is not necessary to pass any flags or arguments, just run the base arduino-lint command.
🐛 Arduino Lint panics:
$ arduino-lint
Linting sketch in E:\FooSketch
panic: profiles parsing err: yaml: unmarshal errors:
line 5: cannot unmarshal !!map into string
goroutine 1 [running]:
github.com/arduino/arduino-cli/arduino/sketch.(*projectRaw).getProfiles(0xc00015c000)
C:/Users/per/go/pkg/mod/github.com/arduino/arduino-cli@v0.35.4-0.20241001142927-1f8d0f6c0dd3/arduino/sketch/profiles.go:84 +0x1fb
github.com/arduino/arduino-cli/arduino/sketch.LoadProjectFile(0xc00013e8c0?)
C:/Users/per/go/pkg/mod/github.com/arduino/arduino-cli@v0.35.4-0.20241001142927-1f8d0f6c0dd3/arduino/sketch/profiles.go:265 +0xb6
github.com/arduino/arduino-cli/arduino/sketch.New(0x2?)
C:/Users/per/go/pkg/mod/github.com/arduino/arduino-cli@v0.35.4-0.20241001142927-1f8d0f6c0dd3/arduino/sketch/sketch.go:90 +0x5a5
github.com/arduino/arduino-lint/internal/project/projectdata.InitializeForSketch(...)
E:/git/arduino/arduino-lint/internal/project/projectdata/sketch.go:26
github.com/arduino/arduino-lint/internal/project/projectdata.Initialize({0xc000118070?, 0x1?, 0xc000239a90?})
E:/git/arduino/arduino-lint/internal/project/projectdata/projectdata.go:37 +0x6f
github.com/arduino/arduino-lint/internal/rule.Runner({0xc000118070?, 0x0?, 0x0?})
E:/git/arduino/arduino-lint/internal/rule/rule.go:37 +0xcb
github.com/arduino/arduino-lint/internal/command.ArduinoLint(0xc00011e100?, {0x0, 0x0, 0x0})
E:/git/arduino/arduino-lint/internal/command/command.go:77 +0x3c5
github.com/spf13/cobra.(*Command).execute(0xc000193508, {0xc0000520c0, 0x0, 0x0})
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0xc000193508)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f
github.com/spf13/cobra.(*Command).Execute(0x0?)
C:/Users/per/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071 +0x13
main.main()
E:/git/arduino/arduino-lint/main.go:33 +0x18
Expected behavior
Linting passes for all sketches that contain a valid sketch project file.
In cases where there is a problem with a sketch, linting is always completed, with the rule violations clearly communicated in the standard manner. Panics should only ever occur when "impossible" conditions are encountered (i.e., a bug in Arduino Lint or its dependencies).
Arduino Lint version
9115109
Operating system
Operating system version
Additional context
Originally reported at arduino-libraries/Arduino_UnifiedStorage#61 (comment).
Related
Workaround
Remove the sketch project file, or comment out the problematic build profile content, before linting.
Issue checklist
Describe the problem
Arduino Lint leverages some of the capabilities implemented in the Arduino CLI tool, via its
github.com/arduino/arduino-cliGo module dependency.Sketches may contain a sketch project file. Arduino CLI parses the content of the file when processing the sketch content.
The sketch project file may contain build profiles, which define the dependencies of the sketch.
Support for specifying dependencies on local libraries was recently added to Arduino CLI (arduino/arduino-cli#2930).
Use of the capabilities of Arduino CLI by other Go applications via the
github.com/arduino/arduino-cliGo module was explicitly supported at the time Arduino Lint was written. However, it was later decided that maintaining a vast public API was simply not feasible. For this reason, almost the entire API of the Arduino CLI was made internal; only for use within the Arduino CLI application itself. This makes it impossible to update Arduino Lint'sgit.832008.xyz/arduino/arduino-cliGo module dependency past the point when that change was made. So Arduino Lint is stuck using the outdated version arduino/arduino-cli@1f8d0f6c0dd3.When the local library dependency feature of the build profiles system is used, the
librariessequence has a mapping type. Since prior to the introduction of the feature, the elements could only have a string type, older versions of Arduino CLI such as the one used by Arduino Lint do not have the ability to parse build profiles that contain local library dependencies.🐛 Arduino Lint panics when linting a sketch that contains a build profile with a local library dependency.
To reproduce
FooSketch.zip
ⓘ It is not necessary to pass any flags or arguments, just run the base
arduino-lintcommand.🐛 Arduino Lint panics:
Expected behavior
Linting passes for all sketches that contain a valid sketch project file.
In cases where there is a problem with a sketch, linting is always completed, with the rule violations clearly communicated in the standard manner. Panics should only ever occur when "impossible" conditions are encountered (i.e., a bug in Arduino Lint or its dependencies).
Arduino Lint version
9115109
Operating system
Operating system version
Additional context
Originally reported at arduino-libraries/Arduino_UnifiedStorage#61 (comment).
Related
Workaround
Remove the sketch project file, or comment out the problematic build profile content, before linting.
Issue checklist