binwiederhier / replbot

Slack/Discord bot for running interactive REPLs and shells from a chat.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to start tmux, installed via rpm

bgschiller opened this issue · comments

I tried to start up a repl but it immediately failed with the following log output:

Started replbot server.
Slack connected as user replbot/U02F6EQ62VD
[session C5UPSCFP1_1632527569_060800] Starting session
[session C5UPSCFP1_1632527569_060800] Started REPL session
[session C5UPSCFP1_1632527569_060800] Failed to start tmux: exit status 1
[session C5UPSCFP1_1632527569_060800] Closed REPL session
[session C5UPSCFP1_1632527569_060800] Session exited with error: exit status 1

But when I switch user to the replbot user I'm able to start a tmux session without issue. I don't think this is related to #35, as I'm using the default set of scripts that came installed with the RPM package. I also double-checked the python repl that I used to try it out and it had regular unix line endings.

Thanks so much for the project! I'm looking forward to playing with it. Right now I'm using it to learn about AWS CDK. I'm hoping to make a reusable stack that anyone can use to stand up a replbot server on an ec2 machine.

I've tried running the commands replbot would invoke by hand, and my best guess is that it's failing when it runs the first tmux set-option:

c = append(c, []string{"tmux", "set-option", "-g", "default-terminal", "xterm-256color"}) // This is ugly, because it's global (-g)

When I run that in the same environment, I get an error saying failed to connect to server. It looks like if I explicitly start up a session using something like tmux new-session -s my-session -d the command works afterwards. Maybe that's an acceptable fix?

I'm using Amazon Linux 2 on an ec2 server. tmux version is 1.8.

Thank you for reporting this. I will look at this today.

I have very limited time today, but I'm more than happy to debug this with you. A couple of things:

For you specifically:

  1. Try running the demo script. That doesn't use Docker. If that works it's a docker problem. Make sure that the replbot user is in the docker group (see install instructions).
  2. Try this manually: #35 (comment)

Also:

  1. I acknowledge that the logging is not great and that I've had this exact "stack trace" many times myself. I think I need to log the output of the command so it's easy to figure out what's wrong.
  2. I am in the middle of rewriting part of the tmux stuff in the gotty branch, because I need (sigh) yet another layer of tmuxes to provide a web-based terminal, so this code will change soon anyway.
  3. I haven't tested the rpm package myself. It's just built as part of the release, so things may not be properly set up.

I'm gonna try the current release again on a new box, maybe even an amazon linux box in ec2, so I can replicate.

I'm gonna try the current release again on a new box, maybe even an amazon linux box in ec2, so I can replicate.

Okay I spun up an Amazon Linux image (amzn2-ami-hvm-2.0.20210813.1-x86_64-gp2) and I can't even install REPLbot because there is no asciinema package that works. I'm sorry, but I don't have a ton of Amazon Linux / rpm experience. If you give me some guidance how you installed asciinema that'd be great ... Alternatively, I will likely just release a version without the asciinema dependency. That's mostly optional anyway.

I'll look more later today.

Okay with a custom package (without asciinema dependency) I was able to reproduce. I will provide a fix by tonight, I have to do some family things now :-D

Okay looks like it's this. The tmux version is really really old in Amazon Linux. I'll see if it's an easy fix.

Sep 25 17:11:25 ip-172-30-4-148.ec2.internal replbot[6536]: command output: usage: split-window [-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] [-t target-pane] [command]

It appears that the command passed to tmux in 1.8 has to be one shell argument, and can be multiple in 2.6:

# tmux 1.8
[root@ip-172-30-4-148 ec2-user]# tmux new-session sleep 60
usage: new-session [-AdDP] [-F format] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]

# tmux 2.6
pheckel@plep ~/Code/replbot(a13d2c3*) » tmux new-session sleep 60
<sleeps>

I've gotten past the new-session thing, but there are other issues with this old tmux version. I will continue later today.
So far:

tmux 1.8 vs 2.6 differences:

  • command argument has to be one argument
  • set-hook does not exist yet
  • load-buffer tells me "buffer invalid"

So I think I'm going to have to drop support for tmux 1.8. The load-buffers behavior is odd and not workable. It does not support loading buffers into tmux based on a buffer name, only based on automatic indices. While I could work around that, it's a ton of work and I'm not really willing to do that.

I'll add a version check when launching replbot so it'll fail early.

Sorry.

FYI tmux 1.8 is from 2015, so 6 years old. Not sure why a current image on AWS ships with that.

I released v0.5.1, which includes a tmux version check and hard fails when it's too low. It also shows the command errors in the log now more clearly.

I'm gonna close this. Let me know if you can't get it to run. If you are in AWS anyway, I suggest an Ubuntu AMI.

I'm an idiot. Try v0.5.2. I messed up the version check 😁