-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Erlang/OTP 26 stdin fails on file:read/file:read_line #7230
Comments
@frazze-jobb when can we expect a release with fix for that? This one is breaking elixirLS (Elixir Language Server) |
Yes, am on parental leave this week, but will look into it next week |
Would it be okey to start the shell later? In that case it would be possible to solve this similarly to #7211 |
@frazze-jobb I can start the shell later but I need something that will work on lower OTP versions. Your example crashes OTP 25
|
@frazze-jobb just so I understand better the problem, it is not possible to change the encoding after the shell is started, even with |
It is possible to change the encoding, problem is that the driver has already read stdin before "io:setopts" has been evaluated |
Alternatively, is it possible to read from stdin device without starting a shell? |
@frazze-jobb I see! What do you think about a VM flag or app configuration? |
For what it's worth, you can access the direct binary stream by setting stdio as a file descriptor when using the erlang:open_port/2 BIFs:
This will preserve the exact encoding that was passed in the input. If it was unicode, it remains unicode, if it was binary garbage, it remains binary garbage. The 'port_command' value does expect iodata() out, so any unicode output subsequences you have have to be flattened out to valid binaries before being sent out (so avoid any charlists that have unicode codepoints in the values and force it down to valid utf8 binaries with |
@ferd will it work in windows? |
hm, I think unfortunately windows is pickier about drivers hijacking stdio, even though Erlang is told not to use them. It might fail there, but I haven't had a windows computer in a functional state in a long while to check it. |
The downside it that as far as I understand it just passes byte blobs with no concept of lines. In order to use it in elixirLS I'd need to implement buffering and reading by lines. |
You can pass That being said, I think we will add an option as Josè described so that you can set the encoding of standard_io when you start erlang. |
As group now acts as the proxy when running "oldshell" or "noshell" it needs to be able to read and write raw binaries. Latin1 encoding allows all possible bytes, so by fixing latin1 we allow any bytes to be passed into and out of Erlang unmodified. fixes erlang#7230
Describe the bug
Expected behavior
On Erlang/OTP 25 it worked without problems:
The goal is to read a bytestream, "duπa" is just an example.
Affected versions
Only on Erlang/OTP 26. This patch fixes stdout, perhaps similar is needed for stdin?
The text was updated successfully, but these errors were encountered: