Skip to content

[per-OS Packages] Error if adding --platform, when excluded_platforms is defined #1373

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 1 commit into from
Aug 15, 2023
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
8 changes: 7 additions & 1 deletion internal/devconfig/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ func (pkgs *Packages) AddPlatforms(versionedname string, platforms []string) err

// Adding any platform will restrict installation to it, so
// the ExcludedPlatforms are no longer needed
pkg.ExcludedPlatforms = nil
if len(pkg.ExcludedPlatforms) > 0 {
return usererr.New(
"cannot add any platform for package %s because it already has `excluded_platforms` defined. "+
"Please delete the `excludedPlatforms` for this package from devbox.json and re-try.",
pkg.VersionedName(),
)
}

pkgs.jsonKind = jsonMap
pkg.kind = regular
Expand Down
8 changes: 8 additions & 0 deletions testscripts/add/add_platforms.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ json.superset devbox.json expected_devbox3.json
exec devbox add cowsay --exclude-platform x86_64-darwin,x86_64-linux --exclude-platform aarch64-darwin
json.superset devbox.json expected_devbox4.json

### Part 3: Ensure we error to prevent inconsistent state

! exec devbox add cowsay --platform x86_64-darwin
stderr 'Error: cannot add any platform for package cowsay@latest because it already has `excluded_platforms` defined'

! exec devbox add hello --exclude-platform x86_64-darwin
stderr 'Error: cannot exclude any platform for package hello@latest because it already has `platforms` defined'

-- devbox.json --
{
"packages": [
Expand Down