Skip to content
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

Generation fails when referencing module that uses the replace directive #815

Open
1 of 5 tasks
jmgilman opened this issue Sep 7, 2024 · 0 comments
Open
1 of 5 tasks

Comments

@jmgilman
Copy link

jmgilman commented Sep 7, 2024

Description

When referencing a Go module that is being replaced using the replace directive in the go.mod file, mockery fails to load the package.

Mockery Version

v2.45.0

Go Version

v1.23.0

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

Start with a go.mod that uses replace:

module github.com/my/pkg/otherpkg

require (
	github.com/my/pkg/tools v0.0.0
)

replace github.com/my/pkg/tools => ../tools

go 1.23.0

And then attempt to generate mocks for interfaces in that package:

with-expecter: true
packages:
    github.com/my/pkg/tools:
        interfaces:
            Interface1:
            Interface2:

When running mockery, it will error out saying there's no module providing github.com/my/pkg/tools. However, Go itself has no issues importing the package.

Expected Behavior

Expected mockery to behave the same way as Go.

Actual Behavior

Mockery fails with:

07 Sep 24 19:07 EDT ERR encountered error when loading package error="-: no required module provides package github.com/my/pkg/tools; to add it:\n\tgo get github.com/my/pkg/tools" dry-run=false version=v2.45.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant