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 load garble export file" errors #708

Closed
vodves-vodves opened this issue Mar 29, 2023 · 10 comments · Fixed by #756
Closed

"cannot load garble export file" errors #708

vodves-vodves opened this issue Mar 29, 2023 · 10 comments · Fixed by #756

Comments

@vodves-vodves
Copy link

vodves-vodves commented Mar 29, 2023

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.9.3

Build settings:
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS windows
         GOAMD64 v1

$ go version
go version go1.20.2 windows/amd64

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\user\AppData\Local\go-build
set GOENV=C:\Users\user\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\user\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\user\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\user\Desktop\go\testdelete\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=E:\Temp\go-build2220679288=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import "fmt"

func main() {
	fmt.Println("hi")
}
garble build main.go

What did you expect to see?

binary

What did you see instead?

It happens in any project

# command-line-arguments
cannot load garble export file for errors: open C:\Users\user\AppData\Local\go-build\38\380046a7211e0f560886ad287756ba1ee3c0ca3422a90c549f9c776b1b9f0908-garble-0k0idgQRqCRMUJi0YOd4-d: The system cannot find the file specified.      
exit status 1
@vodves-vodves vodves-vodves changed the title garble build fil garble build fail Mar 29, 2023
@scirpter
Copy link

scirpter commented Apr 2, 2023

Started noticing the same thing for certain projects, but only when appending the -literals and -tiny flags..

@scirpter
Copy link

scirpter commented Apr 2, 2023

Try out this:

go clean -cache

This should fix the issue.

@mvdan
Copy link
Member

mvdan commented Apr 2, 2023

I had a hunch that this kind of error could happen, I just never saw it in practice. Thanks for reporting; will look into a fix. @scirpter is right that go clean -cache can be a temporary workaround for this. garble build -a can also be a temporary workaround, and it's probably slightly better as it doesn't remove your entire build cache.

@jimmywhite999
Copy link

I had a hunch that this kind of error could happen, I just never saw it in practice. Thanks for reporting; will look into a fix. @scirpter is right that go clean -cache can be a temporary workaround for this. garble build -a can also be a temporary workaround, and it's probably slightly better as it doesn't remove your entire build cache.

neither of these work around work for me any other suggestions

mvdan added a commit to mvdan/garble-fork that referenced this issue Apr 30, 2023
The test passes, because it expects garble to fail the same way that
users are seeing in practice.

For burrowers#708.
lu4p pushed a commit that referenced this issue May 1, 2023
The test passes, because it expects garble to fail the same way that
users are seeing in practice.

For #708.
@vodves-vodves

This comment was marked as off-topic.

@scirpter

This comment was marked as off-topic.

@vodves-vodves

This comment was marked as off-topic.

@mvdan

This comment was marked as off-topic.

mvdan added a commit to mvdan/garble-fork that referenced this issue May 20, 2023
We first called the typecheck method, which starts filling cachedOutput
with information from the current package, and later we would load the
gob files for all dependencies via loadCachedOutputs.

This was a bit confusing; instead, load the cached gob files first,
and then do all the operations which fill information for curPkg.

Similarly, we were waiting until the very end of transformCompile to
write curPkg's cachedOutput gob file to the disk cache.
We can write the file at an earlier point, before we have obfuscated and
re-printed all Go files for the current package.
We can also write the file before other work like processImportCfg.

None of these changes should affect garble's behavior,
but they will make the cache redesign for burrowers#708 easier.
mvdan added a commit that referenced this issue May 20, 2023
We first called the typecheck method, which starts filling cachedOutput
with information from the current package, and later we would load the
gob files for all dependencies via loadCachedOutputs.

This was a bit confusing; instead, load the cached gob files first,
and then do all the operations which fill information for curPkg.

Similarly, we were waiting until the very end of transformCompile to
write curPkg's cachedOutput gob file to the disk cache.
We can write the file at an earlier point, before we have obfuscated and
re-printed all Go files for the current package.
We can also write the file before other work like processImportCfg.

None of these changes should affect garble's behavior,
but they will make the cache redesign for #708 easier.
mvdan added a commit to mvdan/garble-fork that referenced this issue Jun 3, 2023
Some users had been running into "cannot load cache entry" errors,
which could happen if garble's cache files in GOCACHE were removed
when Go's own cache files were not.

Now that we've moved to our own separate cache directory,
and that we've refactored the codebase to depend less on globals
and no longer assume that we're loading info for the current package,
we can now compute a pkgCache entry for a dependency if needed.

We add a pkgCache.CopyFrom method to be able to append map entries
from one pkgCache to another without needing an encoding/gob roundtrip.

We also add a parseFiles helper, since we now have three bits of code
which need to parse a list of Go files from disk.

Fixes burrowers#708.
@mvdan mvdan closed this as completed in #756 Jun 3, 2023
mvdan added a commit that referenced this issue Jun 3, 2023
Some users had been running into "cannot load cache entry" errors,
which could happen if garble's cache files in GOCACHE were removed
when Go's own cache files were not.

Now that we've moved to our own separate cache directory,
and that we've refactored the codebase to depend less on globals
and no longer assume that we're loading info for the current package,
we can now compute a pkgCache entry for a dependency if needed.

We add a pkgCache.CopyFrom method to be able to append map entries
from one pkgCache to another without needing an encoding/gob roundtrip.

We also add a parseFiles helper, since we now have three bits of code
which need to parse a list of Go files from disk.

Fixes #708.
@vodves-vodves
Copy link
Author

Excuse me please tell me how to download the latest version? I only have 0.9.3 to download.

@mvdan
Copy link
Member

mvdan commented Jun 4, 2023

You can use go install mvdan.cc/garble@master to get the latest development version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants