Closed nandohos closed 1 year ago
I tried the solution that @ryoshindo gave in #349 and it worked.
I had the same error, but in my case it was because the package name of the file with
main()
was notmain
. Thus, the error disappeared by modifying the file as follows- package app + package main
My IDE created the package with the folder name and thus this error occurred.
Leaving my solution if someone stumbles upon this.
I just ran air
command without any arguments which resulted in:
/bin/sh: /Users/[username]/projects/my-project/tmp/main: Permission denied
To fix it I had to explicitly specify build command, i.e.:
air --build.cmd "go build -o ./tmp/main ./cmd/myproj/main.go"
Leaving my solution if someone stumbles upon this. I just ran
air
command without any arguments which resulted in:/bin/sh: /Users/[username]/projects/my-project/tmp/main: Permission denied
To fix it I had to explicitly specify build command, i.e.:
air --build.cmd "go build -o ./tmp/main ./cmd/myproj/main.go"
this also fixed my problem, thanks for posting this. This problem did not occur until i moved my main.go
inside the ./cmd
folder, i don't know if this is intended behaviour? But it appears the ./tmp/main
binary was being created with the wrong permissions -rw-r--r--
instead of -rwxr-xr-x
It's a relatively easy fix to this.
Make sure air doesn't delete the tmp folder. Give exec perms to the tmp/main binary.
If you're using a structure like /cmd/whatever...make sure that the package name is 'main' and you should be good to go.
I had a similar fix. My project had an /api/cmd/api
folder containing my main.go
file.
In .air.toml
, I updated this line:
- cmd = "go build -o ./tmp/main ."
+ cmd = "go build -o ./tmp/main ./cmd/api"
Hello, I just did a fresh install using go (go install github.com/cosmtrek/air@latest) on WSL ubuntu 22.04. Ran the following commands
The second command creates a folder tmp with a file inside when it runs, however it throws an error 'Permission denied'
[nando@DESKTOP] ~/Folder$ air -c .air.toml / /\ | | | |) //--\ || || _ , built with Go
watching . !exclude tmp building... running... /bin/sh: 1: /home/nando/Folder/tmp/main: Permission denied
Checking the permissions of the file that it created
[nando@DESKTOP] ~/Folder/tmp$ ls -la .rw-r--r-- 16k nando nando 31 Jan 23:39 main
The issue #113 didn't help, even after reinstalling and logging out still getting the same issue