Skip to content

enahnce(cli/init): skip prompts automatically in non interactive environments - #15997

Merged
amrbashir merged 17 commits into
tauri-apps:devfrom
junaidmirr:dev
Sep 11, 2026
Merged

amrbashir merged 17 commits into
tauri-apps:devfrom
junaidmirr:dev

Conversation

@junaidmirr

@junaidmirr junaidmirr commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

When running the tauri init command in environments such as CI systems, automated scripts, or other situations where no interactive terminal is available, the command currently attempts to prompt the user for input. This can result in an I/O error when the prompt cannot read from standard input.

As a result, tauri init cannot be reliably used in non interactive environments unless the --ci flag is explicitly provided. While --ci provides a way to use the command without prompts, requiring it for every automated invocation is easy to overlook.

The current implementation relies on the --ci flag to disable prompts, but does not automatically determine whether standard input is connected to an interactive terminal. The --force flag is separate from this behavior and is intended only to control overwriting of an existing src-tauri directory.

Proposed change

This pull request uses Rust's standard library IsTerminal trait to detect whether standard input is connected to an interactive terminal.

When standard input is not connected to a terminal, tauri init automatically follows the same non interactive path used when --ci is provided. This prevents the command from attempting to prompt for input when there is no user available to respond, while preserving the existing behavior when an interactive terminal is available.

Explicit command line options such as --app-name, --frontend-dist, and --dev-url can still be used to override the default configuration values.

The behavior of --force is unchanged. It continues to control whether an existing src-tauri directory can be overwritten and does not affect prompting behavior.

Design consideration

This change introduces behavior based on whether the process has access to an interactive terminal. In most cases, the absence of a terminal indicates CI or automation, but standard input can also be redirected or piped for other reasons.

The goal is to avoid attempting interactive prompts when there is no user available to respond, while keeping the existing behavior unchanged for normal terminal usage.

I chose terminal detection instead of introducing another flag because it allows non interactive invocations to work without requiring users to remember an additional option.

I am open to feedback on whether detecting a non interactive terminal is the appropriate approach, or whether this behavior would be better controlled through an explicit option.

Testing

• Manually tested tauri init in a non interactive environment and verified that it completes without prompting.

• Verified that explicit command line options continue to override the default values.

• Added a regression test covering non interactive execution.

• The implementation uses Rust's standard IsTerminal API and is cross platform.

Documentation

• Updated the README with a Building from Source section explaining how to build the CLI from source.

• Documented the automatic terminal detection behavior.

• Added a changeset describing the fix for the release notes.

Overall, this makes tauri init more reliable when used in CI and automation while preserving the existing behavior for normal interactive terminal usage.

When running  in a non-interactive environment
(e.g., CI, scripts), the command still attempted to prompt for
input, resulting in an IO error. This change sets
when  is true, so that --force also skips all prompts
and uses defaults, making it safe for automation.

Fixes #<issue-number> (if applicable).
@junaidmirr
junaidmirr requested a review from a team as a code owner September 8, 2026 17:34
fixed bug
When running tauri init in a non-interactive environment (CI, scripts), the command would attempt to prompt for input and fail with an IO error because no terminal was available. This change uses std::io::IsTerminal to detect whether stdin is a real terminal. If not, it behaves as if --ci was passed, skipping all prompts and using defaults. This fixes the crash without altering the semantics of --force (which remains only for overwriting existing files). Also adds a regression test, updates the README with a new "Building from Source" section, and includes a changeset entry.
When running tauri init in a non-interactive environment (CI, scripts), the command would attempt to prompt for input and fail with an IO error because no terminal was available. This change uses std::io::IsTerminal to detect whether stdin is a real terminal. If not, it behaves as if --ci was passed, skipping all prompts and using defaults. This fixes the crash without altering the semantics of --force (which remains only for overwriting existing files). Also adds a regression test, updates the README with a new Building from Source section, and includes a changeset entry.
@junaidmirr junaidmirr changed the title fix(cli): make --force imply --ci for non-interactive init Fix CLI init to skip prompts automatically in non interactive environments Sep 9, 2026
Comment thread README.md Resolved
Comment thread init.rs Resolved
Comment thread crates/tauri-cli/src/init.rs Resolved
Comment thread .changes/cli-force-noninteractive.md Resolved
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through fd062af

There are 14 changes which include tauri-cli with minor, @tauri-apps/cli with minor, tauri with minor, tauri-build with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-macos-sign with minor, @tauri-apps/api with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

The test was incorrectly looking for the cargo-tauri binary in target/ instead of target/debug/. This caused failures on Windows where the path resolution was off by one level. Reduced the number of parent calls to two, matching the actual layout (target/debug/deps/ -> target/debug/). This works consistently across all platforms.
Comment thread crates/tauri-cli/src/init.rs Resolved
Comment thread README.md Resolved
Comment thread .changes/cli-force-noninteractive.md Resolved
style: revert unintended indentation changes in init.rs
@amrbashir

Copy link
Copy Markdown
Member

@junaidmirr you need to sign all your commits in the PR otherwise I can't merge the PR.

@junaidmirr

Copy link
Copy Markdown
Contributor Author

@junaidmirr you need to sign all your commits in the PR otherwise I can't merge the PR.

I have resigned all the commits in the PR. Thank you!

@amrbashir amrbashir changed the title Fix CLI init to skip prompts automatically in non interactive environments enahnce(cli/init): skip prompts automatically in non interactive environments Sep 11, 2026
@amrbashir
amrbashir merged commit d0f38df into tauri-apps:dev Sep 11, 2026
17 checks passed
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