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

Cannot properly build a simple sqlite application #1279

Open
IceBjerg opened this issue Oct 1, 2024 · 9 comments
Open

Cannot properly build a simple sqlite application #1279

IceBjerg opened this issue Oct 1, 2024 · 9 comments

Comments

@IceBjerg
Copy link

IceBjerg commented Oct 1, 2024

Hey everyone!

I must first state that I have never used this package before, but I had some experience with SQLite in other languages.

I am working on my MacOS (Sequoia - M3 Pro), using VsCode. Everything is up to date, always.

I wrote my very simple code:

package main

import (
	"log"

	_ "github.com/mattn/go-sqlite3"
)

func main() {
	log.Println("Hello, World!")
}

I am unable to debug my app in VsCode with the following lauch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "go",
            "name": "Start hello",
            "request": "launch",
            "mode": "auto",
            "cwd": "${workspaceFolder}",
            "program": "${workspaceFolder}/cmd/hello"
        }
    ]
}

I went and tried to debug manually, but then I had issues when trying to create an executable from it 😢

I am able to run this code with the go run ./cmd/hello command, however, I have difficulties when I try to create executable from it. I tried the following commands:

go build ./cmd/hello
CGO_ENABLED=1 go build ./cmd/hello
CGO_ENABLED=1 go build -tags "darwin arm64"  ./cmd/hello
CGO_ENABLED=1 go build -tags "darwin arm64 libsqlite3"  ./cmd/hello

None of that seems to result an executable that works.
If I try to run the executable from the vs-code integrated command line, the executable hangs, won't respond to ctrl+c, in separate terminals, the executable crashes.
Crash report attached.

I think i will have other issues once I need to dockerize my app, but that's for another day I think (cross platform builds for amd64/arm64 linux).

Do you have any good tips on this?
crashreport.txt

@rittneje
Copy link
Collaborator

rittneje commented Oct 1, 2024

What version of Go are you using? What version of this library are you using? What version of which C compiler are you using?

Are you saying that go build itself hangs, or the binary that it produces hangs?

@IceBjerg
Copy link
Author

IceBjerg commented Oct 1, 2024

Versions:

go version go1.22.5 darwin/arm64
github.com/mattn/go-sqlite3 v1.14.23

gcc -v                                                                                                                                                                      668ms 
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The produced binary hangs when trying to start it.

@rittneje
Copy link
Collaborator

rittneje commented Oct 3, 2024

Your crash report suggests it is getting killed because the code was not signed. That seems like a macos configuration issue of some kind?

@vilelamarcospaulo
Copy link

+1
I'm having exactly same issue, also on MacOS, did you was able to work around this @IceBjerg

@IceBjerg
Copy link
Author

IceBjerg commented Oct 6, 2024

No workaround unfortunately.

@IceBjerg
Copy link
Author

IceBjerg commented Oct 6, 2024

And I am also being able to build the app without the import being in it, so I don't think it's MacOS configuration issue.

@el2e10
Copy link

el2e10 commented Oct 6, 2024

I encountered a similar issue and resolved it temporarily by manually code signing with codesign --sign - ./main. However, I have to repeat this process every time I build, which doesn't seem like a proper solution.

@stephen
Copy link

stephen commented Oct 6, 2024

I had this same problem (specifically, binaries where I had included go-sqlite3 were being killed for codesigning reason). Doing things like clearing the go module and build cache did not help.

I ended up resolving it by uninstalling and reinstalling go from brew (brew uninstall go and brew install go).

That's an unfortunately superstitious thing to have to do, but I haven't had this since. Given what feels like a recent spike in these reports for mac users here, I wonder if there's something weird that happened to brew installs of go and clang interacting with each other.

@jaytula
Copy link

jaytula commented Oct 6, 2024

I recently updated to Mac OS 15.0.1 Sequoia and started experience this issue as well. Running codesign --sign - ./main does make it run. Doing go run main.go also works.

I did not install go from homebrew but instead manually installed it in /usr/local/go.

Switching to using Homebrew go resolved the issue.

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