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

I can't type any characters into the terminal. (STDIN, STDOUT) #11125

Closed
nodirbekrajaboff opened this issue May 16, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@nodirbekrajaboff
Copy link

What version of Bun is running?

1.1.8+89d25807f

What platform is your computer?

Linux 4.15.0-208-generic x86_64 x86_64

What steps can reproduce the bug?

I ran the file through bunjs and I can't type any letters through the terminal. This is only not working on my ubuntu server. In another server this codes working. This is my codes:

import { ENVLIST } from "@/config/env";
import getRootPath from "@/utils/get-root-path";
import readline from "readline";
import path from "node:path";

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

const env = path.join(getRootPath(), ".env");

async function promptAndWriteEnv(index: number) {
if (index < ENV_LIST.length) {
if (!(await Bun.file(env).exists())) await Bun.write(env, "");

if (await checkIfExists(ENV_LIST[index])) {
  console.log(${ENV_LIST[index]} already exists in .env file.);
  promptAndWriteEnv(index + 1);
} else
  rl.question(Enter value for ${ENV_LIST[index]}: , async (value) => {
    let text = "";
    let result = "";

    const file = Bun.file(env);
    if (await file.exists()) {
      text += await file.text();
      result += ${text}\n${ENV_LIST[index]}=${
        !isNaN(Number(value)) ? value : "${value}"
      }\n;
    }

    Bun.write(
      env,
      result
        .replace(/(\r\n|\r|\n){2}/g, "$1")
        .replace(/(\r\n|\r|\n){3,}/g, "$1\n")
    );
    console.log(${ENV_LIST[index]} added to .env file successfully!);
    promptAndWriteEnv(index + 1);
  });

} else {
console.log(".env file created successfully!");
rl.close();
}
}

async function checkIfExists(variable: string) {
const envData = await Bun.file(env).text();
const envLines = envData.split("\n");
for (const line of envLines) {
const [key, ] = line.split("=");
if (key.trim() === variable) return true;
}
return false;
}

promptAndWriteEnv(0);

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@nodirbekrajaboff nodirbekrajaboff added the bug Something isn't working label May 16, 2024
@nodirbekrajaboff nodirbekrajaboff closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@Jarred-Sumner
Copy link
Collaborator

If you upgrade to a more recent Linux kernel this will likely be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants