-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--build.full_bin appears to be ignored in favor of --build.bin #734
Comments
Seems user@host:env$ cat <<EOF > main.go
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("Print env ENV:")
fmt.Println(os.Getenv("ENV"))
}
EOF
user@host:env$ air --build.cmd "go build -o main main.go" --build.full_bin "ENV=test ./main" --build.include_file "main.go"
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.61.7, built with Go go1.23.5
watching .
watching main.go
!exclude tmp
building...
running...
/bin/sh: /home/user/testdir/env/tmp/main: No such file or directory
^Ccleaning...
see you again~
user@host:env$ ENV=test-env ./main
Print env ENV:
test-env |
So, if you try to use both options, we know the winner: user@host:env$ air --build.cmd "go build -o main main.go" --build.full_bin "ENV=test-full_bin ./main" --build.bin "ENV=test-bin ./main" --build.include_file "main.go"
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.61.7, built with Go go1.23.5
watching .
watching main.go
!exclude tmp
building...
running...
Print env ENV:
test-bin
Process Exit with Code 0 FYI Is |
To get this working I can indeed switch to the TOML file; glad to know I'm not crazy. |
Ok. Lets make test of TOML configuration: user@host:env$ cat <<EOF > main.go
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("Print env ENV:")
fmt.Println(os.Getenv("ENV"))
fmt.Println("Print ARGS:")
fmt.Printf("%+v\n", os.Args[1:])
}
EOF .air.toml user@host:env$ cat <<EOF > .air.toml
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = ["args","-","bin"]
bin = "./main test-cli-arg-bin"
cmd = "go build -o ./main main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = "ENV=test-Full_bin ./main test-arg-cli-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 = []
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
silent = false
time = false
[misc]
clean_on_exit = false
[proxy]
app_port = 0
enabled = false
proxy_port = 0
[screen]
clear_on_rebuild = false
keep_scroll = true
EOF user@host:env$ air
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.61.7, built with Go go1.23.5
watching .
!exclude tmp
building...
running...
Print env ENV:
test-Full_bin
Print ARGS:
[test-arg-cli-full_bin args - bin]
Process Exit with Code 0 Seems |
We can use user@host:env$ air --build.cmd "go build -o main main.go" --build.bin "ENV=test-bin ./main" --build.args_bin "test-ar-cli-bin" --build.include_file "main.go"
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.61.7, built with Go go1.23.5
watching .
watching main.go
!exclude tmp
building...
running...
Print env ENV:
test-bin
Print ARGS:
[test-ar-cli-bin]
Process Exit with Code 0
^Ccleaning...
see you again~ |
Another way to use |
Excellent, thanks for the alternative options. Much appreciated! |
Hey there,
I just stumbled upon this project ~20 minutes ago and it sounds fantastic. Unfortunately I'm having trouble getting mine to work. I'm skipping the TOML file for the moment in favor of a raw CLI invocation and it seems to ignore
--build.full_bin
. For context, I'm building an admin panel in my app that uses templ and HTMX, and want to regenerate and rehost the app easily. My command is something like:And I see
air
spin up and watch the files, invokesgo generate ./...
, builds the binary, then a bit later tries to run it using the default./tmp/main
path:Am I misunderstanding the docs in how to use
--build.full_bin
? Is it meant to complement--build.bin
in some way? The docs had me thinking it was one or the other.The text was updated successfully, but these errors were encountered: