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

bun repl #947

Open
DetachHead opened this issue Aug 1, 2022 · 10 comments
Open

bun repl #947

DetachHead opened this issue Aug 1, 2022 · 10 comments
Labels
enhancement New feature or request repl An issue with `bun repl`

Comments

@DetachHead
Copy link

What is the problem this feature will solve?

want to be able to quickly run a code snippet without creating a file

What is the feature you are proposing to solve the problem?

bun repl command, or even just bun on its own opens the repl (like in node)

(i know this is is mentioned in #159 but it didn't have its own issue. feel free to close if you don't want seperate issues for items on the roadmap)

What alternatives have you considered?

No response

@DetachHead DetachHead added the enhancement New feature or request label Aug 1, 2022
@Pedromdsn
Copy link
Contributor

Pedromdsn commented Oct 3, 2022

Literally one of the 2 things I need to replace node with bun.
This is an image in material icons.

@cassepipe
Copy link

cassepipe commented Feb 17, 2023

If that ever happens, would it be possible to add an option for the bun repl to:

  1. Use GNU readline (used by bash, gdb and others) while having access to completions.
  2. Have an option to open the repl in our preferred $EDITOR buffer. For example oh-my-zsh has an option to open the zsh command line in a vim buffer
  3. Have a full fledge vim mode such zsh and fish have

Any combination of those solutions would make a repl much more usable than they generally are.

rlwrap does exist but then you lose completions, tough choice to make

@michaelskyba
Copy link

It's supported now with bun repl?
I don't see any way to enable vi bindings though; it doesn't seem to use readline

@KaKi87
Copy link

KaKi87 commented Feb 1, 2024

Hello,
Any news on this ?
Thanks

@paperdave
Copy link
Member

its been on my mind recently to rewrite bun repl in native code (it is currently an alias to bun x bun-repl which is written in javascript)

Use GNU readline (used by bash, gdb and others) while having access to completions.

in my opinion readline shouldnt be used because completions ought to be powered by the javascript engine, and i just think that the act of reading input can be implemented about a thousand times better.

Have an option to open the repl in our preferred $EDITOR buffer.

I think this is a reasonable idea, but it borders on the point that you may just want to use an actual file with bun run.

I don't see any way to enable vi bindings though

this would be interesting to support

@Electroid Electroid added the repl An issue with `bun repl` label Feb 5, 2024
@cassepipe
Copy link

Using GNU readline would have the advantage of unlocking a vim mode (that's not the best around but hey it's there for us who really enjoy vim modes in line editors)

@KilianB
Copy link
Contributor

KilianB commented Jun 28, 2024

When reimplementing repl it would be great if non interactive terminal sessions are supported (#5832) .

Currently I explore the possibility to create a ts notebook prototype similar to jupyter notebooks where a repl session is spawned in a child process.

const runtime= Bun.spawn({
  cmd: ["bun", "repl"],
  stdin: "pipe",
  stdout: "pipe",
});

This currently fails: [!] Failed to start REPL interface! Is the command running in an interactive terminal?

@jordan-castro
Copy link

Any news on this? I'm trying to provide a interactive terminal for my programming language that compiles into JS. I got it working with node thanks to their '-i' flag option. I've been wanting to try with bun like:

        p = open(`bun repl`, "r+") # this is where it fails
        write(p, command_with_marker)
        flush(p)
        out = readline(p.out)

@KilianB
Copy link
Contributor

KilianB commented Nov 3, 2024

I forked repl and it was a matter of commenting out a single line that checked for the interactive part. As far as I could tell everything else still worked without any trouble.
It was as easy as following where the error was thrown and slipping the of check

@jordan-castro
Copy link

Hm, I'd rather not fork the bun repl. I imagine that would work but the idea is that users can use the bun on their own machine without any change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request repl An issue with `bun repl`
Projects
None yet
Development

No branches or pull requests

9 participants