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

Install Fails #6

Closed
brandonkal opened this issue Nov 27, 2019 · 19 comments
Closed

Install Fails #6

brandonkal opened this issue Nov 27, 2019 · 19 comments

Comments

@brandonkal
Copy link

Unable to install using go get. It appears there is a dependency issue.

~/.config/lf  brew install libmagic
==> Downloading https://homebrew.bintray.com/bottles/libmagic-5.37.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/14/14eb5417f36b7ae1813a290c6004c880bd2c50498bc470a48dd9fb8cb489aa4e?__gda__=exp=1574840839~hmac=ea3c38b75d874c38c4341e6
######################################################################## 100.0%
==> Pouring libmagic-5.37.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/libmagic/5.37: 315 files, 6.7MB
~/.config/lf  go get -u github.com/doronbehar/pistol/cmd/pistol
package github.com/pierrec/lz4/v3: cannot find package "github.com/pierrec/lz4/v3" in any of:
	/usr/local/Cellar/go/1.13.4/libexec/src/github.com/pierrec/lz4/v3 (from $GOROOT)
	/Users/brandon/go/src/github.com/pierrec/lz4/v3 (from $GOPATH)
@doronbehar
Copy link
Owner

Thanks for reporting this. Could you locate the header files of libmagic as installed by brew? It should be something like /usr/local/Cellar/libmagic/5.37/include. After locating the include path, could you try running the following:

CGO_CFLAGS="-I/usr/local/Cellar/libmagic/5.37/include" go get -u github.com/doronbehar/pistol/cmd/pistol

@asmarcz
Copy link

asmarcz commented Dec 5, 2019

The same issue here running Ubuntu 18.04.

Ran sudo apt install libmagic-dev then go get -u github.com/doronbehar/pistol/cmd/pistol, same error.

I was able to locate only the .so files.

asmar:/usr/lib/x86_64-linux-gnu$ ll libmagic.*
.rw-r--r-- 261k root root 29 říj 17:50 libmagic.a
lrwxrwxrwx   17 root root 29 říj 17:50 libmagic.so -> libmagic.so.1.0.0
lrwxrwxrwx   17 root root 29 říj 17:50 libmagic.so.1 -> libmagic.so.1.0.0
.rw-r--r-- 137k root root 29 říj 17:50 libmagic.so.1.0.0

@doronbehar
Copy link
Owner

@asmarcz Could you use apt-file or dpkg to search for the package that will provide magic.h? It seems libmagic-dev should provide /usr/include/magic.h, see this...

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

@doronbehar I'm sorry, I didn't know of such possibility.

I located the file

asmar:~$ dpkg -S magic.h
linux-headers-4.15.0-70-generic: /usr/src/linux-headers-4.15.0-70-generic/include/config/fb/neomagic.h
linux-libc-dev:amd64: /usr/include/linux/magic.h
linux-headers-4.15.0-70: /usr/src/linux-headers-4.15.0-70/include/linux/vermagic.h
linux-headers-4.15.0-72-generic: /usr/src/linux-headers-4.15.0-72-generic/include/config/fb/neomagic.h
linux-headers-4.15.0-72: /usr/src/linux-headers-4.15.0-72/include/uapi/linux/magic.h
linux-headers-4.15.0-72: /usr/src/linux-headers-4.15.0-72/include/video/neomagic.h
linux-headers-4.15.0-70: /usr/src/linux-headers-4.15.0-70/include/video/neomagic.h
linux-headers-4.15.0-36: /usr/src/linux-headers-4.15.0-36/include/linux/vermagic.h
linux-headers-4.15.0-36-generic: /usr/src/linux-headers-4.15.0-36-generic/include/config/fb/neomagic.h
linux-headers-4.15.0-69: /usr/src/linux-headers-4.15.0-69/include/linux/vermagic.h
linux-headers-4.15.0-69-generic: /usr/src/linux-headers-4.15.0-69-generic/include/config/fb/neomagic.h
linux-headers-4.15.0-70: /usr/src/linux-headers-4.15.0-70/include/uapi/linux/magic.h
linux-headers-4.15.0-72: /usr/src/linux-headers-4.15.0-72/include/linux/vermagic.h
linux-headers-4.15.0-36: /usr/src/linux-headers-4.15.0-36/include/video/neomagic.h
linux-headers-4.15.0-36: /usr/src/linux-headers-4.15.0-36/include/uapi/linux/magic.h
linux-headers-4.15.0-69: /usr/src/linux-headers-4.15.0-69/include/uapi/linux/magic.h
libmagic-dev:amd64: /usr/include/magic.h
linux-headers-4.15.0-69: /usr/src/linux-headers-4.15.0-69/include/video/neomagic.h

Then I tried to run the command again with substituted path but it gave the same error.

asmar:~$ CGO_CFLAGS="-I/usr/include/magic.h" go get -u github.com/doronbehar/pistol/cmd/pistol
package github.com/pierrec/lz4/v3: cannot find package "github.com/pierrec/lz4/v3" in any of:
	/usr/local/go/src/github.com/pierrec/lz4/v3 (from $GOROOT)
	/home/asmar/go/src/github.com/pierrec/lz4/v3 (from $GOPATH)

@doronbehar
Copy link
Owner

Boy, I haven't noticed this has nothing to do with libmagic... both your and @brandonkal 's installation should be fine without the need to modify CGO_CFLAGS during build. lz4 is a dependency of archiver - meaning that something is wrong with the way it imports it.

I've updated the repo with a small dependencies updates. Please try again now and if the same error persists, I'll talk with the archiver guys.

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

Still doesn't work. Same error. Tried asmar:~$ sudo rm -r go/src/ before running still not working.

@doronbehar
Copy link
Owner

Funny... could you try cloning the repo and cd to cmd/pistol inside the repo and run go build or go install?

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

Doesn't seem to contain error.

asmar:~/projects/pistol/cmd/pistol$ go build
go: downloading github.com/adrg/xdg v0.0.0-20190319220657-88e5137d2444
go: downloading github.com/galdor/go-cmdline v1.1.0
go: downloading github.com/sirupsen/logrus v1.4.2
go: downloading github.com/rakyll/magicmime v0.1.0
go: downloading github.com/dustin/go-humanize v1.0.0
go: downloading github.com/alecthomas/chroma v0.6.3
go: downloading github.com/mholt/archiver v0.0.0-20190623220050-33320f6f7306
go: extracting github.com/sirupsen/logrus v1.4.2
go: downloading golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e
go: extracting github.com/adrg/xdg v0.0.0-20190319220657-88e5137d2444
go: extracting github.com/dustin/go-humanize v1.0.0
go: extracting github.com/galdor/go-cmdline v1.1.0
go: extracting github.com/mholt/archiver v0.0.0-20190623220050-33320f6f7306
go: downloading github.com/ulikunitz/xz v0.5.6
go: downloading github.com/nwaples/rardecode v1.0.0
go: downloading github.com/golang/snappy v0.0.1
go: downloading github.com/klauspost/pgzip v1.2.1
go: extracting github.com/golang/snappy v0.0.1
go: downloading github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6
go: extracting github.com/alecthomas/chroma v0.6.3
go: downloading github.com/dlclark/regexp2 v1.1.6
go: downloading github.com/klauspost/compress v1.7.1
go: downloading github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go: downloading github.com/pierrec/lz4 v2.0.5+incompatible
go: extracting github.com/klauspost/pgzip v1.2.1
go: downloading github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
go: extracting github.com/nwaples/rardecode v1.0.0
go: downloading github.com/dsnet/compress v0.0.1
go: extracting github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
go: extracting github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6
go: downloading github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721
go: extracting github.com/ulikunitz/xz v0.5.6
go: extracting github.com/dlclark/regexp2 v1.1.6
go: extracting golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e
go: extracting github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721
go: extracting github.com/pierrec/lz4 v2.0.5+incompatible
go: extracting github.com/dsnet/compress v0.0.1
go: extracting github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go: extracting github.com/rakyll/magicmime v0.1.0
go: extracting github.com/klauspost/compress v1.7.1
go: downloading github.com/klauspost/cpuid v1.2.0
go: extracting github.com/klauspost/cpuid v1.2.0
go: finding github.com/adrg/xdg v0.0.0-20190319220657-88e5137d2444
go: finding github.com/galdor/go-cmdline v1.1.0
go: finding github.com/rakyll/magicmime v0.1.0
go: finding github.com/sirupsen/logrus v1.4.2
go: finding github.com/alecthomas/chroma v0.6.3
go: finding github.com/dustin/go-humanize v1.0.0
go: finding github.com/mholt/archiver v0.0.0-20190623220050-33320f6f7306
go: finding golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e
go: finding github.com/dlclark/regexp2 v1.1.6
go: finding github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
go: finding github.com/dsnet/compress v0.0.1
go: finding github.com/golang/snappy v0.0.1
go: finding github.com/klauspost/pgzip v1.2.1
go: finding github.com/klauspost/compress v1.7.1
go: finding github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6
go: finding github.com/nwaples/rardecode v1.0.0
go: finding github.com/pierrec/lz4 v2.0.5+incompatible
go: finding github.com/ulikunitz/xz v0.5.6
go: finding github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go: finding github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721
go: finding github.com/klauspost/cpuid v1.2.0

