Open iqbaldp78 opened 2 years ago
When you start Docker, does cmd/* show the watching
log in the terminal?
sample: watching ***
yes
my terminal @SuzurikawaChihiro
Interesting. The reverse here is the case for me. Air does not track root changes but does quite fine once files are in a sub directory.
I have a similar problem and tried "*", "."
but neither worked for root files.
Hi, I have a similar problem
My project directory:
my .air.toml:
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
root = "."
tmp_dir = "tmp"
[build]
# cmd = "make build-api"
cmd = "go build -o ./tmp/main ./cmd/user_service/main.go"
bin = "tmp/main"
full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
include_ext = ["go", "tpl", "tmpl", "html", "css", "js", "env", "yaml"]
exclude_dir = ["tmp", "assets", "vendor", "bin", "build", "deploy"]
include_dir = []
exclude_regex = ["_test.go"]
exclude_file = []
exclude_unchanged = true
log = "air.log"
args_bin = []
stop_on_error = true
send_interrupt = false
delay = 1000
kill_delay = 500
[log]
time = false
[color]
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
[misc]
clean_on_exit = false
When I save any file in the root, air rebuilds successfully, but ignores all subdirectories and files in them. Writing directories in the include_dir
field does not solve this problem.
Use WSL2 Ubuntu 22.04.
Same here, created simple Fiber app, it works if 'main.go' is in root directory, but after I moved it to 'src' directory - it says 'no Go files in {paht to root directory}'. Include_dir didn't help
@Falldot Did it work for you ? I am facing the same problem
This apparently is still a thing. I have a project where the go files are in ./cmd/web. Air refuses to find them. I eventually moved all the files into the root directory to get around this.
watching . watching cmd watching cmd/api watching cmd/web watching cmd/web/templates watching internal !exclude tmp building... no Go files in {/Users/[my-name]/Development/[project-name]} failed to build, error: exit status 1
@PickledDev I have a similar setup, and it works for me. In your build section, are you using the following ?
cmd = "go build -o ./tmp/main ./cmd/web/." (with period at the end, not main.go,etc)
If I run the build command as listed on the line in the terminal, it will compile. Only Air doesn't want to.
I have that but still no go (pun not intended).
[build]
# Just plain old shell command. You could use `make` as well.
cmd = "go build -o ./tmp/main ./cmd/web/."
# Binary file yields from `cmd`.
bin = "/tmp/main"
My file structure is:
I also noticed it says it is watching my templates folder, but it does not see changes there when I make them. I have verified that the include line is watching the correct extensions
include_ext = ["go", "tpl", "tmpl", "html", "gohtml"]
I've made a little progress. As a test I decided that the wording "No Go files..." was a clue to the problem. I do not have any go files at the root of my project, they are all in ./cmd/web at the moment. So I created a dummy.go file with a function that just had a comment in it. Ran air, and it compiled and stopped complaining.
Now I have a new problem; the executable created in ./tmp does not have execute permissions. I should probably note I am an a Mac running Sonoma.
Make sure to add http server main.go
file in cmd directory of air.toml
I have a similar issue, only changing main.go
in root folder will trigger rebuild. Modifying files in subfolders will not trigger the rebuild.
I run air with default config, no custom config file pass in. When run, it shows that it is watching all the subdirectories.
Got similar problem. Air exclude cmd and internal folder and i dont know why. log:
!exclude cmd
!exclude internal
!exclude node_modules
!exclude tmp
config:
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
bin = "tmp/main.exe"
cmd = "go build -o ./tmp/main.exe ./cmd/app/."
delay = 1000
exclude_dir = ["tmp", "node_modules"]
exclude_file = []
exclude_regex = ["_test.go", "_temp.go"]
exclude_unchanged = true
follow_symlink = true
full_bin = ""
include_dir = ["**"]
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = [
"templ generate",
"npx tailwindcss -i ./internal/style/style.css -o ./internal/static/style/output.css",
]
rerun = true
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 mentioned here
and here
setting poll=true in the build section works. This is at least true for me running WSL2 Debian on Windows 10
This is my working .air.toml config for reference
root = "."
tmp_dir = "tmp"
[build]
bin = "./tmp/main"
cmd = "templ generate && go build -o ./tmp/main ."
delay = 1000
exclude_regex = [".*_templ.go"]
exclude_dir = ["assets", "tmp", "vendor", "node_modules"]
include_dir = []
exclude_file = []
exclude_unchanged = false
follow_symlink = false
full_bin = ""
poll=true
include_ext = ["go", "tpl", "tmpl", "templ", "html"]
kill_delay = "0s"
log = "build-errors.log"
send_interrupt = false
stop_on_error = true
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
time = false
[misc]
clean_on_exit = false
This is my file structure using Windows 11 WSL Ubuntu:
And this is my air.toml:
root = "."
Running air at the root of the project:
Edit the air.toml:
root = "./cmd"
Still the same error:
if i delete the air.toml and run the air command at ./cmd:
kkolios@kkolios-pc:/mnt/c/Users/kkolios/Desktop/my-beatiful-cv/cmd$ air
/ /\ | | | |) //--\ || || _ v1.51.0, built with Go go1.22.2
watching . watching docs watching internal watching internal/models watching internal/repositories watching internal/services watching internal/utils watching tests watching tests/models watching tests/repositories watching tests/services watching tests/utils !exclude tmp building... running...
/ /__/ / / _// / \/ \ //\////\/ v4.12.0 High performance, minimalist Go web framework https://echo.labstack.com ____O/___ O\ ⇨ http server started on [::]:9999
it's working but this not the expected behavior, i cannot find a way to configure the air.toml is like WSL ignore the configurations, any related problem ?
As mentioned here
and here
setting poll=true in the build section works. This is at least true for me running WSL2 Debian on Windows 10
This is my working .air.toml config for reference
root = "." tmp_dir = "tmp" [build] bin = "./tmp/main" cmd = "templ generate && go build -o ./tmp/main ." delay = 1000 exclude_regex = [".*_templ.go"] exclude_dir = ["assets", "tmp", "vendor", "node_modules"] include_dir = [] exclude_file = [] exclude_unchanged = false follow_symlink = false full_bin = "" poll=true include_ext = ["go", "tpl", "tmpl", "templ", "html"] kill_delay = "0s" log = "build-errors.log" send_interrupt = false stop_on_error = true [color] app = "" build = "yellow" main = "magenta" runner = "green" watcher = "cyan" [log] time = false [misc] clean_on_exit = false
it worked for me
Make sure to add http server
main.go
file in cmd directory ofair.toml
this works for me, thanks
i have project directory like this :
my
.air.toml
when try to save .env file its reload as well, but when i try to save main.go file under dir cmd/app/main.go . does not work ..
can someone help me ??