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

Support the PostgreSQL engine on Windows #282

Closed
dharmjit opened this issue Jan 20, 2020 · 25 comments
Closed

Support the PostgreSQL engine on Windows #282

dharmjit opened this issue Jan 20, 2020 · 25 comments
Labels
📚 postgresql upstream Issue is caused by a dependency

Comments

@dharmjit
Copy link

Hi, I just started exploring this project. But not able to build the project on windows. Is windows support in the road map. Thanks

@eullerpereira94
Copy link
Contributor

Can you specify the error message?

@dharmjit
Copy link
Author

I am getting below error.

github.com\lfittl\[email protected]\parser\include/port.h:17:19: fatal error: netdb.h: No such file or directory                                                                                                                                  compilation terminated.

@eullerpereira94
Copy link
Contributor

Ah, the dreaded "missing C header files" error. First, this seems like a problem within pg_query_go and the C header files available on your system. I have two recommendations for you:

  1. if you are in Windows 10, activate WSL2, and use sqlc within the Linux subsystem. Be sure to install gcc on it.
  2. Try the vendoring instructions present in the pg_query_go repo, and see if it works.

I will research a little bit more in order to see if there is some other options, but those two are the ones that were on the top of my mind.

@landbed
Copy link

landbed commented Mar 13, 2020

@kyleconroy @euller88 how about providing a binary file on every releases? user can download directly?

@kyleconroy kyleconroy added the upstream Issue is caused by a dependency label Mar 13, 2020
@kyleconroy
Copy link
Collaborator

@landbed that is already the case. You can download macOS and Linux binaries for every commit on master. Each release also has binaries.

The issue is that out PostgreSQL parser does not support Windows. Once MySQL support is complete, we'll offer a Windows version that does not support PostgreSQL.

@kyleconroy kyleconroy added the enhancement New feature or request label Mar 13, 2020
@dharmjit
Copy link
Author

Hi @kyleconroy, windows binaries then will not be useful for people using postgresql.

@766b
Copy link

766b commented Jun 19, 2020

Just FYI, you can run sqlc on Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.

@kyleconroy
Copy link
Collaborator

Initial Windows support is now live (#886).

GOOS=windows GOARCH=amd64 go build ./cmd/sqlc/

These builds have a huge limitation: the PostgreSQL engine does not work. While that's obviously not ideal, it's good for those people that only need MySQL support.

@kyleconroy kyleconroy added 📚 postgresql and removed enhancement New feature or request labels Feb 8, 2021
@kyleconroy kyleconroy changed the title Not able to build on windows Support the PostgreSQL engine on Windows Feb 8, 2021
@arif2009
Copy link

Just FYI, you can run sqlc on Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.

It's not working on WSL as well. This is my try:
2022-02-17_20h38_07

@bmerracho
Copy link

Hello any updates regarding this issue? is there a possibility for postgresql support in windows soon?

@pawlobanano
Copy link

pawlobanano commented Apr 6, 2022

Just FYI, you can run sqlc on Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.

It's not working on WSL as well. This is my try:

Fortunately it is working. There is a little hack for the lack of systemd in WSL2, but it is surmountable via commands mentioned here: microsoft/WSL#5126 (comment)
and then simple install: sudo snap install sqlc

@gafful
Copy link

gafful commented Aug 25, 2022

I ended up installing sqlc with homebrew on WSL

@NinoM4ster
Copy link

I'm sorry for being rude but how is this 3 years in and still not fixed?!

I've just started migrating a new project from GORM and this is honestly unacceptable.

The WSL workaround is not enough, I think the parser should have native Windows support.

@eullerpereira94
Copy link
Contributor

@NinoM4ster the parser is a different project that is not maintained by Kyle. You can always open an issue on the pg_query_go repository. Also, any contributions towards a parser that works on Windows would be greatly appreciated.

@NinoM4ster
Copy link

You can always open an issue on the pg_query_go repository.

This issue seems to track that already. Thanks.

@GustavoCielo
Copy link

Oh wow, tried the WSL workaround, but still didnt work, damn

@malcolmmaima
Copy link

malcolmmaima commented Jan 23, 2023

sqlc generate

Gives:

C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows

Possible solution in windows (worked for me):

docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate

@mulukenhailu
Copy link

sqlc generate

Gives:

C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows

Possible solution in windows (worked for me):

docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate

please, can you explain step by step how it worked for you on Windows?

@kokodayou2000
Copy link

sqlc generate

Gives:

C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows

Possible solution in windows (worked for me):

docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate

please, can you explain step by step how it worked for you on Windows?

sqlc generate

Gives:

C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows

Possible solution in windows (worked for me):

docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate

please, can you explain step by step how it worked for you on Windows?

I just ran into this issue as well

first use pwd command
get path
C:\Users\03062\Desktop\Code\workspace\project\golang\simplebank
second
copy the path
docker run --rm -v "C:\Users\03062\Desktop\Code\workspace\project\golang\simplebank:/src" -w /src kjconroy/sqlc generate

https://docs.sqlc.dev/en/latest/overview/install.html#docker

@robinmuhia
Copy link

Just run that command exactly as it is... do not change anything

@Tesohh
Copy link

Tesohh commented Aug 2, 2023

Just FYI, you can run sqlc on Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.

It's not working on WSL as well. This is my try:

2022-02-17_20h38_07

install sqlc through go install in wsl then try this: ~/go/bin/sqlc generate

@andrewmbenton
Copy link
Collaborator

There is an option to use sqlc with remote codegen execution, which is perhaps a suitable workaround for Windows PostgreSQL users: https://docs.sqlc.dev/en/stable/reference/changelog.html#remote-code-generation

Otherwise the best solution seems to be using a downloaded release binary with WSL.

I am closing this issue since pg_query_go likely won't be updated to support Windows, and the above workarounds are stable.

@andrewmbenton andrewmbenton closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
@Ali-Adel-Nour
Copy link

version: "2"
packages:

  • name: "db"
    path: "./db/sqlc"
    queries: "./db/query/"
    schema: "./db/migration/"
    engine: "postgresql"
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: false
    emit_exact_table_names: false

I keep getting this error
error parsing sqlc.yaml: yaml: unmarshal errors:
line 2: field packages not found in type config.Config
make: *** [Makefile:14: sqlc] Error 1

@andrewmbenton
Copy link
Collaborator

@Ali-Adel-Nour Your config structure looks like version "1" but you've specified version "2". Your config should parse if you set version: "1".

@bontusss
Copy link

I decided to use the wsl workaround but it didn't see my database. I've installed postgres on wsl but there's no way to access it on pgadmin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql upstream Issue is caused by a dependency
Projects
None yet
Development

No branches or pull requests