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/magicmime@v0.1.1-0.20211127135329-3de4ff29dc49/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/magicmime@v0.1.1-0.20211127135329-3de4ff29dc49/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