ongardie / cubicle

Manage isolated development environments
MIT License
13 stars 3 forks source link

error when exiting a cub #39

Closed superfell closed 1 year ago

superfell commented 1 year ago

This is using #38 on arm/osx I cub enter bob3 do some things, then use exit to leave bob3. At which point i get an error

simon@bob3:~/w$ exit
Error: failed to run command in environment "bob3"

Caused by:
    Non-zero exit status (1) from docker exec

Stack backtrace:
   0: anyhow::backtrace::capture::Backtrace::capture
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: cubicle::docker::Docker::run_
   3: <cubicle::runner::CheckedRunner as cubicle::runner::Runner>::run
   4: cub::cli::run
   5: cub::main
   6: std::sys_common::backtrace::__rust_begin_short_backtrace
   7: std::rt::lang_start::{{closure}}
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:280:13
      std::panicking::try::do_call
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:128:48
      std::panicking::try::do_call
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:128:20
   9: _main
ongardie commented 1 year ago

I think probably the last command you ran in bob3 failed, like:

bob3% false
bob3% exit
Error: failed to run command in environment "bob3"

Caused by:
    Non-zero exit status (1) from docker exec
Command exited with status 1 [this is output by Diego's shell prompt]
~$ 

Then the shell will exit with a non-zero status, and it looks to Cubicle like everything failed terribly. I don't know if there's a better way to handle this, other than having Cubicle ignore the exit status of interactive shells.

Docker seems to pass the exit status through but not display an error:

~$ docker run -it --rm debian             
root@1686f5a4afd8:/# false
root@1686f5a4afd8:/# 
exit
Command exited with status 1 [this is output by Diego's shell prompt]
~$ docker run -it --rm debian
root@9965e1ea7990:/# true
root@9965e1ea7990:/# 
exit
~$ 
superfell commented 1 year ago

Ah, yes, that'd be it.