indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.47k stars 239 forks source link

Panic on pyoxidizer run: set_attr_add_collection_context #561

Closed Sheeproid closed 2 years ago

Sheeproid commented 2 years ago

I'm on an M1 macbook if it matter.

I tried to use pyoxidizer to pack a pip package using the following code

    for resource in exe.pip_install(["robusta-cli==0.9.11"]):
        #resource.resources_location = "filesystem-relative:lib"
        resource.resources_location_fallback = "in-memory"
        exe.add_python_resource(resource)

I used in-memory and filesystem-relative options and they both did not work.

Help is appreciated :)

Stacktrace:

thread 'main' panicked at 'set_attr_add_collection_context(resources_location_fallback) called when it shouldn't have been', /Users/tomerkeshet/.cargo/registry/src/github.com-1ecc6299db9ec823/pyoxidizer-0.20.0/src/starlark/python_resource.rs:225:29
stack backtrace:
   0:        0x102ff91c8 - std::backtrace_rs::backtrace::libunwind::trace::h449592924b3bd63f
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x102ff91c8 - std::backtrace_rs::backtrace::trace_unsynchronized::ha2aaeafed0c31c90
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x102ff91c8 - std::sys_common::backtrace::_print_fmt::h58db85a17304976f
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:66:5
   3:        0x102ff91c8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h10cf06316d33e2a9
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:45:22
   4:        0x10301c7b0 - core::fmt::write::h1faf18c959c3a8df
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/fmt/mod.rs:1190:17
   5:        0x102ff1140 - std::io::Write::write_fmt::h86ab231360bc97d2
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/io/mod.rs:1657:15
   6:        0x102ffbc10 - std::sys_common::backtrace::_print::h771b4aab9b128422
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:48:5
   7:        0x102ffbc10 - std::sys_common::backtrace::print::h637de99a9f76e8a7
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:35:9
   8:        0x102ffbc10 - std::panicking::default_hook::{{closure}}::h36e628ffaf3cd44f
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:295:22
   9:        0x102ffb888 - std::panicking::default_hook::h3ee1564a7544e58f
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:314:9
  10:        0x102ffc270 - std::panicking::rust_panic_with_hook::h191339fbd2fe2360
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:698:17
  11:        0x102ffbff8 - std::panicking::begin_panic_handler::{{closure}}::h91c230befd9929e3
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:588:13
  12:        0x102ff96b0 - std::sys_common::backtrace::__rust_end_short_backtrace::haaaeebb1d37476b3
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:138:18
  13:        0x102ffbd34 - rust_begin_unwind
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
  14:        0x1030544ec - core::panicking::panic_fmt::h4fe1013b011ef602
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
  15:        0x1027087f0 - <T as starlark::values::TypedValueDyn>::set_attr_dyn::h96758ea0de55063a
  16:        0x102b4942c - starlark::values::Value::set_attr::h87d86be726941588
  17:        0x102b693dc - starlark::eval::set_expr::h0040cc9f58c2955c
  18:        0x102b6e078 - starlark::eval::eval_block::he83d6d35c8d19176
  19:        0x102b6e7a8 - starlark::eval::eval_block::he83d6d35c8d19176
  20:        0x102b4fedc - <starlark::eval::def::Def as starlark::values::TypedValue>::call::h12b5609f689c66a7
  21:        0x102b3bbec - <T as starlark::values::TypedValueDyn>::call_dyn::hd1ce1dfc5311f3de
  22:        0x102b470d0 - starlark::values::Value::call::ha32b96112a39d311
  23:        0x102ab7130 - starlark_dialect_build_targets::starlark_resolve_target::h7d9917b21ff970b5
  24:        0x102ab6f38 - starlark_dialect_build_targets::starlark_resolve_target::h7d9917b21ff970b5
  25:        0x102aba2c0 - starlark_dialect_build_targets::resolve_target::h8ccdb887bc9d42f4
  26:        0x102b2f3d0 - <T as starlark::values::TypedValueDyn>::call_dyn::h06e23cd94129d968
  27:        0x102b470d0 - starlark::values::Value::call::ha32b96112a39d311
  28:        0x102abab2c - starlark_dialect_build_targets::resolve_targets::hf14eddb3c3f2cea4
  29:        0x102b2f3d0 - <T as starlark::values::TypedValueDyn>::call_dyn::h06e23cd94129d968
  30:        0x102b470d0 - starlark::values::Value::call::ha32b96112a39d311
  31:        0x102b65f3c - starlark::eval::eval_call::hc9be880c1d51a7d3
  32:        0x102b67ccc - starlark::eval::eval_expr::ha8200e57eb26f2a4
  33:        0x102b6c80c - starlark::eval::eval_block::h0efc9c12f2054fd1
  34:        0x102b6f2a0 - starlark::eval::eval_module::hcf93f4e1f630faba
  35:        0x102b6f44c - starlark::eval::eval_file::h863870c5ea9d4d01
  36:        0x102bb0924 - starlark::eval::simple::eval_file::h1155de79d4757aaa
  37:        0x102666cfc - pyoxidizer::starlark::eval::EvaluationContext::evaluate_file::h76d0e50168b9996d
  38:        0x1026860e8 - pyoxidizer::projectmgmt::run::h10da6e6a8b327c47
  39:        0x1026fdb10 - pyoxidizer::cli::run_cli::h2cb21e5463ec6492
  40:        0x1026ada34 - pyoxidizer::main::h6c4b4ff021750ab6
  41:        0x1026a054c - std::sys_common::backtrace::__rust_begin_short_backtrace::hda961440d08c9ac9
  42:        0x1026cff14 - std::rt::lang_start::{{closure}}::h809e77e8c866e2fb
  43:        0x102ff8a74 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h8eb3ac20f80eabfa
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:259:13
  44:        0x102ff8a74 - std::panicking::try::do_call::ha6ddf2c638427188
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
  45:        0x102ff8a74 - std::panicking::try::hda8741de507c1ad0
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
  46:        0x102ff8a74 - std::panic::catch_unwind::h82424a01f258bd39
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
  47:        0x102ff8a74 - std::rt::lang_start_internal::{{closure}}::h67e296ed5b030b7b
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/rt.rs:128:48
  48:        0x102ff8a74 - std::panicking::try::do_call::hd3dd7e7e10f6424e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
  49:        0x102ff8a74 - std::panicking::try::ha0a7bd8122e3fb7c
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
  50:        0x102ff8a74 - std::panic::catch_unwind::h809b0e1092e9475d
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
  51:        0x102ff8a74 - std::rt::lang_start_internal::h358b6d58e23c88c7
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/rt.rs:128:20
  52:        0x1026bb664 - _main
indygreg commented 2 years ago

This can hopefully be worked around by passing add_location_fallback instead of wherever in your Starlark config file you are using resources_location_fallback. Although there's a chance something internally in mapping to the wrong name leading to this error. Although the call stack looks like it is coming from your Starlark file.

This is bad error handling and/or bad documentation. It is a legit bug. Thanks for reporting.