#no dependency named 'dependecy_name' in 'build.zig.zon' even though it's there

1 messages · Page 1 of 1 (latest)

unborn dove
#

anonymousDepencency has been giving me some trouble.

attached photo is my file structure, i made a new project just to simplify things.

this is the code to import dep's module:

const loc_dep = b.anonymousDependency("dep/", @import("dep/build.zig"), .{
  .target = target,
  .optimize = optimize,
});
exe.addModule("dep", loc_dep.module("test-thing"));

this is dep's build.zig (well the important parts)

const raylib_dep = b.dependency("raylib", .{
  .target = target,
  .optimize = optimize,
});
const raylib = raylib_dep.artifact("raylib");
b.installArtifact(raylib);

_ = b.addModule("test-thing", .{
  .source_file = std.Build.FileSource.relative("src/main.zig"),
});

this is dep's build.zig.zon:

.{
  .name = "zentig-raylib",
  .version = "0.1.0",
  .dependencies = .{
    .raylib = .{
      .url = "https://github.com/raysan5/raylib/archive/7124a14a60a4bf7e4357030395750e03a1b976b2.tar.gz",
      .hash = "1220cb899cf05b87a116323b64419278bddb116b07394c3a5ce60c65f6aae7fafc8a",
    },
  },
}

and i get this error:

no dependency named 'raylib' in 'USER\zig\package_manager_anon_dep\dep\build.zig.zon'. All packages used in build.zig must be declared in this file.

what am i doing wrong?

fierce arch
#

The error message here is misleading. Anonymous dependencies cannot (currently) have non-anonymous deps, because Zig needs to be aware of all non-anon deps before actually compiling the build script so that it can fetch them. In fact, any build.zig.zon is completely ignored for anon deps

unborn dove
fierce arch
#

unfortunately i don't really think there's a good way to do this, no

#

not currently at least