air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
17.62k stars 804 forks source link

air doesnt reloading in the deeper path #509

Closed dpurbosakti closed 1 week ago

dpurbosakti commented 9 months ago

only work at this path /mnt/d/belajar/be/go/moko/simple-bank but when i edited some file in the /mnt/d/belajar/be/go/moko/simple-bank//api/account.go air doesnt reloading

is there any way to solve this by changing .air.toml ?

fourstepper commented 9 months ago

Could you create an example project that shows this issue between two different directories and push it to another repository on Github?

dpurbosakti commented 9 months ago

@fourstepper https://github.com/dpurbosakti/techschool_simplebank you can check it here main.go is works fine, but file in the deeper dir isnt working(air doesnt check if file is changed)

fourstepper commented 9 months ago

This is caused by you explicitly including "api", I am pretty sure, in your .air.toml - https://github.com/dpurbosakti/techschool_simplebank/blob/main/.air.toml#L14

It works if you comment this line out

dpurbosakti commented 9 months ago

image yes i tried to include api dir to try if its work that way,

image but when i comment "include_dir" in .air.toml its still didnt work even the CLI told me they are watching my dir

image proof on after edited, no mention about file changed

dpurbosakti commented 9 months ago

tried in several file in different dir still not working, only detect on main.go file

fourstepper commented 9 months ago

With this change, everything works as expected for me.

db/sqlc/account.sql.go has changed
building...
Processing path: /tmp/techschool_simplebank
running...
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /health-check             --> simple-bank/api.NewServer.func1 (3 handlers)
[GIN-debug] POST   /accounts                 --> simple-bank/api.(*Server).createAccount-fm (3 handlers)
[GIN-debug] GET    /accounts/:id             --> simple-bank/api.(*Server).getAccount-fm (3 handlers)
[GIN-debug] GET    /accounts                 --> simple-bank/api.(*Server).listAccounts-fm (3 handlers)
[GIN-debug] PUT    /accounts                 --> simple-bank/api.(*Server).updateAccount-fm (3 handlers)
[GIN-debug] DELETE /accounts/:id             --> simple-bank/api.(*Server).deleteAccount-fm (3 handlers)
[GIN-debug] POST   /transfers                --> simple-bank/api.(*Server).createTransfer-fm (3 handlers)
[GIN-debug] POST   /users                    --> simple-bank/api.(*Server).createUser-fm (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on 0.0.0.0:8080
dpurbosakti commented 9 months ago

is it maybe because im using WSL ?

fourstepper commented 9 months ago

Can't say, try replicating the bug in another environment

dpurbosakti commented 9 months ago

i've created another repo to check, and it still doesnt work.

dpurbosakti commented 9 months ago

and yes it works on windows but not in WSL

jtlehtinen commented 9 months ago

@dpurbosakti, are you making file edits from a Windows application. There's a known issue in WSL where modifications made from the native Windows environment may not trigger file modification events in the WSL Linux environment.

A workaround is to use polling by adding the following lines to your Air configuration file:

[build]
  poll = true
dpurbosakti commented 9 months ago

oh nice, it works. @jtlehtinen thanks