Skip to content

Unable to build from source archive #150

Closed

Description

@colindean

I'm attempting to build a Homebrew formula (#95) but hitting a problem wherein the cli module's build.rs assumes that it's being run from inside a directory with git information. Looking at it, sure enough, it's trying to use git rev-parse HEAD to get the latest commit. I tried coding around it to get the basename of the current directory instead, but hit some Rust Result/Option safety stuff that exhausted the very limited time I have right now.

I think the better solution for getting build-time information is to use built, which generates some code in a module accessible at runtime for things like hash, version, etc.

Activity

  1. SaadiSave commented on Mar 22, 2023

    @SaadiSave

    Refer to #110, it's a similar issue

  2. N4tus commented on Mar 22, 2023

    @N4tus

    I had a similar issue where git rev-parse HEAD failed to run, because the folder of the repository was not considered a save directory. In this case, just rungit config --global --add safe.directory /path/of/typst
    Hope that helps someone.

  3. CGMossa commented on Mar 22, 2023

    @CGMossa
    Contributor

    Can we please have some details here? What are you people doing exactly that requires the addition of safe.directory?

  4. colindean commented on Mar 22, 2023

    @colindean
    Author

    @CGMossa Sorry, this does warrant more context.

    If you download a source archive from a release, e.g. 22-03-21-2, unpack, and cd into it, e.g.

    tag=22-03-21-2
    thedir=$(mktemp -d -t typst-test-compile)
    mkdir -p ${thedir}
    cd ${thedir}
    wget https://github.com/typst/typst/archive/refs/tags/${tag}.tar.gz
    tar xf ${tag}.tar.gz
    cd typst-${tag}
    cargo build -p typst-cli

    (which is essentially what Homebrew does when building)

    you will see

    error: failed to run custom build command for `typst-cli v0.0.0 (/private/var/folders/pg/6lxh4v9x1jvfvfnyfl1bpd900000gq/T/typst-test-compile.tMRd0tGk/typst-22-03-21-2/cli)`
    
    Caused by:
      process didn't exit successfully: `/private/var/folders/pg/6lxh4v9x1jvfvfnyfl1bpd900000gq/T/typst-test-compile.tMRd0tGk/typst-22-03-21-2/target/debug/build/typst-cli-294daf656803e0dd/build-script-build` (exit status: 101)
      --- stderr
      thread 'main' panicked at 'byte index 8 is out of bounds of ``', cli/build.rs:7:48
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    warning: build failed, waiting for other jobs to finish...
    

    I can't speak to the safe.directory thing, I think that's more likely related to a particular environment's git configuration.

  5. added a commit that references this issue on Mar 22, 2023
    5239522
  6. figsoda commented on Mar 22, 2023

    @figsoda
    Contributor
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