2020-12-27 04:07

On Windows: `is not on GOPATH` error when running counterfeiter

We invoked scripts/test.sh on a Windows 10 64-bit machine.


Generating fakes used by tests...

Path 'C:\Users\saint\go\src\github.com\maxbrunsfeld\counterfeiter\arguments' is not on GOPATH
Path 'C:\Users\saint\AppData\Local\Temp\symlinked_fixtures' is not on GOPATH
exit status 1


echo %GOPATH%

We believe that error is triggered on this line, which mistakenly splits the GOPATH on :, not realizing that in Windows, the : is part of the path (e.g C:\) and not necessarily a separator.

We are using go 1.8:

go version
go version go1.8 windows/amd64


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39946355 tomorrow-77 4月前

    It looks like this specific problem can be solved by splitting on os.PathListSeparator instead of on ':'.

    点赞 评论 复制链接分享
  • weixin_39765057 weixin_39765057 4月前

    It warms my heart that people using windows to write golang want to use counterfeiter. Thanks for taking the time to write up this beautiful description, and finding the source of the problem -- I really appreciate it.

    I applied the fix you suggested in 7f6ceee8bbe9189968c960e3593724a953b39151. Unfortunately I don't have access to a windows machine right now - any chance you'd be willing to check and see if the tests run (and pass ???) on Windows ?

    点赞 评论 复制链接分享
  • weixin_39946355 tomorrow-77 4月前

    Thanks Tim. You're fast! I'm swamped this week, but we'll try again this Saturday, and see how much further we get.

    Thanks again!

    点赞 评论 复制链接分享
  • weixin_40002692 weixin_40002692 4月前

    Hello, When I tried to use it, I came to the following error: format.Node internal error (5:2: invalid import path: "github.com\SAP\cf-mta-plugin\clients\restclient") In my code, there is no import path with the following signature(\).

    点赞 评论 复制链接分享
  • weixin_39765057 weixin_39765057 4月前

    Very Interesting. I don't think I'll be able to debug that very well, since that sounds really specific to your project. If you think you can create a reproducible test case for that, I'd be more than happy to either contribute a fix, or help you in submitting a PR and getting it merged in a timely fashion.

    I'm also not entirely convinced that is related to this issue. Were you trying to run ./scripts/test.sh on a windows machine ? Could you walk me through some of the steps you took that resulted in that error being printed ?

    点赞 评论 复制链接分享
  • weixin_39765057 weixin_39765057 4月前

    It looks like I was mistaken before. The error encountered is actually valid - there is some more discussion over in issue https://github.com/maxbrunsfeld/counterfeiter/issues/79.

    I believe this to be fixed on master - at least, I can no longer reproduce this in a windows vm I'm using. Going forward, I'm going to invest a bit this week in setting up CI for windows so that these issues are discovered automatically and not by the community. 😬

    For now, I'd like to close this issue out, since I believe the original issue to be resolved. Please re-open this issue if I'm in error.

    点赞 评论 复制链接分享