Hi,
I wanted better semantic analysis from zls, so followed the instructions to enable Build-On-Save.
I am able to do zig build check
which shows me the errors, but zls is not happy because it can’t watch the directory.
Running zig build check --watch
from the cli gives me the following error:
error: unable to watch src: NotSameFileSystem
A bit of googling brought me to a logged issue around this
My home directory is a separate mount (not enough space on the ssd) with zig installed through pacman
, so they are on separate mounts.
I moved my project to the same drive and watch worked fine.
While I like zig being managed by pacman
, I’d appreciate better feedback from zls. Is my best course of action to install zig manually into /home?
You’ll need "build_on_save_step": "check"
in your zls.json so that zls knows what to build.
Thank you for you reply. I don’t think that’s required anymore for Build-On-Save
By default, ZLS will automatically enable Build-On-Save if your build script defines a “check” step
That’s from the Build-On-Save documentation (linked above)
Furthermore, my lsp log shows it calling the build with check (which I added to build.zig):
[WARN][2025-04-28 12:31:03] …lsp/handlers.lua:564 “zig build runner exited with non-zero status: 1
stderr:
error: unable to watch src: NotSameFileSystem
error: the following build command failed with exit code 1:
/home/shri/src/drone.ah/triangle/.zig-cache/o/c407587240404c9a84a1fe1dbaca4fc1/build /usr/bin/zig /usr/lib/zig /home/shri/src/drone.ah/triangle /home/shri/src/drone.ah/triangle/.zig-cache /home/shri/.cache/zig --seed 0x330b4e16 -Z871a980459bd7bf7 --watch --check-only”
By default, ZLS will automatically enable Build-On-Save if your build script defines a “check” step
Sorry I didn’t notice that.
To clarify, are you passing --watch
in zls’s config ? If so that’s not needed as zls knows when opened files are saved.
Yes, but zls can’t give that information to zig, --watch
gives zig similar information.
It’s also recommended to use -fincremental
with --watch
for extremely fast builds.
zls supports running zig with either/both of these options
I think I might be misunderstanding what @drone-ah wants.
Is this about getting zls to show it’s own error messages along side the compiler’s in an IDE ?
I want zls to provide better diagnostic information about the errors in my code without having to do a build.
zls with the check step currently shows an error because my home directory is on a different mount point from zig.
I fixed it temporarily by moving the project to the root of the filesystem - and it works fine.
I was wondering if there was an alternative solution.
I hope that is a bit clearer as to the issue I have.
Thanks,
Shri
If you are wanting to use watch, then Zig (currently) needs to reside on the same partition. You can install manually or use something like zigup or mise to install it.
1 Like
You already did what needs to be done to work around the current limitation. Next somebody needs to implement the missing feature mentioned in the issue you linked in the first message.
ZLS or not, it’s a missing feature in the Zig compiler.
1 Like
Thank you all - I’ll wait until it’s fixed then 
While not exactly your problem, I also wanted to note that even when you’re within the same persistent filesystem zig build
can refuse to comply.
In my case, I thought it would be cool to use -fno-emit-bin
and -fincremental
to try to avoid running zig build
or zig build check
80x per hour.
Unfortunately my projects are all saved to my Nextcloud folder, and if I recall correctly the client uses FUSE to create a nested user-space filesystem. Thus, NotSameFileSystem
.
This PR has been open for nearly a year and it looked like it was bumped to the 14.1 milestone in March, then bumped again to 0.15.0. Unfortunate, for sure, yet probably not a big priority right after a new release.
Since I’m disinclined to change my entire filesystem layout or pepper my $HOME with random hardlinks and extra files just for this one feature (this isn’t Python, after all), so I bound the check command to a key and called it a day.
Edit: terminology
1 Like