@doronbehar
Copy link
Owner

1 more thing please @asmarcz, I'd like to know the output of go version on your machine.

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

I installed Go just yesterday (or the day before) when I tried to use pistol with lf.

asmar:~$ go version
go version go1.13.5 linux/amd64

@doronbehar
Copy link
Owner

And could you try deleting the $GOPATH/ or probably ~/go in your case and then run: go install github.com/doronbehar/pistol/cmd/pistol

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

asmar:~$ sudo rm -r go
[sudo] password for asmar: 
asmar:~$ go install github.com/doronbehar/pistol/cmd/pistol
can't load package: package github.com/doronbehar/pistol/cmd/pistol: cannot find package "github.com/doronbehar/pistol/cmd/pistol" in any of:
	/usr/local/go/src/github.com/doronbehar/pistol/cmd/pistol (from $GOROOT)
	/home/asmar/go/src/github.com/doronbehar/pistol/cmd/pistol (from $GOPATH)

@doronbehar
Copy link
Owner

Oh right, I've managed to reproduce with a modified $GOPATH on my machine. The issue is familiar with archiver - mholt/archiver#195 and there's an currently open upstream Go issue: golang/go#31529

As a workaround (I tested), Use the following command instead:

env GO111MODULE=on go get -u github.com/doronbehar/pistol/cmd/pistol

@doronbehar
Copy link
Owner

Once verified the workaround works for you as well, I'll update the readme..

@asmarcz
Copy link

asmarcz commented Dec 6, 2019

Thank you, pistol can be run now:

asmar:~/go/bin$ ./pistol --help
Usage: ./pistol OPTIONS [<file> ...]

OPTIONS

-c, --config <config>  configuration file to use (defaults to /home/asmar/.config/pistol.conf)
-h, --help             print help and exit
-v, --verbosity        increase verbosity

ARGUMENTS

file                   the file to preview

As a side note. For me with default Go settings the paths were

$GOPATH/bin/pistol
~/go/bin/pistol

as opposed to the README

$GOPATH/.bin/pistol
~/.go/bin/pistol

@rtviii
Copy link

rtviii commented Jun 5, 2023

Thanks for reporting this. Could you locate the header files of libmagic as installed by brew? It should be something like /usr/local/Cellar/libmagic/5.37/include. After locating the include path, could you try running the following:

CGO_CFLAGS="-I/usr/local/Cellar/libmagic/5.37/include" go get -u github.com/doronbehar/pistol/cmd/pistol

For those, having this issue on Mac M1 silicon:
CGO_CFLAGS="-I/opt/homebrew/Cellar/libmagic/5.44/include" go install github.com/doronbehar/pistol/cmd/pistol@latest worked for me. brew installs sutff in /opt/homebrew/Cellar just so you don't get bored on your 3k$ computer.

@kavindalj
Copy link

kavindalj commented Aug 22, 2023

I tried this on my m1 mac and didn't work for me..please anyone can help to fix this?

CGO_CFLAGS="-I/opt/homebrew/Cellar/libmagic/5.44/include/magic.h" go install github.com/doronbehar/pistol/cmd/pistol@latest
# github.com/doronbehar/magicmime
go/pkg/mod/github.com/doronbehar/[email protected]/magicmime.go:28:11: fatal error: 'magic.h' file not found
 #include <magic.h>
          ^~~~~~~~~
1 error generated.

@pawel-rh
Copy link

pawel-rh commented Jan 23, 2024

Ubuntu 23.10 user here, can't compile due to magic.h missing

$ go install github.com/doronbehar/pistol/cmd/pistol@latest
# github.com/doronbehar/magicmime
go/pkg/mod/github.com/doronbehar/[email protected]/magicmime.go:28:11: fatal error: magic.h: No such file or directory
   28 | // #include <magic.h>
      |           ^~~~~~~~~
compilation terminated.

@doronbehar
Copy link
Owner

https://github.com/doronbehar/pistol/#from-source

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

6 participants