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

Can't use sh pipe on Arm macOS #375

Open
lorenzolewis opened this issue Mar 15, 2023 · 6 comments
Open

Can't use sh pipe on Arm macOS #375

lorenzolewis opened this issue Mar 15, 2023 · 6 comments

Comments

@lorenzolewis
Copy link
Member

curl --proto '=https' --tlsv1.2 -sSf https://create.tauri.app/sh | sh doesn't work on Arm-based macOS installs and results in this error:

image

Is this something we know what the root cause of is? I can reproduce it to help troubleshoot and fix. Related PR in docs: tauri-apps/tauri-docs@6e1deee and tauri-apps/tauri-docs#1162

@coolaj86
Copy link

coolaj86 commented Mar 15, 2023

I was able to get a little more info:

info: downloading create-tauri-app
                                  ? Project name (tauri-app) › thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Uncategorized, message: "Too many open files" }', /Users/runner/work/create-tauri-app/create-tauri-app/packages/cli/src/lib.rs:81:18
                                    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
                             sh: line 269: 55157 Abort trap: 6           "$@"
info: downloading create-tauri-app
                                  ? Project name (tauri-app) › thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Uncategorized, message: "Too many open files" }', /Users/runner/work/create-tauri-app/create-tauri-app/packages/cli/src/lib.rs:81:18
                                                                                            stack backtrace:
             0: _rust_begin_unwind
                                     1: core::panicking::panic_fmt
                                                                     2: core::result::unwrap_failed
    3: create_tauri_app::try_run
                                   4: cargo_create_tauri_app::main
                                                                  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
                                                       sh: line 269: 55634 Abort trap: 6           "$@"
info: downloading create-tauri-app
                                  ? Project name (tauri-app) › thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Uncategorized, message: "Too many open files" }', /Users/runner/work/create-tauri-app/create-tauri-app/packages/cli/src/lib.rs:81:18
                                                                                            stack backtrace:
             0:        0x10046fb84 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb33e6e8152f78c95
                                          1:        0x1004259b8 - core::fmt::write::hd33da007f7a27e39
      2:        0x100455fe4 - std::io::Write::write_fmt::h7edc10723862001e
                                                                             3:        0x100472bc0 - std::sys_common::backtrace::print::h895ee35b3f17b334
                                                          4:        0x1004729a8 - std::panicking::default_hook::{{closure}}::h3b7ee083edc2ea3e
                                               5:        0x100473138 - std::panicking::rust_panic_with_hook::h1672176227032c45
                               6:        0x100472d48 - std::panicking::begin_panic_handler::{{closure}}::h0b2d072f9624d32e
                           7:        0x100472cb8 - std::sys_common::backtrace::__rust_end_short_backtrace::he9abda779115b93c
                             8:        0x100472c94 - _rust_begin_unwind
                                                                          9:        0x100473c44 - core::panicking::panic_fmt::h23ae44661fec0889
                                               10:        0x100473eb8 - core::result::unwrap_failed::h414a6cbb12b1e143
                      11:        0x10041d4b0 - create_tauri_app::try_run::h18e9e3afe09922b3
                                                                                             12:        0x10041f708 - cargo_create_tauri_app::main::h2ff257668c93ec9e
                                                                     13:        0x10041d61c - std::sys_common::backtrace::__rust_begin_short_backtrace::hbba686bd5d62202f
                                                                         14:        0x10041fe20 - _main
     sh: line 269: 55879 Abort trap: 6           "$@"

I think the issue may be in the rust binary, not necessarily in the shell script.

@amrbashir
Copy link
Member

I don't know but maybe this section is related

# check if we have to use /dev/tty to prompt the user
local need_tty=yes
for arg in "$@"; do
OPTIND=1
if [ "${arg%%--*}" = "" ]; then
# Long option;
# don't attempt to interpret it.
continue
fi
while getopts :hy sub_arg "$arg"; do
case "$sub_arg" in
y)
# user wants to skip the prompt --
# we don't need /dev/tty
need_tty=no
;;
*)
;;
esac
done
done
if $_ansi_escapes_are_valid; then
printf "\33[1m\33[32minfo:\33[0m downloading create-tauri-app\n" 1>&2
else
printf '%s\n' 'info: downloading create-tauri-app' 1>&2
fi
ensure mkdir -p "$_dir"
ensure downloader "$_url" "$_file" "$_arch"
ensure chmod u+x "$_file"
if [ ! -x "$_file" ]; then
printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./create-tauri-app${_ext}." 1>&2
exit 1
fi
if [ "$need_tty" = "yes" ] && [ ! -t 0 ]; then
# The binary is going to want to ask for confirmation by
# reading stdin. This script was piped into `sh` though and
# doesn't have stdin to pass to its children. Instead we're going
# to explicitly connect /dev/tty to the binary's stdin.
if [ ! -t 1 ]; then
err "Unable to run interactively. Run with -y to accept defaults"
fi
ignore "$_file" "$@" < /dev/tty
else
ignore "$_file" "$@"
fi

@lorenzolewis
Copy link
Member Author

Is there a way to replicate this on a local build in any way?

@amrbashir
Copy link
Member

A dirt way is to replace $_file in these two lines with a path to the release version of a CTA (usually target/release/cargo-create-tauri-app

ignore "$_file" "$@" < /dev/tty
else
ignore "$_file" "$@"

then:
cat create-tauri-app.sh | sh should work

@lorenzolewis
Copy link
Member Author

Yup, was able to get a repro with that one @amrbashir

@lorenzolewis
Copy link
Member Author

Did a bit of digging into this and putting my notes here:

@amrbashir amrbashir changed the title Can't use secure curl with pipe on Arm macOS Can't use sh pipe on Arm macOS Mar 15, 2023
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