Skip to content
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

Exclude dir not working #678

Open
herzadinata opened this issue Nov 4, 2024 · 5 comments
Open

Exclude dir not working #678

herzadinata opened this issue Nov 4, 2024 · 5 comments

Comments

@herzadinata
Copy link

herzadinata commented Nov 4, 2024

I use:
air v1.61.1, built with Go go1.23.2

This is my .air.toml file, put in the project root:
Screenshot 2024-11-04 at 09 58 32

But the node_modules dir in the project root is still being watched:
Screenshot 2024-11-04 at 09 57 20

Expectation:
The node_modules should not be watched

@herzadinata herzadinata changed the title Excluding dir not working Exclude dir not working Nov 4, 2024
@istyf
Copy link

istyf commented Nov 4, 2024

Hmm, "works on my machine". Are you sure that it is actually using that config file? Does it fail as expected if you change the build command to some nonsense such as go build -o ./tmp/main ./nosuchdirectory ?

@herzadinata
Copy link
Author

herzadinata commented Nov 5, 2024

@istyf

Oh sorry, a little misunderstanding, i am not using it to build golang binary file, rather to watch / hot-reload my golang development environment.

...
[build]
  args_bin = []
  bin = "./tmp/main"
  cmd = "go build -o ./tmp/main ."
  exclude_dir = ["tmp", "node_modules"]
...

So that is for excluding directory on build command? That's not what I want to do.

I want to watch the changes on my golang project but excluding that node_modules from being watched.
So I tried to change the code above to this

...
root = "."
tmp_dir = "tmp"
exclude_dir = ["tmp", "node_modules"]

[build]
  args_bin = []
...

That's still not excluding node_modules from being watched. Is it capable of doing that?

@istyf
Copy link

istyf commented Nov 5, 2024

No, it is not specific to the build command. It specifies what directories should be excluded from watching for changes.

What do you want to happen when air detects a file change? What is supposed to be reloaded and how?

@istyf
Copy link

istyf commented Nov 5, 2024

Sorry, I didn’t notice that you moved exclude_dir out of the [build] section. That does not work.

If you remove lines from the toml those settings will be set to their default values, which aren’t necessarily empty. You need to change it back to have any hope of getting it to work.

If you do not want to build anything you need to set cmd to something that succeeds but does nothing. One example is here: #632 (comment)

@herzadinata
Copy link
Author

herzadinata commented Nov 6, 2024

@istyf I meant building I don't want to build binary file for production, but building the binary file into tmp_dir for watching purpose is is fine.

Okay so I changed back the exclude_dir:
Screenshot 2024-11-06 at 09 10 37

Then run air by also pointing the air.toml. file:
Screenshot 2024-11-06 at 09 10 51

But still the node_modules is being watched:
Screenshot 2024-11-06 at 09 11 40

I am expecting the node_modules should not be watched as I specified in the exclude_dir above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants