Coder Social home page Coder Social logo

Comments (31)

anseki avatar anseki commented on May 29, 2024

Hi evilebottnawi, thank you for your report.

So, how did you use readlineSync? GitLab CI runner, build script for something, testing your app, or in your app?
If you tried to make readlineSync run in some wrapped environment such as CI auto script that runs at background (i.e. without TTY), readlineSync should not work, because readlineSync is used to reading that interactivity.

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki maybe not throw Exception, simply display an error and when you try use function also display error. Exception breaks build :(

from readline-sync.

anseki avatar anseki commented on May 29, 2024

So, how did you use readlineSync?

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki i use gulp and require readline-sync in gulp file

from readline-sync.

anseki avatar anseki commented on May 29, 2024

I see.
Try to execute gulp command directly with that gulpfile, then does it work fine?

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki yes all working fine outside docker container

from readline-sync.

anseki avatar anseki commented on May 29, 2024

TTY might have been not enabled.
Try to make docker run with -t option.
And make gulp run in this session.

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki https://gitlab.com/gitlab-org/gitlab-ci-multi-runner
no option for set -t

from readline-sync.

anseki avatar anseki commented on May 29, 2024

Not GitLab CI.
This is TTY test.

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki
i run ls -l /dev
output:
...
crw-rw-rw- 1 root root 5, 0 Jan 15 16:43 tty
...

tty exist in folder

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki full error from logs

stty: when specifying an output style, modes may not be set
/some_path/node_modules/readline-sync/lib/read.sh: 49: /some_path/node_modules/readline-sync/lib/read.sh: cannot create /dev/tty: No such device or address
stty: standard input: Inappropriate ioctl for device
/some_path/node_modules/readline-sync/lib/readline-sync.js:66
    if (res.error) { throw res.error; }
                     ^

Error: The platform doesn't support interactive reading
stty: when specifying an output style, modes may not be set
/some_path/node_modules/readline-sync/lib/read.sh: 49: /some_path/node_modules/readline-sync/lib/read.sh: cannot create /dev/tty: No such device or address
stty: standard input: Inappropriate ioctl for device

from readline-sync.

anseki avatar anseki commented on May 29, 2024

Not exist or not test.
TTY has to be enabled.

from readline-sync.

anseki avatar anseki commented on May 29, 2024

I don't know what you want to do, but if you don't need interactive reading, you can ignore the error by catching the thrown error.

try {
  key = readlineSync.keyIn();
} catch (e) {}

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki with -t work all fine

from readline-sync.

anseki avatar anseki commented on May 29, 2024

Good for you 😃
So, was the issue solved? will this issue be closed?

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki no :(. gitlab-ci run without flag -t. But this is a problem not apply here.

from readline-sync.

anseki avatar anseki commented on May 29, 2024

You can enable TTY by -t option and specify --name gitlab-ci-runner to make it run within same session.
BTW, I don't know what you want to do... Why you need interactive reading in CI? These should be in conflict.
I think that you should catch the thrown error.

from readline-sync.

anseki avatar anseki commented on May 29, 2024

I think that this #26 (comment) might help you.

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki I searched through the documentation but could not find the option set up -t

from readline-sync.

anseki avatar anseki commented on May 29, 2024

I think that this #26 (comment) and this #26 (comment) might help you without -t option.

from readline-sync.

alexander-akait avatar alexander-akait commented on May 29, 2024

@anseki no

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

I'm using readline-sync on windows (git-bash.exe).
`C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:250
if (res.error) { throw res.error; }
^

Error: The current environment doesn't support interactive reading from TTY.
at readlineExt (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:212:19)
at tryExt (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:249:15)
at C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:352:15
at _readlineSync (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:422:5)
at getValidLine (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:752:11)
at Object.exports.question (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\node_modules\readline-sync\lib\readline-sync.js:834:10)
at Object. (C:\Users\sikkache\AppData\Roaming\npm\node_modules\jira\index.js:8:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)

sikkache@DAP-CHA-POR0109 MINGW64 /d/Documents/Programmation/NodeJS/jira (master)
$ ls -l /dev
...
crw-rw-rw- 1 sikkache 1049089 5, 0 avr. 4 10:39 tty
`

Thank you for your help

from readline-sync.

anseki avatar anseki commented on May 29, 2024

Hi @SelimIkkache,

Could you show me your code?
And, which version of readlineSync, Windows, bash and Node.js?
Also, did the code work in CMD?

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

Versions :
[email protected]
Windows: 7
Git Bash: GNU bash, version 4.4.12(1)-release (x86_64-pc-msys)
Node js: v6.9.5

It works in CMD

The code

#!/usr/bin/env node
// Entry point for the program
var readlineSync = require('readline-sync');
var Basic = require('./helper/basic')
var jiraLPCArgs = new (require('./helper/cli-args'))()

// Get password for JIRA
jiraLPCArgs.auth.setDigest(jiraLPCArgs.user,
  readlineSync.question('Enter your password ', {hideEchoBack: true}))

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

I closed my git bash and relaunch it, I have no more issues

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

By the way, this code works in CMD, but not in GitBash.
There is no output at all on gitbash.

Output on CMD

C:\Users\sikkache>jiralpc
Enter your password *********
STATUS: [object Object]
ERROR: null
CCU-3828 - [LPC][TEC] Nettoyer le code suite au remarque du linter : phase 1 - B
loquant
CCU-3808 - [LPC] [TEC] Créations de règles pour le linter - Majeur
_[...]_

Output on gitbash

$ jiralpc

And it is frozen for ever

from readline-sync.

anseki avatar anseki commented on May 29, 2024

I see.
It seems that your environment (MinGW) does not support interactive reading from TTY. That is, the error message is correct.
Since readlineSync is library to read and write via TTY, of course it can't work with no TTY.

REPL also may not work in your environment. try this:

node
console.log('foo');

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

You're right, it doesn't work ever.

So Howcan I make it work ?

from readline-sync.

anseki avatar anseki commented on May 29, 2024

That is solved simply, by using it in an environment that TTY is available.
I think that you probably use a decent terminal such as Cmder instead of CMD that has many problems, as everyone knows.
Or, if you really want to use MinGW, #33 might help you. But I don't recommend it.

from readline-sync.

SelimIkkache avatar SelimIkkache commented on May 29, 2024

Thank you, you can solve the issue according to me.

from readline-sync.

anseki avatar anseki commented on May 29, 2024

😄

from readline-sync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.