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

Apple M1: dfx deploy failed with errors container state improper #8

Closed
johnnynanjiang opened this issue Jun 10, 2024 · 3 comments
Closed

Comments

@johnnynanjiang
Copy link

My Mac is Apple M1 Pro, MacOS Ventura 13.5. No I didn't restore or manipulate my OS.

dfx deploy
Deploying all canisters.
All canisters have already been created.
Building canisters...
Executing 'npx azle backend'

Building canister backend
Error: Command failed: podman exec azle__container__5fd100a48e4fdf8a61db8e78ab48f8c270807d89dd337b81fba5315ea333baf3 rm -rf /.azle/backend
Error: can only create exec sessions on running containers: container state improper

    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at compileRustCodeWithPodman (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code.ts:21:13)
    at compileRustCode (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code.ts:12:9)
    at compileRustCodeWithCandidAndCompilerInfo (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code_with_candid_and_compiler_info.ts:23:20)
    at getCandidAndCanisterMethods (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/get_candid_and_canister_methods.ts:38:49)
    at ???/azle-api-rest-nextjs/node_modules/azle/src/compiler/index.ts:93:76
    at time (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/utils/time.ts:10:26)
    at azle (???/azle-api-rest-nextjs/node_modules/azle/src/compiler/index.ts:66:15) {
  status: 125,
  signal: null,
  output: [
    null,
    Buffer(0) [Uint8Array] [],
    Buffer(85) [Uint8Array] [
       69, 114, 114, 111, 114,  58,  32,  99,  97, 110,  32, 111,
      110, 108, 121,  32,  99, 114, 101,  97, 116, 101,  32, 101,
      120, 101,  99,  32, 115, 101, 115, 115, 105, 111, 110, 115,
       32, 111, 110,  32, 114, 117, 110, 110, 105, 110, 103,  32,
       99, 111, 110, 116,  97, 105, 110, 101, 114, 115,  58,  32,
       99, 111, 110, 116,  97, 105, 110, 101, 114,  32, 115, 116,
       97, 116, 101,  32, 105, 109, 112, 114, 111, 112, 101, 114,
       10
    ]
  ],
  pid: 11203,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(85) [Uint8Array] [
     69, 114, 114, 111, 114,  58,  32,  99,  97, 110,  32, 111,
    110, 108, 121,  32,  99, 114, 101,  97, 116, 101,  32, 101,
    120, 101,  99,  32, 115, 101, 115, 115, 105, 111, 110, 115,
     32, 111, 110,  32, 114, 117, 110, 110, 105, 110, 103,  32,
     99, 111, 110, 116,  97, 105, 110, 101, 114, 115,  58,  32,
     99, 111, 110, 116,  97, 105, 110, 101, 114,  32, 115, 116,
     97, 116, 101,  32, 105, 109, 112, 114, 111, 112, 101, 114,
     10
  ]
}
Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build all canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (backend) with an embedded error: Failed to build custom canister backend.: Failed to run npx azle backend.: The custom tool failed.
@johnnynanjiang johnnynanjiang changed the title dfx deploy failed errors dfx deploy failed with errors Jun 10, 2024
@johnnynanjiang johnnynanjiang changed the title dfx deploy failed with errors dfx deploy failed with errors container state improper Jun 10, 2024
@johnnynanjiang
Copy link
Author

johnnynanjiang commented Jun 11, 2024

  • I followed the advice raised in Discord by @lastmjs

https://discord.com/channels/748416164832608337/956466775380336680/1249772246420033646

It kind of seems an esoteric issue with Mac that not everyone has unfortunately
An alternative is to natively compile Azle: https://demergent-labs.github.io/azle/reference_http/native_compilation.html
  • The steps I took were
1. dfx start --clean --host 127.0.0.1:8000
2. rm -rf node_modules
3. npm install
4. npx azle clean 
(1~4 as per https://demergent-labs.github.io/azle/deployment.html#common-deployment-issues)
5. the steps on the page https://demergent-labs.github.io/azle/reference_http/native_compilation.html
6. update `"build": "npx azle backend` to `"build": "npx azle backend --native-compilation",` in `dfx.json`
7. AZLE_VERBOSE=true dfx deploy
(6~7 as per https://demergent-labs.github.io/azle/deployment.html#common-deployment-issues)
  • Got the following error
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
  cargo:warning=1 error generated.
  • Full logs
AZLE_VERBOSE=true dfx deploy
Deploying all canisters.
All canisters have already been created.
Building canisters...
Executing 'npx azle backend --native-compilation'

Building canister backend
    Updating crates.io index
    Updating git repository `https://github.com/wasm-forge/ic-wasi-polyfill`
    Updating git repository `https://github.com/demergent-labs/wasmedge-quickjs`
warning: spurious network error (3 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
  Downloaded encoding_index_tests v0.1.4
  Downloaded new_debug_unreachable v1.0.6
  Downloaded function_name-proc-macro v0.3.0
  Downloaded zerofrom v0.1.4
  Downloaded function_name v0.3.0
  Downloaded ciborium-io v0.2.2
  Downloaded icu_provider_macros v1.5.0
  Downloaded write16 v1.0.0
  Downloaded yoke-derive v0.7.4
  Downloaded zerofrom-derive v0.1.4
  Downloaded candid_derive v0.6.6
  Downloaded downcast-rs v1.2.1
  Downloaded wasmi_arena v0.4.1
  Downloaded itoa v1.0.11
  Downloaded tokio-macros v1.8.2
  Downloaded utf16_iter v1.0.5
  Downloaded utf8_iter v1.0.4
  Downloaded autocfg v1.3.0
  Downloaded ciborium-ll v0.2.2
  Downloaded encoding-index-singlebyte v1.20141219.5
  Downloaded tinystr v0.7.6
  Downloaded thiserror-impl v1.0.61
  Downloaded indexmap-nostd v0.4.0
  Downloaded lalrpop-util v0.20.2
  Downloaded zerovec-derive v0.10.2
  Downloaded signal-hook-registry v1.4.2
  Downloaded paste v1.0.15
  Downloaded synstructure v0.13.1
  Downloaded argparse v0.2.2
  Downloaded stable-fs v0.1.12
  Downloaded displaydoc v0.2.4
  Downloaded rustversion v1.0.17
  Downloaded wasmedge_wasi_socket v0.5.4
  Downloaded either v1.12.0
  Downloaded data-encoding v2.6.0
  Downloaded ena v0.14.3
  Downloaded writeable v0.5.5
  Downloaded wasmi_core v0.13.0
  Downloaded walkdir v2.5.0
  Downloaded thiserror v1.0.61
  Downloaded dns-parser v0.8.0
  Downloaded litemap v0.7.3
  Downloaded icu_locid_transform v1.5.0
  Downloaded yoke v0.7.4
  Downloaded lock_api v0.4.12
  Downloaded pin-project-lite v0.2.14
  Downloaded tokio-rustls-wasi v0.24.1
  Downloaded ciborium v0.2.2
  Downloaded smallvec v1.13.2
  Downloaded parking_lot_core v0.9.10
  Downloaded getrandom v0.2.15
  Downloaded crc32fast v1.4.2
  Downloaded candid_parser v0.1.4
  Downloaded socket2 v0.4.10
  Downloaded icu_provider v1.5.0
  Downloaded icu_locid_transform_data v1.5.0
  Downloaded parking_lot v0.12.3
  Downloaded bitflags v2.5.0
  Downloaded half v2.4.1
  Downloaded icu_normalizer_data v1.5.0
  Downloaded ryu v1.0.18
  Downloaded icu_locid v1.5.0
  Downloaded icu_normalizer v1.5.0
  Downloaded num-traits v0.2.19
  Downloaded candid v0.10.8
  Downloaded serde_derive v1.0.203
  Downloaded bytes v1.6.0
  Downloaded icu_properties v1.5.0
  Downloaded cc v1.0.99
  Downloaded serde v1.0.203
  Downloaded icu_collections v1.5.0
  Downloaded indexmap v2.2.6
  Downloaded ic-stable-structures v0.6.5
  Downloaded encoding-index-japanese v1.20141219.5
  Downloaded url v2.5.1
  Downloaded encoding v0.2.33
  Downloaded mio_wasi v0.8.9
  Downloaded num-bigint v0.4.5
  Downloaded encoding-index-korean v1.20141219.5
  Downloaded wasmparser-nostd v0.100.2
  Downloaded encoding-index-tradchinese v1.20141219.5
  Downloaded zerovec v0.10.2
  Downloaded encoding-index-simpchinese v1.20141219.5
  Downloaded wasmi v0.31.2
  Downloaded idna v1.0.0
  Downloaded serde_json v1.0.117
  Downloaded hashbrown v0.14.5
  Downloaded icu_properties_data v1.5.0
  Downloaded lalrpop v0.20.2
  Downloaded syn v2.0.66
  Downloaded rustls v0.21.12
  Downloaded unicode-width v0.1.13
  Downloaded tokio_wasi v1.25.2
  Downloaded petgraph v0.6.5
  Downloaded tokio v1.38.0
  Downloaded 95 crates (7.4 MB) in 3m 33s
   Compiling proc-macro2 v1.0.85
   Compiling unicode-ident v1.0.12
   Compiling autocfg v1.3.0
   Compiling libc v0.2.155
   Compiling cfg-if v1.0.0
   Compiling version_check v0.9.4
   Compiling typenum v1.17.0
   Compiling serde v1.0.203
   Compiling cc v1.0.99
   Compiling syn v1.0.109
   Compiling thiserror v1.0.61
   Compiling either v1.12.0
   Compiling generic-array v0.14.7
   Compiling wasi v0.11.0+wasi-snapshot-preview1
   Compiling num-traits v0.2.19
   Compiling lock_api v0.4.12
   Compiling parking_lot_core v0.9.10
   Compiling getrandom v0.2.15
   Compiling memchr v2.7.2
   Compiling anyhow v1.0.86
   Compiling paste v1.0.15
   Compiling byteorder v1.5.0
   Compiling rustversion v1.0.17
   Compiling stable_deref_trait v1.2.0
   Compiling lazy_static v1.4.0
   Compiling psm v0.1.21
   Compiling smallvec v1.13.2
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling digest v0.10.7
   Compiling quote v1.0.36
   Compiling sha2 v0.10.8
   Compiling syn v2.0.66
   Compiling cpufeatures v0.2.12
   Compiling ring v0.17.8
   Compiling stacker v0.1.15
   Compiling rand_core v0.6.4
   Compiling crc32fast v1.4.2
   Compiling data-encoding v2.6.0
   Compiling writeable v0.5.5
   Compiling litemap v0.7.3
   Compiling arbitrary v1.3.2
   Compiling ppv-lite86 v0.2.17
   Compiling unicode-width v0.1.13
   Compiling num-integer v0.1.46
   Compiling rand_chacha v0.3.1
   Compiling aho-corasick v1.1.3
   Compiling dirs-sys-next v0.1.2
   Compiling encoding_index_tests v0.1.4
   Compiling pin-project-lite v0.2.14
   Compiling typed-arena v2.0.2
   Compiling regex-syntax v0.8.4
   Compiling synstructure v0.13.1
The following warnings were emitted during compilation:

warning: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `ring v0.17.8`

Caused by:
  process didn't exit successfully: `.../azle-api-rest-nextjs/target/release/build/ring-de635f83c39a4ad2/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_8_
  OPT_LEVEL = Some("z")
  TARGET = Some("wasm32-wasi")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CC_wasm32-wasi
  CC_wasm32-wasi = None
  cargo:rerun-if-env-changed=CC_wasm32_wasi
  CC_wasm32_wasi = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  cargo:rerun-if-env-changed=CFLAGS_wasm32-wasi
  CFLAGS_wasm32-wasi = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_wasi
  CFLAGS_wasm32_wasi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command "clang" "-Oz" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-I" "include" "-I" ".../azle-api-rest-nextjs/target/wasm32-wasi/release/build/ring-ae0b16a668669c16/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-g3" "-nostdlibinc" "-DNDEBUG" "-DRING_CORE_NOSTDLIBINC=1" "-o" ".../azle-api-rest-nextjs/target/wasm32-wasi/release/build/ring-ae0b16a668669c16/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...
Error: Command failed: CARGO_TARGET_DIR=target cargo build --target wasm32-wasi --manifest-path .azle/backend/canister/Cargo.toml --release
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at compileRustCodeNatively (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code.ts:55:13)
    at compileRustCode (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code.ts:10:9)
    at compileRustCodeWithCandidAndCompilerInfo (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/compile_rust_code_with_candid_and_compiler_info.ts:23:20)
    at getCandidAndCanisterMethods (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/get_candid_and_canister_methods.ts:38:49)
    at .../azle-api-rest-nextjs/node_modules/azle/src/compiler/index.ts:93:76
    at time (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/utils/time.ts:10:26)
    at azle (.../azle-api-rest-nextjs/node_modules/azle/src/compiler/index.ts:66:15) {
  status: 101,
  signal: null,
  output: [ null, null, null ],
  pid: 33623,
  stdout: null,
  stderr: null
}
Building frontend...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build all canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (backend) with an embedded error: Failed to build custom canister backend.: Failed to run npx azle backend --native-compilation.: The custom tool failed.
Nans-MacBook-Pro-14:azle-api-rest-nextjs nanjiang$ clang
clang: error: no input files

@johnnynanjiang
Copy link
Author

johnnynanjiang commented Jun 11, 2024

Followed below steps to fix the problem above, as per surrealdb/surrealdb.wasm#41

1. export AR=/opt/homebrew/opt/llvm/bin/llvm-ar
2. export CC=/opt/homebrew/opt/llvm/bin/clang
3. AZLE_VERBOSE=true dfx deploy

@johnnynanjiang johnnynanjiang changed the title dfx deploy failed with errors container state improper Apple M1: dfx deploy failed with errors container state improper Jun 11, 2024
@adrian-d-hidalgo
Copy link
Owner

I'm sorry. I'm going to update this template to the latest Azle version (0.23.0). This version doesn't need Rust compilation anymore, is faster, and fixes most compilation bugs.

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

2 participants