air-verse / air

☁️ Live reload for Go apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hot Reload not working for changes on main.go

JonPichel opened this issue · comments

Hi,

I am using the air version packaged in nixpkgs. My operating system is NixOS. This is the version that gets returned on air -v: (devel), built with Go go@1.22.1.

This is my .air.toml file:

root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "./tmp/main"
  cmd = "go build -o ./tmp/main ."
  delay = 0
  exclude_dir = ["node_modules", "assets", "tmp", "vendor", "testdata"]
  exclude_file = []
  exclude_regex = ["_test.go"]
  exclude_unchanged = false
  follow_symlink = false
  full_bin = ""
  include_dir = [".", "internal"]
  include_ext = ["go"]
  include_file = ["main.go"]
  kill_delay = "0s"
  log = "build-errors.log"
  poll = false
  poll_interval = 0
  rerun = false
  rerun_delay = 500
  send_interrupt = false
  stop_on_error = false

[color]
  app = ""
  build = "yellow"
  main = "magenta"
  runner = "green"
  watcher = "cyan"

[log]
  main_only = false
  time = false

[misc]
  clean_on_exit = false

[screen]
  clear_on_rebuild = false
  keep_scroll = true

As you can see I tried several things to include main.go, but nothing is working. When I run air it reports that it is watching main.go, but when I change the contents of the file it doesn't reload.

It does however detect changes in any file in the internal/ directory.

I assume this is a problem with the version packaged by nixpkgs, but maybe my configuration is not correct.

It seems to I have the same issue, but when i set config file flag

air -c .air.toml

It works!

air v1.51.0, built with Go go1.22.2

It doesn't work for me that way either. Maybe it is due to the Nix package using the (devel) version.

This may not be helpful, but I will share,
In .air.toml.
Try changing poll=false to poll=true.

Hot reloading did not work on my AppleSillicon Mac, but in the end the only problem was the above setting!

I used DeepL for the translation!