wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
18k stars 807 forks source link

"Error getting metatable" when attempting to run io.popen() in Debug Overlay #3849

Closed keturiosakys closed 10 months ago

keturiosakys commented 1 year ago

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

-

WezTerm version

20230530-062729-95e44f21

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Attempting to run io.popen() command with any valid input command string passed in results in the following error:

Error getting metatable: userdata is not expected type

The error seems to be reported from the luahelper package (line 415 in src/lib.rs and the userdata is not expected type is an error from mlua crate but this is as far as I could get.

To Reproduce

  1. Open WezTerm debug REPL (CTRL-SHIFT-L)
  2. Type io.popen("/bin/ls")
  3. See the error show up.

Configuration

no config

Expected Behavior

Command runs successfully

Logs

No response

Anything else?

No response

wez commented 1 year ago

In the meantime, take a look at https://wezfurlong.org/wezterm/config/lua/wezterm/run_child_process.html

keturiosakys commented 1 year ago

Thanks! Got it working with run_child_process interface.

wez commented 1 year ago

FWIW, that userdata error is specific to the debug overlay; it's trying to figure out how to print it nicely, and failing.

If you assign the value to a variable, then it does work:

> p = io.popen('/bin/ls')
> p:read('*all')
wez commented 1 year ago

This should be resolved now in main.

Please take a few moments to try out the fix and let me know how that works out. You can find the nightly downloads for your system in the wezterm installation docs.

If you prefer to use packages provided by your distribution or package manager of choice and don't want to replace that with a nightly download, keep in mind that you can download portable packages (eg: a .dmg file on macOS, a .zip file on Windows and an .AppImage file on Linux) that can be run without permanently installing or replacing an existing package, and can then simply be deleted once you no longer need them.

If you are eager and can build from source then you may be able to try this out more quickly.

github-actions[bot] commented 9 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.