diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 084b2814687..0e99add55bc 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -119,12 +119,10 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream PlatformArchitecture: fqbn.PlatformArch, }) if targetPlatform == nil || pm.GetInstalledPlatformRelease(targetPlatform) == nil { - // TODO: Move this error message in `cli` module - // errorMessage := fmt.Sprintf( - // "\"%[1]s:%[2]s\" platform is not installed, please install it by running \""+ - // version.GetAppName()+" core install %[1]s:%[2]s\".", fqbn.Package, fqbn.PlatformArch) - // feedback.Error(errorMessage) - return nil, &arduino.PlatformNotFoundError{Platform: targetPlatform.String(), Cause: fmt.Errorf(tr("platform not installed"))} + return nil, &arduino.PlatformNotFoundError{ + Platform: fmt.Sprintf("%s:%s", fqbn.Package, fqbn.PlatformArch), + Cause: fmt.Errorf(tr("platform not installed")), + } } builderCtx := &types.Context{} diff --git a/test/test_compile_part_4.py b/test/test_compile_part_4.py index 7cc22813634..757095f63ba 100644 --- a/test/test_compile_part_4.py +++ b/test/test_compile_part_4.py @@ -378,3 +378,22 @@ def test_compile_without_upload_and_fqbn(run_command, data_dir): res = run_command(["compile", sketch_path]) assert res.failed assert "Error during build: Missing FQBN (Fully Qualified Board Name)" in res.stderr + + +def test_compile_non_installed_platform_with_wrong_packager_and_arch(run_command, data_dir): + assert run_command(["update"]) + + # Create a sketch + sketch_name = "SketchSimple" + sketch_path = Path(data_dir, sketch_name) + assert run_command(["sketch", "new", sketch_path]) + + # Compile with wrong packager + res = run_command(["compile", "-b", "wrong:avr:uno", sketch_path]) + assert res.failed + assert "Error during build: Platform 'wrong:avr' not found: platform not installed" in res.stderr + + # Compile with wrong arch + res = run_command(["compile", "-b", "arduino:wrong:uno", sketch_path]) + assert res.failed + assert "Error during build: Platform 'arduino:wrong' not found: platform not installed" in res.stderr