Fixing /opt/wrapper: does not exist error in Vercel PHP functions

,

I’m having the same issue for a Go project deployed to Vercel.

The same deployment that worked a few days ago can no longer be redeployed successfully.

After redeploying, I get the following panic:

panic: no such file or directory
goroutine 1 [running]:
main.checkForLambdaWrapper()
./main__vc__go__.go:24 +0x14a
main.main()
./main__vc__go__.go:29 +0x13

So I checked the vercel code, and it looks like Vercel is injecting the AWS_LAMBDA_EXEC_WRAPPER environment variable into the Lambda runtime. My app tries to execute whatever path is provided by this variable, but it points to a file that does not exist in the execution environment, which causes the panic. :thinking:

Code: vercel/packages/go/main.go at 74edeef49a3b51441fe61fcc2323260af6902a16 · vercel/vercel · GitHub

func checkForLambdaWrapper() {
	wrapper := os.Getenv("AWS_LAMBDA_EXEC_WRAPPER")
	if wrapper == "" {
		return
	}

	// Removing the env var doesn't work
	// Set it to empty string to override the previous value
	os.Setenv("AWS_LAMBDA_EXEC_WRAPPER", "")
	argv := append([]string{wrapper}, os.Args...)
	err := syscall.Exec(wrapper, argv, os.Environ())
	if err != nil {
		panic(err)
	}
}