Skip to content

feat(cli): changes to run to work better with detached stdin (no shell)#426

Merged
tuler merged 1 commit intoprerelease/v2-alphafrom
feature/run-stdin-detached
Feb 23, 2026
Merged

feat(cli): changes to run to work better with detached stdin (no shell)#426
tuler merged 1 commit intoprerelease/v2-alphafrom
feature/run-stdin-detached

Conversation

@tuler
Copy link
Member

@tuler tuler commented Feb 20, 2026

This makes cartesi run to work better with detached stdin, by not running the shell at the end.
You can test this by running cartesi run < /dev/null.
The goal is to make run work well when it's launched from another spawn.
The application deployment had to be moved from the shell loop to before the shell is called, so it happens with this new mode.

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: f11ab86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 92.96% (🎯 0%) 726 / 781
🔵 Statements 92.96% 726 / 781
🔵 Functions 92.54% 62 / 67
🔵 Branches 0% 0 / 0
📁 File Coverage (11 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 88.68% 🟢 88.68% 🟡 75% 🔴 0% 83-85, 139-147
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/config.ts 🟢 92.63% 🟢 92.63% 🟢 94.12% 🔴 0% 65-66, 217, 226, 235, 255, ...
apps/cli/src/exec/cartesi-machine.ts 🟡 75% 🟡 75% 🟡 66.67% 🔴 0% 10-12, 28-30
apps/cli/src/exec/genext2fs.ts 🟢 96.92% 🟢 96.92% 🟢 100% 🔴 0% 87-88
apps/cli/src/exec/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/mksquashfs.ts 🟢 91.23% 🟢 91.23% 🟢 100% 🔴 0% 68-72
apps/cli/src/exec/util.ts 🟢 94.44% 🟢 94.44% 🟢 100% 🔴 0% 47-48

Copy link
Contributor

@endersonmaia endersonmaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me Anvil never gets healthy

docker inspect --format "{{json .State.Health.Log }}" my-go-dapp-anvil-1 | jq .
...
    "ExitCode": 2,
    "Output": "/usr/local/bin/eth_isready: 7: 1: parameter not set\n"
...

It was introduced when defining set -u in the eth_isready in cartesi/sdk.

An easy fix should be something like

BLOCK_NUMBER=${1:-}

if [ -n "$BLOCK_NUMBER" ]; then
...

@tuler
Copy link
Member Author

tuler commented Feb 20, 2026

for me Anvil never gets healthy

docker inspect --format "{{json .State.Health.Log }}" my-go-dapp-anvil-1 | jq .
...
    "ExitCode": 2,
    "Output": "/usr/local/bin/eth_isready: 7: 1: parameter not set\n"
...

It was introduced when defining set -u in the eth_isready in cartesi/sdk.

An easy fix should be something like

BLOCK_NUMBER=${1:-}

if [ -n "$BLOCK_NUMBER" ]; then
...

Hmm, that's for another PR right? How did it work before?

@tuler
Copy link
Member Author

tuler commented Feb 20, 2026

Maybe we should rethink how to do this better, because today docker compose is always executed in the background with --detach. But maybe in the scenario where TTY is not there, and shell is not there, it should run on foreground.

@endersonmaia
Copy link
Contributor

Hmm, that's for another PR right?

I'll send that PR.

How did it work before?

We're focusing on testing the --fork-url, and for that, it works since we have a block number.

It fails without --fork-url.

@tuler tuler force-pushed the feature/anvil-fork branch from 35b34cc to 1ac383d Compare February 22, 2026 01:42
@tuler tuler force-pushed the feature/run-stdin-detached branch from c9b9951 to 3dd477c Compare February 22, 2026 01:42
@tuler tuler force-pushed the feature/anvil-fork branch from 1ac383d to 75b6333 Compare February 22, 2026 02:17
@tuler tuler force-pushed the feature/run-stdin-detached branch from 3dd477c to 52306dd Compare February 22, 2026 02:17
Base automatically changed from feature/anvil-fork to prerelease/v2-alpha February 22, 2026 15:47
@tuler tuler force-pushed the feature/run-stdin-detached branch from 4cfa5ca to f11ab86 Compare February 23, 2026 14:55
@tuler
Copy link
Member Author

tuler commented Feb 23, 2026

Changed the code to not run compose detached if TTY is not attached

@tuler tuler requested a review from endersonmaia February 23, 2026 14:56
// stdio: "inherit",
// input: composeFile.build()
// });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was commented when migrated from YAML to TS, and compose file being passed via stdin.

When executed for the first time, it downloads on the backgound but it doesn' t gives any feedback to the user, looks like it's stuck.

We need a solution for this, but won't blok this PR for that.

@tuler tuler merged commit 4d364b7 into prerelease/v2-alpha Feb 23, 2026
4 checks passed
@tuler tuler deleted the feature/run-stdin-detached branch February 23, 2026 17:27
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

Successfully merging this pull request may close these issues.

2 participants