Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when running crate2nix generate #308

Closed
C0D3-M4513R opened this issue Oct 27, 2023 · 6 comments
Closed

Panic when running crate2nix generate #308

C0D3-M4513R opened this issue Oct 27, 2023 · 6 comments

Comments

@C0D3-M4513R
Copy link

Reproduction:

  1. git clone https://github.com/C0D3-M4513R/DexProtectOscRS.git
  2. cd DexProtectOscRS
  3. RUST_BACKTRACE=1 crate2nix generate
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/render.rs:237:33
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: crate2nix::render::cfg_to_nix_expr::render
   4: <F as tera::builtins::filters::Filter>::filter
   5: tera::renderer::processor::Processor::eval_filter
   6: tera::renderer::processor::Processor::eval_expression
   7: tera::renderer::processor::Processor::render_node
   8: tera::renderer::processor::Processor::render_node
   9: tera::renderer::processor::Processor::render_node
  10: tera::renderer::processor::Processor::render_node
  11: tera::renderer::processor::Processor::render_node
  12: tera::renderer::processor::Processor::render
  13: tera::renderer::Renderer::render
  14: tera::tera::Tera::render
  15: crate2nix::render::Template<C>::write_to_file
  16: crate2nix::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@savannidgerinel
Copy link

I am also seeing this. In my case, I'm generating Cargo.nix from a workspace Cargo.toml and Cargo.lock file. The problem still occurs even when I filter down to just a single project in my workspace. Here's my repo, with a flake and a Cargo.toml: savanni/monorepo - monorepo - gitea: Gitea Service

I don't have a previous Cargo.nix, as I've been using cargo and shell scripts recently.

@kolloch
Copy link
Collaborator

kolloch commented Nov 3, 2023

Do you have the most recent crate2nix?

I cannot reproduce with the version from master

~/thirdparty/DexProtectOscRS main                                                                        23:18:09
❯ nix run github:nix-community/crate2nix -- generate
Generated ./Cargo.nix successfully.

(but I run into other problems that I will not debug right now on Mac Os at least)

/nix/store/6hl2zviscn0y7846zd0hv6wb9aqlrmaj-rust_objc-sys-0.2.0-beta.2-lib/env: line 1: export: `-fobjc-arc-exceptions': not a valid identifier
/nix/store/6hl2zviscn0y7846zd0hv6wb9aqlrmaj-rust_objc-sys-0.2.0-beta.2-lib/env: line 1: export: `-fobjc-exceptions': not a valid identifier
/nix/store/6hl2zviscn0y7846zd0hv6wb9aqlrmaj-rust_objc-sys-0.2.0-beta.2-lib/env: line 1: export: `-fobjc-runtime': not a valid identifier
/nix/store/ncnpn13v4h7qa8i9l5bbrd52wybj1irl-stdenv-darwin/setup: line 1681: pop_var_context: head of shell_variables not a function context

@kolloch
Copy link
Collaborator

kolloch commented Nov 3, 2023

@savannidgerinel also seems to work (i.e. not panic during render) for your repo on my system...

I'll close for now... Feel very free to reopen if you can reproduce with the version from master.

@kolloch kolloch closed this as completed Nov 3, 2023
@C0D3-M4513R
Copy link
Author

Huh can confirm. It works perfectly now... wtf?

@savannidgerinel
Copy link

@savannidgerinel also seems to work (i.e. not panic during render) for your repo on my system...

I'll close for now... Feel very free to reopen if you can reproduce with the version from master.

Oh.

So, I was using the edition of crate2nix from pkgs-23.05 and mis-reading other parts of my flake.nix where I thought I was pulling crate2nix directly from here.

@kolloch
Copy link
Collaborator

kolloch commented Nov 4, 2023

No worries :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants