Skip to content

Package index is now downloaded automatically when is required #908

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

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions cli/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,40 @@ func getInitResponse() (*rpc.InitResp, error) {
resp.PlatformsIndexErrors = rescanResp.PlatformsIndexErrors
}

// Init() succeeded but there were errors loading platform indexes,
// let's rescan and try again
if resp.GetPlatformsIndexErrors() != nil {

// log each error
for _, err := range resp.GetPlatformsIndexErrors() {
logrus.Errorf("Error loading platform index: %v", err)
}

// update platform index
_, err := commands.UpdateIndex(context.Background(),
&rpc.UpdateIndexReq{Instance: resp.GetInstance()}, output.ProgressBar())
if err != nil {
return nil, errors.Wrap(err, "updating the core index")
}

// rescan
rescanResp, err := commands.Rescan(resp.GetInstance().GetId())
if err != nil {
return nil, errors.Wrap(err, "during rescan")
}

// errors persist
if rescanResp.GetPlatformsIndexErrors() != nil {
for _, err := range rescanResp.GetPlatformsIndexErrors() {
logrus.Errorf("Still errors after rescan: %v", err)
}
}

// succeeded, copy over PlatformsIndexErrors in case errors occurred
// during rescan
resp.PlatformsIndexErrors = rescanResp.PlatformsIndexErrors
}

return resp, nil
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,5 +449,5 @@ def test_board_details_no_flags(run_command):
assert result.ok
result = run_command("board details")
assert not result.ok
assert "Error getting board details: parsing fqbn: invalid fqbn:"
assert "Error getting board details: parsing fqbn: invalid fqbn:" in result.stderr
assert result.stdout == ""
8 changes: 8 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def test_core_updateindex_invalid_url(run_command):
assert result.failed


def test_core_install_without_updateindex(run_command):
# Missing "core update-index"
# Download samd core pinned to 1.8.6
result = run_command("core install arduino:[email protected]")
assert result.ok
assert "Updating index: package_index.json downloaded" in result.stdout


@pytest.mark.skipif(
platform.system() == "Windows", reason="core fails with fatal error: bits/c++config.h: No such file or directory",
)
Expand Down