#Build on save not working

1 messages · Page 1 of 1 (latest)

prime oracle
south ermine
#

This creates another step that ends up using -fno-emit-bin. That makes the build much quicker since there’s no need to call llvm

prime oracle
#

ok, so it is slighty better

#

i dont have a config for zls. do i just create one in the same location as the exe?

south ermine
#

Iirc you run zls --show-config-location

prime oracle
#

i ran it, and the config just doesnt exist

south ermine
#

VSCode might have some interface for it though. Probably use that if it’s a thing

#

If none of that’s a thing, try zls env. That should show where zls will look for the config

prime oracle
#

there is this

#

what is zls env?

south ermine
#

Docs say zls env will show you where zls looks

#

Yeah, so use the VSCode interface since it’s there

prime oracle
south ermine
#

Oh it’s since 0.14.0-dev.50+3354fdcb, sorry

prime oracle
#

oh ok

#

ok well build on save just isnt doing anything now

south ermine
#

Is the build on save step a valid step?

#

And check that it’s enabled

prime oracle
prime oracle
south ermine
#

Try running the step yourself

prime oracle
#

it works when i run it myself

#

Build on save not working

#
const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exe = b.addExecutable(.{
        .name = "hello_world",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);

    run_cmd.step.dependOn(b.getInstallStep());

    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);

    const exe_unit_tests = b.addTest(.{
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);

    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&run_exe_unit_tests.step);

    // check step
    const exe_check = b.addExecutable(.{
        .name = "hello_world",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    const check = b.step("check", "Check if program compiles without invoking llvm");
    check.dependOn(&exe_check.step);
}

this is the build script, in case that helps

kindred sinew
#

what does the Zig Language Sever output panel say

prime oracle
kindred sinew
#

also why did u make the build on save step "install" instead of "check"

prime oracle
#

i didnt, i was just showing them it exists

#

i changed it to check

#

install is just the default

#

restarting the server does not do anything either

#

tf is this?

kindred sinew
#

that usually means its lagging and shouldnt last long

#

is it a big file

prime oracle
#
const std = @import("std");

fn m(x: anytype) void {
    std.debug.print("{d}", .{x.len});
}

pub fn main() !void {
    m(100);
}

not at all

#

i removed the check function

prime oracle
#

fuck it, clean reinstall of zls

prime oracle
#

i’m still struggling with this, if anyone has any tips, please @ me

forest hazel
#

the makeZlsNotInstallAnythingDuringBuildOnSave thing

#

this is how we avoid emitting the binary proper with little editing of the core build.zig logic

prime oracle
#

build on save doesnt even work for me

#

it just doesnt build on save

forest hazel
#

also see the zls json file

forest hazel
#

what's the log say

prime oracle
#

i am using vscode, this is what i get

info : ( main ): Starting ZLS 0.13.0 @ 'c:\Users\radei\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zls_install\zls.exe'
info : (server): Client is 'Visual Studio Code-1.91.1'
info : (server): No config file zls.json found. This is not an error.
info : (server): Set config option 'builtin_path' to 'C:\Users\radei\AppData\Local\Temp\zls\builtin.zig'
info : (server): Set config option 'zig_lib_path' to 'C:\dev\zig-windows-x86_64-0.13.0\lib'
info : (server): Set config option 'zig_exe_path' to 'C:\dev\zig-windows-x86_64-0.13.0\zig.exe'
info : (server): Set config option 'build_runner_path' to 'C:\Users\radei\AppData\Local\Temp\zls\build_runner\21872970afd69e48a0847077e5196711\build_runner.zig'
info : (server): Set config option 'global_cache_path' to 'C:\Users\radei\AppData\Local\Temp\zls'
info : (server): Set config option 'enable_argument_placeholders' to 'false'
info : (server): Set config option 'enable_build_on_save' to 'true'
info : (server): Set config option 'build_on_save_step' to 'check'
info : (server): Set config option 'semantic_tokens' to 'partial'
info : (server): Set config option 'warn_style' to 'true'
info : (server): Set config option 'zig_exe_path' to 'C:\dev\zig-windows-x86_64-0.13.0\zig.EXE'
#
info : (server): Set config option 'enable_build_on_save' to 'true'
info : (server): Set config option 'build_on_save_step' to 'check'

it seems to recognize the change

forest hazel
#

appears to be enabling build on save

#

indeed

prime oracle
#

is there any other log i can check? this is just the vscode output terminal

forest hazel
#

does it output any log when you save the file and build

#

or nada

prime oracle
#

nope, but ive never seen it do that when it was working before

forest hazel
prime oracle
#

yup, that was changed. i was just showing them the setting exists

forest hazel
prime oracle
#
const std = @import("std");

fn m(x: anytype) void {
    std.debug.print("{d}", .{x.len});
}

pub fn main() !void {
    const x = @as(u32, -1);
    _ = x;
    m(100);
}

pretty much the same

#

the problem is, idk if it is a vscode issue or a zls issue

forest hazel
#

try something inline just to be sure, ie _ = x.len;

#

probably won't change anything

#

but best to rule out the possibility

prime oracle
#

nothing

forest hazel
#

there might well be a vscode setting you need to enable

#

because afaict this should be working

#

quick check: what's your OS

prime oracle
#

windows

#

windows 11

forest hazel
#

do you have any antivirus, and if so, have you given behaviour exceptions to both zig and zls

prime oracle
#

i do, but its one my school forces me to download. i dont think it does anything

forest hazel
#

antiviruses are a royal pain for "unsigned executables"

#

what's its name?

prime oracle
#

Sentinel One

#

i know nothing about it, i was required to download it because my schooll network requires it or some bs like that

forest hazel
#
Cyber Vigilance

Path Exclusion is a feature in SentinelOne that allows an administrator to suppress false positive events originating from specific files and processes. It also enables an administrator to exclude a path or file from monitoring where there are any interoperability issues. The exclusion also applies to processes whose route process is in the excl...

prime oracle
#

all it does is give me warnings when i run cmake

forest hazel
#

I would add zig and zls to the exclusion paths to be sure

#

and mayhaps your entire dev directory

prime oracle
#

clangd works fine (another lsp) but ill try that

forest hazel
#

clangd is probably recognized/signed software

prime oracle
#

hmmmmm

forest hazel
#

lol

prime oracle
prime oracle
#

even when running as an admin

forest hazel
#

just to check, I know the log said it is, but is zls --version 0.13?

prime oracle
#

yup, it is 0.13.0

forest hazel
#

quite strange a situation

#

I'm assuming you've restarted the extension host plenty

prime oracle
#

lol yup

#

i did reinstall zls through the extension multiple times

forest hazel
#

what does the install dir for the vscode zls look like

prime oracle
#
    Directory: C:\Users\radei\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zls_install


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         7/26/2024   8:32 PM        3366912 zls.exe

just the exe

#

not even a config, which is weird

#

im relying on vscode's config

forest hazel
#

wait a sec, is that the same as the one in your path?

#

run that zls.exe

#

with --version

prime oracle
#

zls is not set on my path, vs code sets the path of zls

forest hazel
#

I see

prime oracle
#

wait lemme check my path, maybe i did put it on the path and forgot

#

yeah its not there, its just set by vscode

forest hazel
#

honestly haven't the foggiest clue what could be going wrong

#

my last hunch is that zls 0.13.0 is just broken on windows

drowsy sun
#

doesnt vscode have a place to put flags/options for zls?

forest hazel
#

if you wanna try confirming that, try downgrading to 0.12.0

#

and see if that suddenly makes it work

prime oracle
forest hazel
#

at least then we'd know if it's a broken zls thing

#

(as in for both zig and zls)

prime oracle
#

ill try that

forest hazel
#

very annoying, I know

prime oracle
#

still not working

forest hazel
#

well damn

prime oracle
#

i changed the path of zls in the settings to the 0.12 version

forest hazel
#

this is smelling like a vscode thing?

prime oracle
#

i think so

#

i have been looking for an excuse to use nvim 👀

#

it used to work though

forest hazel
#

I'll be that guy and say try helix :p

prime oracle
#

i could try that out too, im guessing it wouldnt need to do as much configuring

#

but arent the bindings different from vim?

forest hazel
#

yeah, comes a bit more out of the box ready - and yeah, it uses a sort of opposite paradigm. vim is verb+noun, whilst helix is noun+verb

#

so in vim you decide what you're going to do, and then you select what you're doing it to

#

whereas in helix, you select something, and then you apply an action

#

for me the latter was more intuitive, but you'll have to be the judge

forest hazel
prime oracle
#

thanks for the helo

#

help

forest hazel
#

I mean

#

wild thought, it could suddenly resume working next time you restart your computer

prime oracle
#

ive tried restarting my computer

#

nothing

forest hazel
#

lol dang

#

fully broken

prime oracle
#

yup

#

thanks for sticking with me through this

forest hazel
#

yeah no problem, sorry to not be of more help