Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

zig-run for files with external dependencies #96

Closed as not planned
Closed as not planned

Description

@corpix

Let's say I have src/main.zig with following:

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

...

I have zap defined in build.zig & build.zig.zon, zig build succeeds.
But when I try to zig-runfrom Emacs it fails with:

main.zig:2:21: error: no package named 'zap' available within package 'root'

I probably know why it happens (sorry I am relatively new to Zig), because zig run does not play well with build.zig. But doesn't this make zig run and zig-run Emacs function useless for larger (and practical) projects?

How do you run your code from within Emacs while making projects with Zig?

Activity

  1. joachimschmidt557 commented on Mar 25, 2024

    @joachimschmidt557
    Contributor

    zig-run will not use a build.zig even if one is present. For larger projects, you're right, it's very unlikely to be used, but for small single-file "scratchpads" it can be useful.

    (zig--run-cmd "run" (file-local-name (buffer-file-name)) "-O" zig-run-optimization-mode))

    #99 is a proposal to add zig build run as a new function. I'll close this issue in favor of that one. If you think this topic deserves a separate issue, we can reopen this again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions