air icon indicating copy to clipboard operation
air copied to clipboard

air doesnt reloading in the deeper path

Open dpurbosakti opened this issue 2 years ago • 12 comments

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 ?

dpurbosakti avatar Dec 14 '23 04:12 dpurbosakti

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

fourstepper avatar Dec 16 '23 12:12 fourstepper

@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)

dpurbosakti avatar Dec 18 '23 02:12 dpurbosakti

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

fourstepper avatar Dec 18 '23 06:12 fourstepper

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 avatar Dec 18 '23 07:12 dpurbosakti

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

dpurbosakti avatar Dec 18 '23 07:12 dpurbosakti

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

fourstepper avatar Dec 18 '23 08:12 fourstepper

is it maybe because im using WSL ?

dpurbosakti avatar Dec 19 '23 00:12 dpurbosakti

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

fourstepper avatar Dec 19 '23 14:12 fourstepper

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

dpurbosakti avatar Dec 20 '23 02:12 dpurbosakti

and yes it works on windows but not in WSL

dpurbosakti avatar Dec 20 '23 02:12 dpurbosakti

@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

jtlehtinen avatar Jan 01 '24 10:01 jtlehtinen

oh nice, it works. @jtlehtinen thanks

dpurbosakti avatar Jan 02 '24 02:01 dpurbosakti