Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
I am reading you code for fun
What did you expect to see?
import (
github.com/cznic/parser/yacc/parser
What did you see instead?
parser/lexer.go:95: undefined: yySymType
parser/misc.go:519: undefined: yySymType
parser/yy_parser.go:60: undefined: yySymType
parser/yy_parser.go:61: undefined: yySymType
parser/yy_parser.go:62: undefined: yySymType
What version of Go are you using (go version)?
@biolee Please run make parser first.
I was testing with AWS EC2 instance (t2.medium) and occured same error message with this PPA.
Environment:
ubuntu@ip-10-140-0-78:~$ uname -a
Linux ip-10-140-0-78 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ip-10-140-0-78:~$ echo $PATH
/usr/lib/go-1.7/bin:/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ubuntu@ip-10-140-0-78:~$ go version
go version go1.7.3 linux/amd64
ubuntu@ip-10-140-0-78:~$ echo $GOPATH
/home/ubuntu/go
ubuntu@ip-10-140-0-78:~$ ls -al $GOPATH
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 25 16:09 .
drwxr-xr-x 5 ubuntu ubuntu 4096 Feb 25 16:09 ..
Then go get -v first and then make parser:
ubuntu@ip-10-140-0-78:~$ git clone https://github.com/pingcap/tidb.git
[...]
ubuntu@ip-10-140-0-78:~$ cd tidb
ubuntu@ip-10-140-0-78:~/tidb$ go get -v
[...]
ubuntu@ip-10-140-0-78:~/tidb$ make parser
[...]
Finally, run make:
ubuntu@ip-10-140-0-78:~/tidb$ make
GOPATH=/home/ubuntu/tidb/_vendor:/home/ubuntu/go CGO_ENABLED=0 GO15VENDOREXPERIMENT="1" go build -ldflags '-X "github.com/pingcap/tidb/util/printer.TiDBBuildTS=2017-02-25 04:20:56" -X "github.com/pingcap/tidb/util/printer.TiDBGitHash=7882b66f2b1c1de7a83534b894a5b78af7543560"' -o bin/tidb-server tidb-server/main.go
# github.com/pingcap/tidb/parser
../go/src/github.com/pingcap/tidb/parser/lexer.go:95: undefined: yySymType
../go/src/github.com/pingcap/tidb/parser/misc.go:609: undefined: yySymType
../go/src/github.com/pingcap/tidb/parser/yy_parser.go:60: undefined: yySymType
../go/src/github.com/pingcap/tidb/parser/yy_parser.go:61: undefined: yySymType
../go/src/github.com/pingcap/tidb/parser/yy_parser.go:62: undefined: yySymType
Makefile:110: recipe for target 'server' failed
make: *** [server] Error 2
Someone in Twitter just noticed me that I should use go get -v github.com/pingcap/tidb and then change directory to $GOPATH/src/github.com/pingcap/tidb to compile. And it works...
It's because $HOME/tidb is not in $GOPATH. When you run 'make parser', the parser would be generated in current directory which in your case is $HOME/tidb, but this directory is not $GOPATH, and go compiler couldn't find this file.
Same qusetion
Most helpful comment
@biolee Please run
make parserfirst.