Giter Site home page Giter Site logo

gyro's Introduction

gyro: a zig package manager

A gyroscope is a device used for measuring or maintaining orientation

Linux windows macOS



GYRO IS NOW ARCHIVED, THANK YOU EVERYONE FOR YOUR FEEDBACK AND TIME. ZIG NOW HAS AN OFFICIAL PACKAGE MANAGER AND DAMN IT'S GOOD.

Table of contents

Introduction

Gyro is an unofficial package manager for the Zig programming language. It improves a developer's life by giving them a package experience similar to cargo. Dependencies are declared in a gyro.zzz file in the root of your project, and are exposed to you programmatically in the build.zig file by importing @import("deps.zig").pkgs. In short, all that's needed on your part is how you want to add packages to different objects you're building:

const Builder = @import("std").build.Builder;
const pkgs = @import("deps.zig").pkgs;

pub fn build(b: *Builder) void {
    const exe = b.addExecutable("main", "src/main.zig");
    pkgs.addAllTo(exe);
    exe.install();
}

To make the job of finding suitable packages to use in your project easier, gyro is paired with a package index located at astrolabe.pm. A simple gyro add alexnask/iguanaTLS will add the latest version of iguanaTLS (pure Zig TLS library) as a dependency. To build your project all that's needed is gyro build which works exactly like zig build, you can append the same arguments, except it automatically downloads any missing dependencies. To learn about other If you want to use a dependency from github, you can add it by explicitly with github add -s github <user>/<repo> [<ref>]. <ref> is an optional arg which can be a branch, tag, or commit hash, if not specified, gyro uses the default branch.

Installation

In order to install gyro, all you need to do is extract one of the release tarballs for your system and add the single static binary to your PATH. Gyro requires the latest stable version of the Zig compiler (0.10.1 at time of writing)

Building

If you'd like to build from source, the only thing you need is the Zig compiler:

git clone https://github.com/mattnite/gyro.git
cd gyro
zig build -Drelease-safe

How tos

Instead of just documenting all the different subcommands, this documentation just lists out all the different scenarios that Gyro was built for. And if you wanted to learn more about the cli you can simply gyro <subcommand> --help.

Initialize project

If you have an existing project on Github that's a library then you can populate gyro.zzz file with metadata:

gyro init <user>/<repo>

For both new and existing libraries you'd want to check out export a package, if you don't plan on publishing to astrolabe then ensuring the root file is declared is all that's needed. For projects that are an executable or considered the 'root' of the dependency tree, all you need to do is add dependencies.

Setting up build.zig

In build.zig, the dependency tree can be imported with

const pkgs = @import("deps.zig").pkgs;

then in the build function all the packages can be added to an artifact with:

pkgs.addAllTo(lib);

individual packages exist in the pkgs namespace, so a package named mecha can be individually added:

lib.addPackage(pkgs.mecha)

Ignoring gyro.lock

gyro.lock is intended for reproducible builds. It is advised to add it to .gitignore if your project is a library.

Export a package

This operation doesn't have a cli equivalent so editing of gyro.zzz is required, if you followed initializing a project and grabbed metadata from Github, then a lot of this work is done for you -- but still probably needs some attention:

  • the root file, it is src/main.zig by default
  • the version
  • file globs describing which files are actually part of the package. It is encouraged to include the license and readme.
  • metadata: description, tags, source_url, etc.
  • dependencies

Publishing a package to astrolabe.pm

In order to publish to astrolabe you need a Github account and a browser. If your project exports multiple packages you'll need to append the name, otherwise you can simply:

gyro publish

This should open your browser to a page asking for a alphanumeric code which you can find printed on the command line. Enter this code, this will open another page to confirm read access to your user and your email from your Github account. Once that is complete, Gyro will publish your package and if successful a link to it will be printed to stdout.

An access token is cached so that this browser sign-on process only needs to be done once for a given dev machine.

If you'd like to add publishing from a CI system see Publishing from an action.

Adding dependencies

From package index

gyro add <user>/<pkg>

From a git repo

Right now if the repo isn't from Github then you can add an entry to your deps like so:

deps:
  pkgname:
    git:
      url: "https://some.repo/user/repo.git"
      ref: main
      root: my/root.zig

From Github

If you add a package from Github, gyro will get the default branch, and try to figure out the root path for you:

gyro add --src github <user>/<repo>

From url

Note that at this time it is not possible to add a dependency from a url using the command line. However, it is possible to give a url to a .tar.gz file by adding it to your gyro.zzz file.

deps:
  pkgname:
    url: "https://path/to/my/library.tar.gz"
    root: libname/rootfile.zig

In this example, when library.tar.gz is extracted the top level directory is libname.

Build dependencies

It's also possible to use packaged code in your build.zig, since this would only run at build time and not required in your application or library these are kept separate from your regular dependencies in your project file.

When you want to add a dependency as a build dep, all you need to do is add --build-dep to the gyro invocation. For example, let's assume I need to do some parsing with a package called mecha:

gyro add --build-dep mattnite/zzz

and in my build.zig:

const Builder = @import("std").build.Builder;
const pkgs = @import("gyro").pkgs;
const zzz = @import("zzz");

pub fn build(b: *Builder) void {
    const exe = b.addExecutable("main", "src/main.zig");
    pkgs.addAllTo(exe);
    exe.install();

    // maybe do some workflow based on gyro.zzz
    var tree = zzz.ZTree(1, 100){};
    ...
}

Removing dependencies

Removing a dependency only requires the alias (string used to import):

gyro rm iguanaTLS

Local development

One can switch out a dependency for a local copy using the redirect subcommand. Let's say we're using mattnite/tar from astrolabe and we come across a bug, we can debug with a local version of the package by running:

gyro redirect -a tar -p ../tar

This will point gyro at your local copy, and when you're done you can revert the redirect(s) with:

gyro redirect --clean

Multiple dependencies can be redirected. Build dependencies are redirected by passing -b. You can even redirect the dependencies of a local package.

HOT tip: add this to your git pre-commit hook to catch you before accidentally commiting redirects:

gyro redirect --check

Update dependencies -- for package consumers

Updating dependencies only works for package consumers as it modifies gyro.lock. It does not change dependency requirements, merely resolves the dependencies to their latest versions. Simply:

gyro update

Updating single dependencies will come soon, right now everything is updated.

Use gyro in Github Actions

You can get your hands on Gyro for github actions here, it does not install the zig compiler so remember to include that as well!

Publishing from an action

It's possible to publish your package in an action or other CI system. If the environment variable GYRO_ACCESS_TOKEN exists, Gyro will use that for the authenticated publish request instead of using Github's device flow. For Github actions this requires creating a personal access token with scope read:user and user:email and adding it to an Environment, and adding that Environment to your job. This allows you to access your token in the secrets namespace. Here's an example publish job:

