air icon indicating copy to clipboard operation
air copied to clipboard

when building getting error that there is " no Go files in /home/.. " and does not detects in the subdirectory

Open aleks20905 opened this issue 1 year ago • 6 comments

im using Go: 1.23.4 Air: 1.61.5 OS: nixos

After updating to version 1.61.5 of air, I encountered an issue where the main.go file is not detected when it is located in a subdirectory ./cmd. However, since the update, air fails to start or build the application unless the main.go file is moved to the root directory of the project.

The only workaround I’ve found is to move the main.go file from the cmd folder to the root of the project.

and to the air.toml i have only changed : cmd = "templ generate && go build -o tmp/main ./cmd"

aleks20905 avatar Dec 28 '24 23:12 aleks20905

I'm having the same issue.

Go version go1.23.4 darwin/arm64 Air version v1.61.5, built with Go go1.23.4 Macbook Pro M1 Sonoma 14.5 (23F79)

AsadSaleh avatar Dec 30 '24 09:12 AsadSaleh

Have you tried this command: cmd = "go build -o tmp/main -buildvcs=false ./cmd"

tskoyo avatar Jan 01 '25 19:01 tskoyo

Have you tried this command: cmd = "go build -o tmp/main -buildvcs=false ./cmd"

Haven't tried it.

However I solved the issue by moving my main.go file to the project's root directory. Now it's working as expected 👍

AsadSaleh avatar Jan 01 '25 23:01 AsadSaleh

What is the connection between the problem and -buildvcs=false buildvcs its just metadata embedding.

I updated to version 1.61.5 of air and started encountering this issue then downgraded to 1.61.4, but the problem persisted. Before 1.61.1, I didn't have any problems, and I haven't tried versions 1.61.2 or 1.61.3.

I havent looked very closely into the matter. Where and when exactly the problem started but still i know that. It seems like something specific changed after 1.61.1+ .

aleks20905 avatar Jan 02 '25 14:01 aleks20905

Same on upgrading from 1.60 to 1.61.7. Though it only popped up when I tried to move my templ command to pre_cmd

bryanvaz avatar Feb 08 '25 18:02 bryanvaz

@aleks20905 The default config file should be named .air.toml not air.toml

If you want to use the config file with a different name please use air -c <filename>. Similar issue https://github.com/air-verse/air/issues/712#issuecomment-2524141577

ngoctrng avatar Mar 20 '25 17:03 ngoctrng

For me this occured because my .air.toml file had an error in it -- proxy_port was not an int.

launching air by itself with the config file produces a misleading error:

  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ v1.62.0, built with Go go1.24.4

watching .
watching bin
watching ci
watching cmd
watching cmd/server
!exclude tmp
building...
no Go files in /app
failed to build, error: exit status 1
running...
/bin/sh: /app/tmp/main: not found

launching air -c .air.toml shows the correct error:

/app # air -c .air.toml
2025/06/19 06:46:16 (50, 16): no value can start with o

ykuksenko avatar Jun 19 '25 06:06 ykuksenko

Exactly, it's defined with a different name in the configuration file. Just change it from air.toml to .air.toml and it works! Image

mhcodev avatar Sep 20 '25 06:09 mhcodev

@aleks20905 The default config file should be named .air.toml not air.toml

If you want to use the config file with a different name please use air -c <filename>. Similar issue #712 (comment)

that was a great help for me, thanks a lot 👍

afereydoon1 avatar Sep 21 '25 12:09 afereydoon1

@aleks20905 The default config file should be named .air.toml not air.toml

If you want to use the config file with a different name please use air -c <filename>. Similar issue #712 (comment)

afereydoon1 avatar Sep 21 '25 12:09 afereydoon1