air-verse / air

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

air not working when project directory is a symlink #531

Open Tachi107 opened 4 months ago

Tachi107 commented 4 months ago

Hi, it seems that air is unable to watch files when accessing the project through a symlink. Here are the steps to reproduce the problem:

$ mkdir project
$ cd project
$ cat > main.go <<EOF
package main
func main() {
    for {}
}
EOF
$ go mod init project
$ air
  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.49.0, built with Go go1.21.6

mkdir /tmp/tmp.nE9SAKeGRq/project/tmp
watching .
!exclude tmp
building...
running...
^Ccleaning...
see you again~
$ cd ..
$ ln -s project symlink
$ air
  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.49.0, built with Go go1.21.6

mkdir /tmp/tmp.nE9SAKeGRq/symlink/tmp
building...
running...
^Ccleaning...
see you again~

As you can see, when cding into the symlink file, air doesn't print the watching . message, and indeed doesn't watch for file updates.

How can I solve this issue? Thanks!

Lasoloz commented 3 months ago

Hi, I'm having the same problem. My project is accessible from three different paths:

/data/project/<redacted>/personal/<project>
~/project/root/personal/<project> (root being a symlink)
~/project/<project> (<project> being a symlink)

The output for the first two is:

 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.51.0, built with Go go1.22.1

watching src
watching src/models
watching src/templating
!exclude tmp
watching views
watching views/layouts
building...
running...

However, when I give the air command from the third path, I get the following:

 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.51.0, built with Go go1.22.1

building...
running...