Error: Failed to run compactc

Hi guys
I’m currently running nixOS on my computer and the command compact compile doesn’t work out of the box after installing compact from :

curl --proto ‘=https’ --tlsv1.2 -LsSf ``https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh`` | sh

compact 0.25.0 is currently installed

$ compact check
compact: x86_64-unknown-linux-musl – Up to date – 0.25.0

I’m getting this error:

$compact compile --help
Error: Failed to run compactc
Caused by: 
0: Failed to spawn compactc command 
1: No such file or directory (os error 2)

I’m looking for a fix, so any help is welcome. :slight_smile:

Thanks

1 Like

It sounds like the installed compactc binary is not compatible with nixOS, maybe some missing library which was dynamically linked, I’m guessing only since I don’t use nixOS.

1 Like

compactc is not executable on my terminal, I wonder if it’s normal.
meanwhile:
/home/hk/.compact/bin/compactc
/home/hk/.compact/versions/0.25.0/x86_64-unknown-linux-musl/compactc
/home/hk/.compact/versions/0.25.0/x86_64-unknown-linux-musl/compactc.bin

Does compactc –-help return something on your side?

1 Like

Yes, I’m able to run this and it returns the help menu:

$ ~/.compact/versions/0.25.0/x86_64-unknown-linux-musl/compactc --help

I just noticed the compactc is a script which just executes the compactc.bin:

#!/bin/bash
thisdir="$(cd $(dirname $0) ; pwd -P)"
PATH="$thisdir:$PATH"
exec "$thisdir/compactc.bin" "$@"

Perhaps you are having an issue related to this: Add /bin/bash to avoid unnecessary pain - Development - NixOS Discourse

Not sure, but perhaps you can just edit compactc and change #!/bin/bash to #!/usr/bin/env bash ?.. just guessing …

3 Likes

Yes, it was the issue!

Adding #!/usr/bin/env bash as the first line of the compactc bash file in ~/.compact/versions/0.25.0/x86_64-unknown-linux-musl resolved the issue.

Thank you!

4 Likes

Hello,

I encountered the same issue after updating to version 0.26.
I opened an issue on the Midnight network Compact repository.

2 Likes

ohh wonderful.. thats been an issue for me as well but I was concerned it was my new mac os 26, and I just kinda gave up and took a breather.. This forum has been most useful..

2 Likes

Hi I have the same issue however when I changed the `bin/bash` to usr/bin/env bash, the `compact compile –help ` command doesn’t work it returns failed to run compactc caused by 0:failed to spawn compactc command 1: Exec format error (os error 8) however when I run ./compactc –help it works. Why does this happen?

1 Like

Hello,
Which version of NixOS are you using?

1 Like

Hi, :waving_hand: sorry for the late reply. I’m using version 0.26.0. I’ve been able to fix the issue, apparently the first line of my compactc file was whitespace and my #!/usr/bin/env bash was on the second line. Cleared the whitespace and that fixed it for me

2 Likes

Awesome news. Sometimes the smallest syntax errors cause the biggest headaches! Glad to hear you are unblocked.

Best of luck with your next steps in exploring Midnight!

2 Likes

Thanks man. I tried using buildFHSUserEnv too I created a shell.nix file and added curl as a targetPkg, I ran nix-shell on it and when I installed the compact compiler I still hit the same issue, an os 2 error. I understand that buildFHSUserEnv tool is used to simulate an environment that makes use of the normal Linux FHS. Did compact compile --Help fail because I didn’t specify compact and all the required packages in my buildFHSUserEnv tool? What do you think?

1 Like

Thanks for the update. Using buildFHSUserEnv was a great idea!

But even inside the FHS sandbox, the compact compile command points to hardcoded paths outside of the isolated environment. (When you leave the nix-shell, compact is still installed on the system.)

This means the ‘os 2 error’ is probably the first-line shebang issue again.

Patching this every time is annoying, but a quick bash script to automate the first-line fix would definitely be useful here.

1 Like

Have you found a solution yet?

1 Like

With the next release of the compiler, you won’t have to manually modify the bash script anymore. Standard users will be able to run the compiler without encountering errors related to that issue.

However, setting up a contained virtual dev environment is another story…

1 Like