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

macOS: Unable to build using Go Modules #832

Closed
1 of 5 tasks
paulquerna-okta opened this issue Feb 6, 2020 · 5 comments
Closed
1 of 5 tasks

macOS: Unable to build using Go Modules #832

paulquerna-okta opened this issue Feb 6, 2020 · 5 comments

Comments

@paulquerna-okta
Copy link

Describe the bug

  • Restored temperature info for macOS #800
  • This PR added host/include/smc.h and host/include/smc.c. These files are in the include sub-directory. This directory includes no go files, so Go modules does not include them when go mod vendor is used. Either the h & c files should be moved into the host directory, or a dummy go file should be added to include

To Reproduce
Go mod vendor gopsutil, then try to build:

# github.com/shirou/gopsutil/host
vendor/github.com/shirou/gopsutil/host/host_darwin_cgo.go:9:11: fatal error: 'include/smc.c' file not found
 #include "include/smc.c"
          ^~~~~~~~~~~~~~~
1 error generated.

Environment (please complete the following information):

  • Windows: [paste the result of ver]
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
  • Mac OS: [paste the result of sw_vers and uname -a
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]
@jetgeng
Copy link

jetgeng commented Mar 10, 2020

i meet the same issue.
sw_vers out is:

ProductName:	Mac OS X
ProductVersion:	10.15.3
BuildVersion:	19D76

uname -a is:

Darwin Gengs-MBP.geng 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64

@axetroy
Copy link

axetroy commented May 11, 2020

Is there any solution for this now?

@mafredri
Copy link

@axetroy no good solution. But as a work-around you can manually copy the missing source/header files to your vendor folder (in the appropriate directory) and commit them. Note that go mod will get rid of them the next time it's run, so care must be taken.

The solution is to either add dummy .go files to the directories so that they will be considered as Go modules or to move them up a directory so they are accompanied by Go files.

@axetroy
Copy link

axetroy commented May 12, 2020

@mafredri Thx.
if this is a solution. why not send a PR and create an empty go file in the folder.

This issue should have stumped too many people

@Lomanic
Copy link
Collaborator

Lomanic commented May 13, 2020

Weeks or months ago I tried to rename include/smc.{c,h} to host_darwin.{c,h}, as in the disk package, didn't commit this work anywhere unfortunately as this was not compiling anymore or (as I better remember it) had build warnings that I didn't understand how to remove.

Will try the empty .go file workaround, to satisfy this (once again) broken go-mod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants