diff --git a/internal/core/target.go b/internal/core/target.go index 0ecc8b744..2a19b6aef 100644 --- a/internal/core/target.go +++ b/internal/core/target.go @@ -609,6 +609,13 @@ func WithProject(p *Project) TargetOption { } } +func WithTargetProjectRef(p *vagrant_plugin_sdk.Ref_Project) TargetOption { + return func(t *Target) (err error) { + t.target.Project = p + return + } +} + // Set a vagrantfile instance on target func WithTargetVagrantfile(v *Vagrantfile) TargetOption { return func(t *Target) (err error) { diff --git a/internal/core/vagrantfile.go b/internal/core/vagrantfile.go index fd786155c..5812feaf1 100644 --- a/internal/core/vagrantfile.go +++ b/internal/core/vagrantfile.go @@ -544,12 +544,15 @@ func (v *Vagrantfile) TargetConfig( if err != nil { // If we failed to get the subvm value, then we want to // just load the target directly so it can generate - v.logger.Warn("failed to get subvm", + v.logger.Warn("failed to get target", "name", name, "error", err, ) - t, err := v.factory.NewTarget(WithTargetName(name)) + t, err := v.factory.NewTarget( + WithTargetName(name), + WithTargetProjectRef(v.targetSource), + ) if err != nil { if status.Code(err) != codes.NotFound { return nil, err