Open m1ker1n opened 1 year ago
i uninstall the Go install, and use only the snapd one, and worked like a charm
Was having the same issue. Installed homebrew for linux, then ran brew install sqlc
. Now the sqlc generate
works fine.
@m1ker1n Can you give us a bit more information about the Go installation you're using? I'm confused because go env
claims that CGO_ENABLED is set to true.
Same error here using windows WSL2 ubuntu 22.04 go version go1.20.5 linux/amd64
same issue WSL ubuntu 22.04 go version 1.20.6 linux/amd64 go install .../sqlc
my go env VGO_ENABLED=1 but it still keeps giving the same error that I should enable CGO_ENABLED flag
anyone found a workaround for this?
For anyone around here using WSL. I tried the command with sudo
one day and it started working out of nowhere🤦♂️. might be as simple as that, try it.
Switch to docker version 🙌. Easy
Yeah, for anyone encountering this issue, instead of running go install, just download the binary directly. Works for me
I encountered this issue on WSL and ChromeOS linux environment. the issue occurred when CGO_ENABLED was 0 when I installed sqlc and turning it on afterwards didn't help.
I was able to reproduce it here are some logs:
$ go env -w CGO_ENABLED=0
$ go env CGO_ENABLED
0
$ go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
$ go env -w CGO_ENABLED=1
$ sqlc generate
# package database
sql/schema/001_users.sql:1:1: the PostgreSQL engine requires cgo. Please set CGO_ENABLED=1.
sql/schema/002_users_apiKeys.sql:1:1: the PostgreSQL engine requires cgo. Please set CGO_ENABLED=1.
$ go env CGO_ENABLED
1
$ rm ~/go/bin/sqlc
$ go env -w CGO_ENABLED=1
$ go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
# github.com/sqlc-dev/sqlc/cmd/sqlc
/usr/bin/ld: warning: x86_64.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
$ sqlc generate
$ go env CGO_ENABLED
1
I also installed couple of libraries like build-essential and libc-dev before I recreated the issue not sure if it made a difference.
It's simple to fix, first you enable CGO
go env -w CGO_ENABLED=1
then you install gcc
sudo apt install build-essential
last you install sqlc again
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
/This problem will occur if you use go install to download. I uninstalled the original one and installed it using brew and it was no problem.
Version
1.17.2
What happened?
sqlc was installed by this:
Used
As result got messages that I should set CGO_ENABLED=1.
Expected to generate go code.
Relevant log output
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go