roc: thread '' panicked at 'cannot find `str.zig`. Check the source code in find_zig_str_path() .. in nix-darwin nixos nix

Hello -------------- MacOS (Intel nix-darwin) : https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_x86_64-2023-03-21-ceacc17.tar.gz zig installed at nix-darwin

The compiled NixOS is the same as well. macOS has been tested on the M2, and Zig was installed in the same way on all of them.

Thanks.

roc run platform-switching/rocLovesZig.roc

🔨 Rebuilding platform… An internal compiler expectation was broken. This is definitely a compiler bug. Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose thread ‘<unnamed>’ panicked at ‘cannot find str.zig. Check the source code in find_zig_str_path() to show all the paths I tried.’, crates/compiler/build/src/link.rs:90:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace thread ‘main’ panicked at ‘Failed to (re)build platform.: Any { … }’, crates/compiler/build/src/program.rs:903:46

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 28 (18 by maintainers)

Most upvoted comments

As a note, another totally reasonable solution is just to stop allowing zig platforms to depend on builtins. Then in each platform just copy the minimal amount of code to get the platform working. In most cases, I bet this is essentially the definition of RocStr with a little bit of extra changes. So manual glue, but extremely minimal. I might push a PR to do that.

EDIT: nvm, that is probably a bad idea, I forgot how complex RocStr actually is due to small, big, seamless slice, and allocations with refcounts. That sounds like a recipe for bugs and things not getting updated in all locations.

We could make a temporary zig glue that essentially copies these files into a zig platform. That would solve the problem. That said, I would much prefer to make a minimal, but proper zig glue to avoid the dependency. It also would make the structures better for platforms. The builtin versions are fine for builtins but honestly not always that good for platforms.

But yeah, simplest solution is zig glue that directly imports the builtin files and then just dumps them all to files. That glue would need to be run from the roc directory, but once glue was generated for a platform, it would be free to be built anywhere.

EDIT: also yeah, prebuilt platforms fix this to.

Or is this something that the roc cli needs to know so that it can build a zig platform from source? I guess the design is that platform authors would build these for different architectures and provides prebuilt libraries. Sorry if this just confuses this issue thread.

@bhansconnect could we have a workaround using roc glue where the spec provides a copy of the builtins in the glue directory that zig platform authors can keep and refer to locally? I assume the issue is that these zig platforms are referring to the roc builtins, and in future these will be provided by glue right? So maybe as a workaround we can do that. Downside I guess is that if major changes are made to roc builtins then the ZicSpec.roc glue file will also need to be updated. What do you think?

Yeah, same issue in a different form due to code updates. Is your roc built from source or from the nightly binary? Also, did you more the roc binary to a different folder, if so, did you move the zig libraries with it?

I am having a very similar issue, so I might as well mention it here. Whenever I try and run one of the examples using a zig-based platform I get this error on NixOS

roc run tui.roc
🔨 Rebuilding platform...
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread '<unnamed>' panicked at 'cannot find `glue.zig`. Check the source code in find_zig_glue_path() to show all the paths I tried.', crates/compiler/build/src/link.rs:116:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Failed to (re)build platform.: Any { .. }', crates/compiler/build/src/program.rs:943:46

using nix-shell I tried both zig version 0.9.1 and the latest 0.10.1 with the same result.

I am a beginner with nix-shell and coding in general.

Wow, I think you are doing really well for a beginner 😃

When I initially tried to incorporate roc into the whole setup, I encountered a file conflict with the previously added poetry2nix. … Don’t worry too much about my issue and focus on what you were doing.

I think that if I set up the flake so that it can install roc instead of via the default.nix, there will be no issue with conflicts. I should be able to do that in the next couple of weeks.

I’m a beginner, and I don’t participate in English chats because I can’t speak English.

Beginners are welcome in our chat! We even have a dedicated message stream for beginners. We’d like roc to be easy to use by people who don’t speak English. If you want to, I think google translate for websites could work well if you enter roc.zulipchat.com there.

Anyway, I’m not sure if it’s just my misconception that the first impression of the language is similar to Nix,

Similar to nix we are also a functional language and like to keep things simple and reproducible 😃

I have some trouble following what went wrong, can you make issues for the errors you encountered along with the command and the operating system that was used?

If you are using macos 13 you may encounter problems due to a bug in zig 0.9.1, although as long as you’re not building zig or wasm platforms you will likely not encounter this problem.

By the way, once this pull request is done we will be able to complete the upgrade to zig 10 and officially support it.

If you want to try out interop with other languages, these examples will be helpful:

For some questions it can be easier to talk with us on zulip chat, you’re always welcome there 😃

Oh yeah, we’re still on zig 0.9.1. We did make progress on upgrading to zig 10, I’ll ask around where we are on that. I’ll see if we can improve the error message for zig version mismatches.

I think you may need to copy over the crates folder included in the nightly archive to your project folder and run roc from the root of the project folder. If you let me know if that works for you, I will improve the error message.

Hi @PlumpMath, Can you check if the following steps work without error for you? In a directory containing the nightly tar file:

ls | grep "roc_nightly.*tar\.gz" | xargs tar -xzvf
ls | grep "roc_nightly.*tar\.gz" | xargs rm -rf
mv roc_nightly* roc_nightly
cd roc_nightly/
./roc examples/platform-switching/rocLovesZig.roc