name: Publish

on: workflow_dispatch

jobs:
  publish:
    runs-on: ubuntu-latest
    environment: publish
    steps:
      - uses: mattnite/setup-gyro@v1
      - uses: actions/checkout@v2
      - run: gyro publish
        env:
          GYRO_ACCESS_TOKEN: ${{ secrets.GYRO_ACCESS_TOKEN }}

Completion Scripts

Completion scripts can be generated by the completion subcommand, it is run like so:

gyro completion -s <shell> <install path>

Right now only zsh is the only supported shell, and this will create a _gyro file in the install path. If you are using oh-my-zsh then this path should be $HOME/.oh-my-zsh/completions.

Design philosophy

The two main obectives for gyro are providing a great user experience and creating a platform for members of the community to get their hands dirty with Zig package management. The hope here is that this experience will better inform the development of the official package manager.

To create a great user experience, gyro is inspired by Rust's package manager, Cargo. It does this by taking over the build runner so that zig build is effectively replaced with gyro build, and this automatically downloads missing dependencies and allows for build dependencies. Other features include easy addition of dependencies through the cli, publishing packages on astrolabe.pm, as well as local development.

The official Zig package manager is going to be decentralized, meaning that there will be no official package index. Gyro has a centralized feel in that the best UX is to use Astrolabe, but you can use it without interacting with the package index. It again comes down to not spending effort on supporting everything imaginable, and instead focus on experimenting with big design decisions around package management.

Generated files

gyro.zzz

This is your project file, it contains the packages you export (if any), dependencies, and build dependencies. zzz is a file format similar to yaml but has a stricter spec and is implemented in zig.

A map of a gyro.zzz file looks something like this:

pkgs:
  pkg_a:
    version: 0.0.0
    root: path/to/root.zig
    description: the description field
    license: spdix-id
    homepage_url: https://straight.forward
    source_url: https://straight.forward

    # these are shown on astrolabe
    tags:
      http
      cli

    # allows for globbing, doesn't do recursive globbing yet
    files:
      LICENSE
      README.md # this is displayed on the astrolabe
      build.zig
      src/*.zig

  # exporting a second package
  pkg_b:
    version: 0.0.0
    ...

# like 'deps' but these can be directly imported in build.zig
build_deps:
  ...

# most 'keys' are the string used to import in zig code, the exception being
# packages from the default package index which have a shortend version
deps:
  # a package from the default package index, user is 'bruh', its name is 'blarg'
  # and is imported with the same string
  bruh/blarg: ^0.1.0

  # importing blarg from a different package index, have to use a different
  # import string, I'll use 'flarp'
  flarp:
    pkg:
      name: blarg
      user: arst
      version: ^0.3.0
      repository: something.gg

  # a git package, imported with string 'mecha'
  mecha:
    git:
      url: "https://github.com/Hejsil/mecha.git"
      ref: zig-master
      root: mecha.zig

  # a raw url, imported with string 'raw' (remember its gotta be a tar.gz)
  raw:
    url: "https://example.com/foo.tar.gz"
    root: bar.zig

  # a local path, usually used for local development using the redirect
  # subcommand, but could be used for vendoring or monorepos
  blarg:
    local: deps/blarg
    root: src/main.zig

gyro.lock

This contains a lockfile for reproducible builds, it is only useful in compiled projects, not libraries. Adding gyro.lock to your package will not affect resolved versions of dependencies for your users -- it is suggested to add this file to your .gitignore for libraries.

deps.zig

This is the generated file that's imported by build.zig, it can be imported with @import("deps.zig") or @import("gyro"). Unless you are vendoring your dependencies, this should be added to .gitignore.

.gyro/

This directory holds the source code of all your dependencies. Path names are human readable and look something like <package>-<user>-<version> so in many cases it is possible to navigate to dependencies and make small edits if you run into bugs. For a more robust way to edit dependencies see local development

It is suggested to add this to .gitignore as well.

gyro's People

Contributors

albinodrought avatar devins2518 avatar dhole avatar drgmr avatar ducdetronquito avatar g-w1 avatar hejsil avatar jakeisnt avatar leecannon avatar lewisgaul avatar mattn avatar mattnite avatar nfisher1226 avatar pjz avatar prince213 avatar rageoholic avatar samtebbs33 avatar sebastiankeller avatar sup3legacy avatar trashhalo avatar travisstaloch avatar truemedian avatar zaneli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gyro's Issues

Move from imports.zzz to imports.zig

Thanks @mattnite for this!

One thing that would be cool is to move from imports.zzz to imports.zig:

  • Removes the YAML dependency, avoids the packaging manager introducing a meta language
  • Leverages the Zig compiler for safety checks... with anonymous struct and enum literals Zig is really good as a DSL
  • Makes zkg Zig all the way down, similar to the ideas behind build.zig and comptime

weird errors

I just installed gyro from the .tar.gz. my zig version is: 0.10.1
and the error i am getting when running gyro build is:

/home/mknight/zig/0.10.0-dev.2431+0e6285c8f/files/lib/std/json.zig:1784:33: 0x2da5a1 in std.json.parse (gyro)
/home/mknight/zig/0.10.0-dev.2431+0e6285c8f/files/lib/std/json.zig:0:0: 0x2db3ee in std.json.parse (gyro)
/home/mknight/zig/0.10.0-dev.2431+0e6285c8f/files/lib/std/fs.zig:0:5: 0x2d3a17 in commands.build (gyro)
/home/mknight/code/gyro/src/main.zig:260:13: 0x2a2d27 in main (gyro)
/home/mknight/code/gyro/src/main.zig:0:0: 0x2a3e13 in main (gyro)
/home/mknight/code/gyro/src/main.zig:0:0: 0x2a3e3f in main (gyro)

gyro build can't find non-standard root file

Forgive me if this is just user error. But I'm not sure what went wrong. It looks like src/main.zig is being used instead of root: src/art.zig which was specified in my gyro.zzz

$ cd /tmp
travis@home:/tmp
$ mkdir gyrotest
travis@home:/tmp
$ cd gyrotest/
travis@home:/tmp/gyrotest
$ zig init-exe
info: Created build.zig
info: Created src/main.zig
info: Next, try `zig build --help` or `zig build run`
travis@home:/tmp/gyrotest
$ gyro add travisstaloch/art.zig -g
debug: default_branch: master
travis@home:/tmp/gyrotest
$ # here i modified build.zig adding `pkgs.addAllTo(exe);` just before `exe.install();`
$ gyro build
info: fetching tarball: https://codeload.github.com/travisstaloch/art.zig/legacy.tar.gz/392498a765c8c6909adbad4b200d7c536cb8c030
error: unable to build stage1 zig object: FileNotFound: /tmp/gyrotest/.gyro/art.zig-travisstaloch-392498a765c8c6909adbad4b200d7c536cb8c030/pkg/src/main.zig
gyrotest...The following command exited with error code 1:
/media/data/Users/Travis/Documents/Code/zig/zig/build/zig build-exe /tmp/gyrotest/src/main.zig --cache-dir /tmp/gyrotest/zig-cache --global-cache-dir /home/travis/.cache/zig --name gyrotest --pkg-begin art /tmp/gyrotest/.gyro/art.zig-travisstaloch-392498a765c8c6909adbad4b200d7c536cb8c030/pkg/src/main.zig --pkg-end --enable-cache 
The following command exited with error code 1 (expected 0):
cd . && /tmp/gyrotest/zig-cache/o/172d20e619a550558650a5a0f8d43e45/build /media/data/Users/Travis/Documents/Code/zig/zig/build/zig . zig-cache /home/travis/.cache/zig 
error: Compiler had an unclean exit

Support cloning Pijul repositories

Please support Pijul for cloning Zig package dependencies.
Pijul is an amazing new version control system written in Rust. Unlike Git, Pijul doesnโ€™t suck.
Itโ€™s based on the theory of patches, and it manages merge conflicts way better than Git.
There are more cool features, check out their homepage for more info.
https://pijul.org
There is a web based forge (similar to Gitea and GitLab for Git), which can be used to share Zig packages: https://nest.pijul.com

published gyro 0.4.0 mac aarch64 is actually a x86 binary

Attempting to executed it on my m1 mac

โžœ  gyro git:(90af164) โœ— /Users/stephensolka/Downloads/gyro-0.4.0-macos-aarch64/bin/gyro 
[1]    78917 illegal hardware instruction  /Users/stephensolka/Downloads/gyro-0.4.0-macos-aarch64/bin/gyro

Inspecting it with file

โžœ  gyro git:(90af164) โœ— file ~/Downloads/gyro-0.4.0-macos-aarch64/bin/gyro 
/Users/stephensolka/Downloads/gyro-0.4.0-macos-aarch64/bin/gyro: Mach-O 64-bit executable x86_64

There is something wrong with this file but I dont know enough about zig to figure out what. https://github.com/mattnite/gyro/blob/master/.github/workflows/release.yml#L140

Incompatible with zig's new build system API

Gyro is currently incompatible with the changes that have recently been made to zig's build system:

/home/lordmzte/dev/dotfiles/scripts/mzteinit/deps.zig:14:17: error: no field or member function named 'addPackage' in 'Build.CompileStep'
        artifact.addPackage(pkgs.@"ansi-term");
        ~~~~~~~~^~~~~~~~~~~

ld.lld: error: cannot create a copy relocation for symbol __stack_chk_guard

Hi, I'm building a Gyro on ARM and got this error:

ld.lld: error: cannot create a copy relocation for symbol __stack_chk_guard
error: LLDReportedFailure
gyro...The following command exited with error code 1:
/data/data/com.termux/files/usr/bin/zig build-exe /data/data/com.termux/files/home/gyro/src/main.zig -cflags -DLIBGIT2_NO_FEATURES_H -DGIT_TRACE=1 -DGIT_THREADS=1 -DGIT_USE_FUTIMENS=1 -DGIT_REGEX_PCRE -DGIT_SSH=1 -DGIT_SSH_MEMORY_CREDENTIALS=1 -DGIT_HTTPS=1 -DGIT_MBEDTLS=1 -DGIT_SHA1_MBEDTLS=1 -fno-sanitize=all -DGIT_ARCH_64=1 -- /data/data/com.termux/files/home/gyro/libs/libgit2/c/deps/http-parser/http_parser.c /data/data/com.termux/files/home/gyro/libs/libgit2/c/src/allocators/failalloc.c
...
-I /data/data/com.termux/files/home/gyro/libs/libssh2/c/include -I /data/data/com.termux/files/home/gyro/libs/libssh2/config -I /data/data/com.termux/files/home/gyro/libs/mbedtls/c/include -I /data/data/com.termux/files/home/gyro/libs/mbedtls/c/library --enable-cache
error: the following build command failed with exit code 1:
/data/data/com.termux/files/home/gyro/zig-cache/o/5b0b6bd4e7a49025e16515305baf277b/build /data/data/com.termux/files/usr/bin/zig /data/data/com.termux/files/home/gyro /data/data/com.termux/files/home/gyro/zig-cache /data/data/com.termux/files/home/.cache/zig -Drelease-safe

(The log is stripped because the log has so much output I can't show it all)

Cannot install from GitHub source with 0.7.0

Using zig master and gyro 0.7.0 release:

$ gyro add --src github Hejsil/clap
error: remote authentication required but no callback set

I don't understand why I'd need authentication; sorry if I've done something stupid!

Does not work with master Zig

Any way someone can update this to work with zig master? It's a million times better than zigmod, but I can't use this with anything because I need zig 11.

error: the SSL certificate is invalid: 0x08 - The certificate is not correctly signed by the trusted CA

I'm using requestz as a dependency for a Zig project. But when I gyro fetch, I got this error:

zigcord on ๎‚  main [?] via โ†ฏ v0.9.0-dev.1656+dcd88ae56 took 10s
โฏ gyro fetch
pkg astrolabe.pm/ducdetronquito/requestz      0.1.1    [###################] 100%
git github.com/alexnask/iguanaTLS             0d39a361 [                   ]   0% ERROR
git github.com/MasterQ32/zig-network          b9c91769 [                   ]   0% ERROR
pkg astrolabe.pm/ducdetronquito/http          0.1.3    [###################] 100%
pkg astrolabe.pm/ducdetronquito/h11           0.1.1    [###################] 100%
----------------------------------------------------------------------------------------
logs captured during fetch:
error: the SSL certificate is invalid: 0x08 - The certificate is not correctly signed by the trusted CA
error: the SSL certificate is invalid: 0x08 - The certificate is not correctly signed by the trusted CA
error: recieved error: GitClone while getting dep: https://github.com/alexnask/iguanaTLS.git:0d39a361639ad5469f8e4dcdaea35446bbe54b48:src/main.zig
error: recieved error: GitClone while getting dep: https://github.com/MasterQ32/zig-network.git:b9c91769d8ebd626c8e45b2abb05cbc28ccc50da:network.zig

zigcord on ๎‚  main [?] via โ†ฏ v0.9.0-dev.1656+dcd88ae56 took 8s
โฏ

Anyways, about the previous issue, I'm currently using a prebuilt version until the upstream LD issue was fixed.

Incorrect escaping of build-dep

You can see the error in the highlighting of deps.zig below.

gyro.zzz

deps:
  raylib:
    git:
      url: "https://github.com/not-nik/raylib-zig.git"
      ref: 85f1b5b8e105045db555684ac0ce920e3f1ee9d7
      root: lib.zig
build_deps:
  raylibBuild:
    git:
      url: "https://github.com/not-nik/raylib-zig.git"
      ref: 85f1b5b8e105045db555684ac0ce920e3f1ee9d7
      root: build.zig

deps.zig

const std = @import("std");
const Pkg = std.build.Pkg;
const FileSource = std.build.FileSource;

pub const build_pkgs = struct {
    pub const raylibBuild = @import(".gyro\raylib-zig-not-nik-github.com-85f1b5b8\pkg\build.zig");
};

pub const pkgs = struct {
    pub const raylib = Pkg{
        .name = "raylib",
        .source = FileSource{
            .path = ".gyro\\raylib-zig-not-nik-github.com-85f1b5b8\\pkg\\lib.zig",
        },
    };

    pub fn addAllTo(artifact: *std.build.LibExeObjStep) void {
        artifact.addPackage(pkgs.raylib);
    }
};

Adding a github repo as dependency fails to get manifest information

This failure causes the root field of gyro.zzz to fall back to "src/main.zig". If the package has a different root, this will cause a build failure.

I was able to trace this to the getGithubGyroFile() function in api.zig.

    // @line 266, api.zig
    var extractor = tar.fileExtractor(subpath, gzip.reader());
    return extractor.reader().readAllAlloc(allocator, std.math.maxInt(usize)) catch |err| {

In this case readAllAlloc is consistently returning error.FileNotFound. I believe the http transactions are succeeding based on verifying that a 200 code was returned, so it is unclear what is causing FileNotFound.

documentation missing -g flag for github repo

While testing adding my lib with gyro, i initially tried gyro add travisstaloch/art.zigafter reading the documentation here.

else if you want to use a Github repository as a dependency then all thatโ€™s required is gyro add <user>/<repo>.

This needs the -g flag: gyro add <user>/<repo> -g

I didn't find a documentation repo. Let me know where the repo is if you'd like a pr.

Initialization returns 403 error

Hi!

Just tried to add gyro support to a library I made.

System info

OS: ArchLinux with 5.16.12 kernel
Zig: 0.9.0
gyro: 0.5.0 from AUR

Problem

Ran the command gyro init Sup3Legacy/zgit

Expected result

Successful initialization

Actual result

error: http status code: 403
???:?:?: 0x2aad8a in ??? (???)
???:?:?: 0x2aaefd in ??? (???)
???:?:?: 0x29dc21 in ??? (???)
???:?:?: 0x29d90d in ??? (???)
???:?:?: 0x29eaee in ??? (???)

2 digit semver number causes crashes when fetching package

Here's the output when trying to fetch my zheets library version 0.1.10:

โฏ gyro build
git github.com/beho/zig-csv                                                                                 f9bff064 [##################################################################################] 100%
git github.com/devins2518/requestz                                                                          da32d03a [##################################################################################] 100%
pkg astrolabe.pm/devins2518/zheets                                                                          0.1.10   [##################################################################################] 100% ERROR
error: http status code: 404
???:?:?: 0x10081905b in _Engine.fetch (???)
???:?:?: 0x10081a2e7 in _Engine.fetch (???)
???:?:?: 0x1008112cf in _commands.build (???)
???:?:?: 0x1007dd353 in _main.0 (???)
???:?:?: 0x1007dd35b in _main.0 (???)
???:?:?: 0x1007de507 in _main.0 (???)

Works fine when I bumped the version to 0.2.0

Gyro not building with zig `0.10.0`

Gyro doesn't build currently on macOS using zig 0.10.0 even though it's listed as the supported version on the readme.

zig-macos-aarch64-0.10.0/lib/std/build.zig:2314:31: error: deprecated; use addIncludePath
    pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

zig add github_user/repo

Loris had a good idea that a user should be able to zkg add some_user/repo and it should add the head of the master/main branch of whatever repo

cannot publish

With latest gyro built from source with fix from #181 using stage2, passing -fstage1 works fine

Release-Safe:

$ gyro publish
thread 31213 panic: incorrect alignment
[1]    31213 IOT instruction (core dumped)  gyro publish

Debug:

$ gyro publish
Opening in existing browser session.
enter this code: 570A-2EDE
waiting for github authentication...
Segmentation fault at address 0x0
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/mem.zig:1307:5: 0x4578c4 in readIntNative__anon_31398 (gyro)
    return @ptrCast(*align(1) const T, bytes).*;
    ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash/wyhash.zig:14:29: 0x527802 in read_bytes__anon_53905 (gyro)
    return mem.readIntLittle(T, data[0..bytes]);
                            ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash/wyhash.zig:53:23: 0x4ed792 in hash (gyro)
            read_bytes(8, b[0..]),
                      ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash/wyhash.zig:170:36: 0x49f2dc in hash (gyro)
        return WyhashStateless.hash(seed, input);
                                   ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash_map.zig:92:32: 0x4ba576 in hashString (gyro)
    return std.hash.Wyhash.hash(0, s);
                               ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash_map.zig:79:26: 0x4ba54c in hash (gyro)
        return hashString(s);
                         ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash_map.zig:1123:34: 0x521c2f in getEntryAdapted__anon_52804 (gyro)
            comptime verifyContext(@TypeOf(ctx), @TypeOf(key), K, Hash, false);
                                 ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash_map.zig:1166:40: 0x4e1932 in getEntryContext (gyro)
        }
                                       ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/hash_map.zig:609:50: 0x47e195 in getEntry (gyro)
        pub fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K {
                                                 ^
/home/lee/src/gyro/src/Project.zig:203:38: 0x423cae in get (gyro)
    return if (self.packages.getEntry(name)) |entry| &entry.value_ptr.* else null;
                                     ^
/home/lee/src/gyro/src/commands.zig:930:71: 0x4190b7 in publish (gyro)
    api.postPublish(allocator, repository, access_token.?, project.get(name).?) catch |err| switch (err) {
                                                                      ^
/home/lee/src/gyro/src/main.zig:283:21: 0x417273 in run__anon_27485 (gyro)
                if (res.positionals.len > 0) res.positionals[0] else null,
                    ^
/home/lee/src/gyro/src/main.zig:144:24: 0x42835e in runCommands (gyro)
            try cmd.run(allocator, &args, &iter);
                       ^
/home/lee/src/gyro/src/main.zig:61:20: 0x429412 in main (gyro)
        runCommands(allocator) catch |err| {
                   ^
/home/lee/zig/0.10.0-dev.4176+6d7b0690a/files/lib/std/start.zig:578:37: 0x429bf9 in main (gyro)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0xac0d6f in ??? (???)
[1]    31562 IOT instruction (core dumped)  gyro publish

support for accessing non-zig files

Hi,

I'm experimenting with gyro for my zig-sqlite package.

Users of the package have two options for the C sqlite library:

  • use the system library
  • use the bundled C source file

With submodules the user can simply use the bundled file like this:

const sqlite = b.addStaticLibrary("sqlite", null);
sqlite.addCSourceFile("third_party/zig-sqlite/sqlite3.c", &[_][]const u8{"-std=c99"});
sqlite.linkLibC();

exe.linkLibC();
exe.linkLibrary(sqlite);
exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" });

but with gyro accessing that C file is not that simple, I managed to make it work by doing this:

const pkgs = @import("gyro").pkgs;

const sqlite_source_file = blk: {
    const dir = std.fs.path.dirname(pkgs.sqlite.path).?;
    break :blk dir ++ "/sqlite3.c";
};

pub fn build(b: *Builder) void {
    const sqlite = b.addStaticLibrary("sqlite", null);
    sqlite.addCSourceFile(sqlite_source_file, &[_][]const u8{"-std=c99"});
    sqlite.linkLibC();
    sqlite.setTarget(target);
    sqlite.setBuildMode(mode);

    exe.linkLibC();
    exe.linkLibrary(sqlite);
}

it's not that bad but it would be cool if there was a way to easily access files from the package directory.

Fail to install a dependency

Hi! I am extremely new to zig and gyro. I'm probably doing something wrong.

I have a project and would like to add a dependency. I'm on Apple Silicon, so I built gyro myself.

Then when I ran the below command, it reached unreachable code.

I'm not sure I followed the instructions correctly, this is the first command I ran with gyro because in my understanding the rest of the guide was geared towards publishing rather than consuming a library.

I'd be happy to get some help on this!

gyro add --src github Iridescence-Technologies/zglfw                                   โœ˜ ABRT 20:45:08
thread 1549202 panic: reached unreachable code
/opt/homebrew/Cellar/zig/HEAD-0cecdca_1/lib/zig/std/os.zig:3395:22: 0x10494a13b in std.os.connect (gyro)
            EBADF => unreachable, // sockfd is not a valid open file descriptor.
                     ^
/Users/mark/code/gyro/libs/zig-network/network.zig:345:47: 0x104947fd7 in .zfetch.network.Socket.connect (gyro)
            .ipv4 => |sockaddr| try connect_fn(self.internal, @ptrCast(*const std.os.sockaddr, &sockaddr), @sizeOf(@TypeOf(sockaddr))),
                                              ^
/Users/mark/code/gyro/libs/zig-network/network.zig:937:21: 0x104946fd3 in .zfetch.network.connectToHost (gyro)
        sock.connect(endpt) catch {
                    ^
/Users/mark/code/gyro/libs/zfetch/src/connection.zig:75:50: 0x10494527b in .zfetch.connection.Connection.connect (gyro)
            .network => try network.connectToHost(allocator, host_dupe, real_port, .tcp),
                                                 ^
/Users/mark/code/gyro/libs/zfetch/src/request.zig:124:44: 0x104944177 in .zfetch.request.Request.init (gyro)
        req.socket = try Connection.connect(allocator, uri.host.?, uri.port, protocol, trust);
                                           ^
/Users/mark/code/gyro/src/api.zig:396:42: 0x10493ac83 in api.request (gyro)
        var ret = try zfetch.Request.init(allocator, real_url, null);
                                         ^
/Users/mark/code/gyro/src/api.zig:200:26: 0x1049383b3 in api.getGithubRepo (gyro)
    var req = try request(allocator, .GET, url, &headers, null);
                         ^
/Users/mark/code/gyro/src/commands.zig:472:55: 0x104985e2b in commands.add (gyro)
                var value_tree = try api.getGithubRepo(&arena.allocator, info.user, info.repo);
                                                      ^
/Users/mark/code/gyro/src/main.zig:166:25: 0x1049286f3 in add.run (gyro)
            try cmds.add(
                        ^
/Users/mark/code/gyro/src/main.zig:88:31: 0x104922f5f in runCommands (gyro)
            try cmd.parent.run(allocator, &args, &iter);
                              ^
/Users/mark/code/gyro/src/main.zig:19:16: 0x1049218ef in main (gyro)
    runCommands(allocator) catch |err| {
               ^
/opt/homebrew/Cellar/zig/HEAD-0cecdca_1/lib/zig/std/start.zig:515:37: 0x104a79a57 in std.start.callMain (gyro)
            const result = root.main() catch |err| {
                                    ^
/opt/homebrew/Cellar/zig/HEAD-0cecdca_1/lib/zig/std/start.zig:457:12: 0x104924b5b in std.start.callMainWithArgs (gyro)
    return @call(.{ .modifier = .always_inline }, callMain, .{});
           ^
/opt/homebrew/Cellar/zig/HEAD-0cecdca_1/lib/zig/std/start.zig:422:12: 0x104924a8b in std.start.main (gyro)
    return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp });
           ^
???:?:?: 0x104e6d0f3 in ??? (???)
???:?:?: 0x3f43ffffffffffff in ??? (???)
fish: Job 1, 'gyro add --src github Iridescenโ€ฆ' terminated by signal SIGABRT (Abort)

Can't download libraries with CLRF and can't build

When i try to run gyro build, i got a weired error without information/stack call trace:

Unable to dump stack trace: FileNotFound

So, i tried to manually download dependencies and run zig build run, but, i get other weired error:

logs captured during fetch:
error: gyro.zzz requires LF line endings, not CRLF
error: recieved error: Explained while getting dep: https://github.com/alexnask/iguanaTLS.git:0d39a361639ad5469f8e4dcdaea35446bbe54b48:src/main.zig

Doesn't build with zig 0.9

  1. c_void got renamed but it exists in some files and dependencies still. easy to fix by zig fmt every file
src/git.zig:221:73: error: use of undeclared identifier 'c_void'
fn submoduleCb(sm: ?*c.git_submodule, sm_name: [*c]const u8, payload: ?*c_void) callconv(.C) c_int {
  1. There seems to be some breaking change involving if allocators should be references or not. But I didn't find anything in the 0.9 change log.
./src/main.zig:38:36: error: expected type '*std.mem.Allocator', found 'std.mem.Allocator'
        try Display.init(&display, allocator);
                                   ^

https://ziglang.org/download/0.9.0/release-notes.html

Managing C dependencies with gyro

I believe it would be very handy for gyro to have the ability to handle C libraries in the form of git repositories.

I think a very elegant solution would be, to be able to specify a URL for a C git repository in gyro.zzz, and to have a path to the place gyro cloned it end up in deps.zig, so the build script can manage the C dependency itself.

[Error at Build] Memory leak detected

Hello, I'm trying to build gyro from master (90af164) using also zig from master (0.8.0-dev.1860+1fada3746) and I've had this happen while building gyro with gyro bootstrapped. I'm pretty sure it happened because I'm using zig from master, so I'll just the release instead. Just wanted to give you guys a heads up that it might break gyro in future updates.

Also, what's the supported zig version to build gyro?

Add an example of tarball source to the README

Unless I'm misunderstanding, it looks like this commit added the ability to source libraries from downloading a tarball over http instead of git. ff20311

It's not documented though. There should be an example doing this in the documentation along with any other supported source types.

(If that's not what the commit does -- the ability to source a library from a tarball at an arbitrary https URL would be really nice!)

error: Unreachable code on gyro fetch

It appears that gyro fetch does not wait for certain github submodules to download and hits unreachable code.

zig version

0.9.0-dev.1815+20e19e75f

[linuxy@void zsaga]$ gyro fetch
Segmentation fault at address 0x0
???:?:?: 0x282918 in ??? (???)
src/thread/pthread_create.c:195:2: 0x7fb54676d8cd in start (src/thread/pthread_create.c)
Aborted

[linuxy@void zsaga]$ gyro fetch
git github.com/fengb/wz d0f9221c [ ] 0% thread 1023 panic: reached unreachable code
Aborted

gyro.zzz

deps:
  zCord:
    git:
      url: "https://github.com/fengb/zCord.git"
      ref: master
      root: src/main.zig

build.zig

const Builder = @import("std").build.Builder;
const pkgs = @import("deps.zig").pkgs;

pub fn build(b: *Builder) void {
    const mode = b.standardReleaseOptions();

    const exe = b.addExecutable("main", "src/main.zig");
    exe.setBuildMode(mode);
    pkgs.addAllTo(exe);
    exe.install();

    const run_cmd = exe.run();
    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);
}

[Error] Bootstrapping gives `expected type '[]const u8', found '[email protected]:8:14'` on Zig 0.8.1

Before I start: Yes, I checked this out recursively. I suspect if I didn't I'd still hit this error before the obvious problem happens.

Here's the compile error I get:

$ zig build -Drelease-safe
./build.zig:71:20: error: expected type '[]const u8', found '[email protected]:8:14'
    lib.addPackage(clap);
                   ^
./build.zig:8:14: note: [email protected]:8:14 declared here
    .path = .{ .path = "libs/zig-clap/clap.zig" },
             ^

Commenting out that line gives a different error:

$ zig build -Drelease-safe
./build.zig:55:24: error: no member named 'path' in '[]const u8'
            .path = .{ .path = "libs/mecha/mecha.zig" },
                       ^
./build.zig:72:20: note: referenced here
    lib.addPackage(version);
                   ^

... I think I've somehow rubber-ducked what the fix will be, if I'm right in that then I'll have a PR for this.

EDIT: Yep, got the fix:

sed -i -e 's/\.{ \.path = \(".*"\) }/\1/g' build.zig

And now there's issues with specific dependencies not supporting Zig 0.8.1. But this should fix gyro itself.

Crash caused by a misplaced "root" element in gyro.zzz

When packaging requestz for gyro, I needed to add a dependency to MasterQ32/zig-network github repository.

If I understand correctly, gyro expect that the root file is located at src/main.zig but in the case of zig-network, the root file is network.zig.

I just tried the following gyro.zzz

pkgs:
  requestz:
    version: 0.1.0
    root: src/main.zig
    description: HTTP client for Zig ๐ŸฆŽ
    license: 0BSD
    source_url: "https://github.com/ducdetronquito/requestz"
    tags: http
deps:
  network:
    src:
      root: network.zig
      github:
        user: MasterQ32
        repo: zig-network
        ref: b9c91769d8ebd626c8e45b2abb05cbc28ccc50da

and it led to the following crash:

C:\Users\DEV\Documents\Code\requestz (feature/packaged-for-gyro)
ฮป gyro build test
error: InvalidSrcTag
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Users\DEV\Documents\Code\gyro\libs\mecha\src\utf8.zig:25:17: 0x7ff7701c1e0b in .version.mecha.src.utf8.wrap(.version.mecha.src.utf8.range(126,126).pred)::.version.mecha.src.utf8.wrap(.version.mecha.src.utf8.range(126,126).pred).func (gyro.obj)
                return error.ParserFailed;
                ^
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Users\DEV\Documents\Code\gyro\libs\mecha\src\utf8.zig:25:17: 0x7ff7701c1e0b in .version.mecha.src.utf8.wrap(.version.mecha.src.utf8.range(126,126).pred)::.version.mecha.src.utf8.wrap(.version.mecha.src.utf8.range(126,126).pred).func (gyro.obj)
                return error.ParserFailed;
                ^
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Program Files (x86)\Zig\master_19_08_2021\lib\std\fmt.zig:1765:17: 0x7ff77023063d in std.fmt.charToDigit (gyro.obj)
        else => return error.InvalidCharacter,
                ^
C:\Users\DEV\Documents\Code\gyro\src\Dependency.zig:213:16: 0x7ff7701bd41b in Dependency.fromZNode (gyro.obj)
        } else return error.InvalidSrcTag;
               ^
C:\Users\DEV\Documents\Code\gyro\src\Project.zig:124:25: 0x7ff7701b83c3 in Project.fromText (gyro.obj)
            const dep = try Dependency.fromZNode(allocator, dep_node);
                        ^
C:\Users\DEV\Documents\Code\gyro\src\Project.zig:155:5: 0x7ff7701b6d47 in Project.fromFile (gyro.obj)
    return fromText(allocator, try file.reader().readAllAlloc(allocator, std.math.maxInt(usize)));
    ^
C:\Users\DEV\Documents\Code\gyro\src\commands.zig:57:19: 0x7ff7701d1637 in commands.fetchImpl (gyro.obj)
    var project = try Project.fromFile(allocator, project_file);
                  ^
C:\Users\DEV\Documents\Code\gyro\src\commands.zig:117:15: 0x7ff7701cf9c6 in commands.build (gyro.obj)
    var ctx = try fetchImpl(allocator);
              ^
C:\Users\DEV\Documents\Code\gyro\src\main.zig:211:13: 0x7ff770157c65 in build::build.run (gyro.obj)
            try cmds.build(allocator, iterator);
            ^
C:\Users\DEV\Documents\Code\gyro\src\main.zig:88:13: 0x7ff77015309f in runCommands (gyro.obj)
            try cmd.parent.run(allocator, &args, &iter);
            ^
C:\Users\DEV\Documents\Code\gyro\src\main.zig:22:21: 0x7ff7701257fc in main (gyro.obj)
            else => return err,

I finally made it work by placing the "root" element in the correct position:

pkgs:
  requestz:
    version: 0.1.0
    root: src/main.zig
    description: HTTP client for Zig ๐ŸฆŽ
    license: 0BSD
    source_url: "https://github.com/ducdetronquito/requestz"
    tags: http
deps:
  network:
    root: network.zig
    src:
      github:
        user: MasterQ32
        repo: zig-network
        ref: b9c91769d8ebd626c8e45b2abb05cbc28ccc50da

Network connection unstability leads to out of memory error.

I was downloading a large file at the same time I tried adding a package. The unstability in my network caused (somehow) a out of memory error.

umaru% gyro add --src github jojolepro/zig-benchmark
error: TemporaryNameServerFailure
/usr/lib/zig/std/heap/general_purpose_allocator.zig:730:13: 0x2ed4bd in std.heap.general_purpose_allocator.GeneralPurposeAllocator((struct std.heap.general_purpose_allocator.Config constant)).resize (gyro)
            return error.OutOfMemory;
            ^
/usr/lib/zig/std/mem/Allocator.zig:315:16: 0x3e5ec6 in std.mem.Allocator.resize (gyro)
    const rc = try self.resizeFn(self, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress());
               ^
/usr/lib/zig/std/heap/general_purpose_allocator.zig:730:13: 0x2ed4bd in std.heap.general_purpose_allocator.GeneralPurposeAllocator((struct std.heap.general_purpose_allocator.Config constant)).resize (gyro)
            return error.OutOfMemory;
            ^
/usr/lib/zig/std/mem/Allocator.zig:315:16: 0x3e5ec6 in std.mem.Allocator.resize (gyro)
    const rc = try self.resizeFn(self, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress());
               ^
/usr/lib/zig/std/net.zig:224:17: 0x31166f in std.net.Ip4Address.parse (gyro)
                return error.InvalidCharacter;
                ^
/usr/lib/zig/std/net.zig:92:31: 0x31b1fb in std.net.Address.parseIp4 (gyro)
        return Address{ .in = try Ip4Address.parse(buf, port) };
                              ^
/usr/lib/zig/std/fmt.zig:1678:25: 0x31b95a in std.fmt.charToDigit (gyro)
    if (value >= radix) return error.InvalidCharacter;
                        ^
/usr/lib/zig/std/net.zig:371:31: 0x311ce5 in std.net.Ip6Address.parse (gyro)
                const digit = try std.fmt.charToDigit(c, 16);
                              ^
/usr/lib/zig/std/net.zig:84:32: 0x31b2b2 in std.net.Address.parseIp6 (gyro)
        return Address{ .in6 = try Ip6Address.parse(buf, port) };
                               ^
/usr/lib/zig/std/net.zig:49:9: 0x31b49f in std.net.Address.parseIp (gyro)
        return error.InvalidIPAddressFormat;
        ^
/usr/lib/zig/std/net.zig:78:29: 0x310358 in std.net.Address.parseExpectingFamily (gyro)
            os.AF_UNSPEC => return parseIp(name, port),
                            ^
/usr/lib/zig/std/io/reader.zig:217:31: 0x31cbbd in std.io.reader.Reader(*std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)),std.os.ReadError,std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)).read).readByte (gyro)
            if (amt_read < 1) return error.EndOfStream;
                              ^
/usr/lib/zig/std/io/reader.zig:217:31: 0x31cbbd in std.io.reader.Reader(*std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)),std.os.ReadError,std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)).read).readByte (gyro)
            if (amt_read < 1) return error.EndOfStream;
                              ^
/usr/lib/zig/std/net.zig:1533:21: 0x324b9c in std.net.dnsParse (gyro)
    if (r.len < 12) return error.InvalidDnsPacket;
                    ^
/usr/lib/zig/std/net.zig:1533:21: 0x324b9c in std.net.dnsParse (gyro)
    if (r.len < 12) return error.InvalidDnsPacket;
                    ^
/usr/lib/zig/std/net.zig:1272:48: 0x31e169 in std.net.linuxLookupNameFromDns (gyro)
    if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;
                                               ^
/usr/lib/zig/std/net.zig:1216:5: 0x3111f8 in std.net.linuxLookupNameFromDnsSearch (gyro)
    return linuxLookupNameFromDns(addrs, canon, name, family, rc, port);
    ^
/usr/lib/zig/std/net.zig:844:17: 0x30edb7 in std.net.linuxLookupName (gyro)
                try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
                ^
/usr/lib/zig/std/net.zig:795:9: 0x30e18c in std.net.getAddressList (gyro)
        try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);
        ^
/shareddata/share/prog/zig/gyro/.gyro/network-mattnite-0.0.1-56b1687581a638461a2847c093576538/pkg/network.zig:1046:30: 0x30d551 in .zfetch.network.getEndpointList (gyro)
        const address_list = try std.net.getAddressList(allocator, name, port);
                             ^
/shareddata/share/prog/zig/gyro/.gyro/network-mattnite-0.0.1-56b1687581a638461a2847c093576538/pkg/network.zig:927:27: 0x30ce8a in .zfetch.network.connectToHost (gyro)
    const endpoint_list = try getEndpointList(allocator, name, port);
                          ^
/shareddata/share/prog/zig/gyro/.gyro/zfetch-truemedian-0.1.1-b59569787870ac634a4bcad87771a519/pkg/src/connection.zig:65:13: 0x30b461 in .zfetch.connection.Connection.connect (gyro)
            try network.connectToHost(allocator, host_dupe, real_port, .tcp);
            ^
/shareddata/share/prog/zig/gyro/.gyro/zfetch-truemedian-0.1.1-b59569787870ac634a4bcad87771a519/pkg/src/request.zig:124:22: 0x309d22 in .zfetch.request.Request.init (gyro)
        req.socket = try Connection.connect(allocator, uri.host.?, uri.port, protocol, trust);
                     ^
/shareddata/share/prog/zig/gyro/src/api.zig:399:19: 0x3020e2 in api.request (gyro)
        var ret = try zfetch.Request.init(allocator, real_url, null);
                  ^
/shareddata/share/prog/zig/gyro/src/api.zig:203:15: 0x2ffc59 in api.getGithubRepo (gyro)
    var req = try request(allocator, .GET, url, &headers, null);
              ^
/shareddata/share/prog/zig/gyro/src/commands.zig:472:34: 0x36dc81 in commands.add (gyro)
                var value_tree = try api.getGithubRepo(&arena.allocator, info.user, info.repo);
                                 ^
/shareddata/share/prog/zig/gyro/src/main.zig:166:13: 0x2f2828 in add.run (gyro)
            try cmds.add(
            ^
/shareddata/share/prog/zig/gyro/src/main.zig:88:13: 0x2ee173 in runCommands (gyro)
            try cmd.parent.run(allocator, &args, &iter);
            ^
/shareddata/share/prog/zig/gyro/src/main.zig:22:21: 0x2e56f9 in main (gyro)
            else => return err,
                    ^
umaru% gyro add --src github jojolepro/zig-benchmark
info: fetching tarball: https://api.github.com/repos/jojolepro/zig-benchmark/tarball/aed36b3d032955c18a7173e9fb7b7dfc2f38425e

Support per-package dependencies/same repo dependencies

Currently, there's no good way to have multiple mutually dependent packages in the same repo. At present, all packages depend on the same list of dependencies, so if you depend on a library in one package it will also be exported depending on itself and any other libraries that it may or may not need.

[Error] If package has system libraries as deps Segfault will appear

I have this package tree:

LinkSystemLibrary("c").........] --- a--b--final
LinkSystemLibrary("glfw")....]

As you can see first library depends on system libs, and the second one on the first one.
Final package will be created by users which want to use my "b" package.
But the problem is final package cannot be run unless user manually link system libraries in final/build.zig
What's worse, there is no error when building final package. Only SegFault when it is runned.
Will there be any feature that's automatically adds system libraries to deps.zig or something similar?

Tracking master

Gyro follows the master branch of the zig compiler, but the master branch of zig-clap does not work with zig master, we should use the zig-master branch instead.

Unable to publish: error: TemporaryNameServerFailure

I'm having trouble trying to update my zig-nestedtext project - I previously managed to publish with gyro publish, but this is now giving me 'TemporaryNameServerFailure'.

I've played around a bit and I get the same error when running gyro build in a clone of the repo (after the zig bootstrap build). I am able to ping astrolabe.pm (disconnecting from my VPN and restarting WSL made no difference). I'm using WSL1, where this did previously work.

$gyro publish
error(gpa): Memory leak detected:


error: TemporaryNameServerFailure
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:0:0: 0x27e18d in std.net.getAddressList (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:0:0: 0x27e195 in std.net.getAddressList (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:84: 0x27e35d in std.net.getAddressList (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:84: 0x278220 in .zfetch.request.Request.init (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:84: 0x278228 in .zfetch.request.Request.init (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:84: 0x278240 in .zfetch.request.Request.init (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:39: 0x2782d7 in .zfetch.request.Request.init (gyro)
/home/runner/work/gyro/gyro/src/api.zig:0:29: 0x2736b8 in api.request (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/mem/Allocator.zig:0:79: 0x26e431 in commands.publish (gyro)
/home/runner/work/gyro/gyro/src/commands.zig:0:0: 0x26fc94 in commands.publish (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/heap/arena_allocator.zig:0:16: 0x258d91 in runCommands (gyro)
/home/runner/work/gyro/gyro/src/main.zig:88:21: 0x244ac2 in std.start.posixCallMainAndExit (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:91:51: 0x28d84b in std.net.linuxLookupNameFromNumericUnspec (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:91:31: 0x28d966 in std.net.linuxLookupNameFromNumericUnspec (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:91:51: 0x28d84b in std.net.linuxLookupNameFromNumericUnspec (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:91:31: 0x28d966 in std.net.linuxLookupNameFromNumericUnspec (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/io/reader.zig:181:43: 0x28b07a in std.io.reader.Reader(*std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)),std.os.ReadError,std.io.buffered_reader.BufferedReader(4096,std.io.reader.Reader(std.fs.file.File,std.os.ReadError,std.fs.file.File.read)).read).readUntilDelimiterOrEof (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c2c1 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c2c1 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c321 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c321 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1476:28: 0x28c4bd in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1476:28: 0x28c4bd in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c2c1 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c2c1 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c321 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1457:42: 0x28c321 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1476:28: 0x28c4bd in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1476:28: 0x28c4bd in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:0:5: 0x28cdd8 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:0:5: 0x28cdd8 in std.net.linuxLookupNameFromDns (gyro)
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.8.0-dev.1806+ecd38c70c/x64/lib/std/net.zig:1271:48: 0x28d794 in std.net.linuxLookupNameFromDns (gyro)

Any ideas what might have changed, or is there a workaround to publish to astrolabe?

Package Windows Release as ZIP

Currently windows releases of zkg are released as an xz compressed tarball, which is very painful to decompress and unpack on windows (and near impossible programmatically, even with PowerShell). My suggestion is to package these releases as a zip archive, which can be very easily unpacked on windows.

local srcs create "ok" files

empty files named "ok" are created after gyro runs. not sure if its after gyro build, gyro update, or gyro fetch. but it only seems to happen with local srcs.

Support for 7.1

What is the latest supported ziglang version. im faceing with many errors when i use 7.1

bug building a dep with a dep

To fail:

zig add wz
zig fetch

add the usual incantation to your build.zig:

    inline for (std.meta.fields(@TypeOf(pkgs))) |field| {
        exe.addPackage(@field(pkgs, field.name));
    }

then
zig build
and you get

$ zig build
./build.zig:21:24: error: expected type '[]const std.build.Pkg', found '[email protected]:5:26'
        exe.addPackage(@field(pkgs, field.name));
                       ^
./deps.zig:5:26: note: [email protected]:5:26 declared here
        .dependencies = .{

This can be fixed by changing the deps.zig to explicitly type .dependencies by doing something like:

const Pkg = @import("std").build.Pkg;
pub const pkgs = .{
  ...
           .dependencies = &[_]Pkg{
  ...

...all credit to @mattnite for chatting on me with discord and leading me to how to manually fix it.

[Error] gyro is not able to find and initialize private repositories

I tried to create a gyro manifest for a project that I am working on. Currently, I have the source stored in a private repository on GitHub. When running

gyro init haze/top_secret_super_secret_dont_share

I am met with this:

got http status code for https://api.github.com/repos/haze/top_secret_super_secret_dont_share: 404{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}

Publish error Device Flow Disabled

When I run gyro publish a page to enter a code is opened in my browser but in the terminal I get the following error:

logs captured during fetch:
error: http status code: 400
error: {"error":"device_flow_disabled","error_description":"Device Flow must be explicitly enabled for this App","error_uri":"https://docs.github.com"}

I run on Windows 11 and my gyro.zzz file is this:

pkgs:
  nanoid:
    version: 1.0.0
    description: "A battle-tested, tiny, secure, URL-friendly, unique string ID generator. Now available in pure Zig."
    license: MIT
    source_url: "https://github.com/SasLuca/zig-nanoid"
    tags:
      url
      uuid
      random
      id
      unique-id
      unique-identifier
      uuid-generator
      unique-id
      nanoid
    root: src/nanoid.zig
    files:
      README.md
      LICENSE

gyro allows adding the same repo twice

i accidentally added my repo twice:

$ gyro add travisstaloch/art.zig -g

This resulted in this error:

$ gyro build run
./deps.zig:8:9: error: redefinition of 'art'
    pub const art = std.build.Pkg{

Not sure what should happen here. Maybe just show an error saying the repo already exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.