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

NumberFormatException because of tput No such device or address #15796

Open
francisdb opened this issue Aug 1, 2022 · 5 comments
Open

NumberFormatException because of tput No such device or address #15796

francisdb opened this issue Aug 1, 2022 · 5 comments

Comments

@francisdb
Copy link

francisdb commented Aug 1, 2022

Compiler version

3.1.3

Minimized code

echo "@main def main = println(util.Properties.versionMsg)" > test.scala
scala -nocompdaemon test.scala

This code is part of a docker build on a amazon corretto 17.0.4 base image
see sbt/docker-sbt#207

Output

tput: terminal attributes: No such device or address

Exception in thread "main" java.lang.NumberFormatException: For input string: ""
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
	at java.base/java.lang.Integer.parseInt(Integer.java:678)
	at java.base/java.lang.Integer.parseInt(Integer.java:786)
	at scala.collection.StringOps$.toInt$extension(StringOps.scala:915)
	at dotty.tools.dotc.config.ScalaSettings$.defaultPageWidth(ScalaSettings.scala:39)
	at dotty.tools.dotc.config.CommonScalaSettings.$init$(ScalaSettings.scala:105)
	at dotty.tools.dotc.config.ScalaSettings.<init>(ScalaSettings.scala:14)
	at dotty.tools.dotc.core.Contexts$ContextBase.<init>(Contexts.scala:850)
	at dotty.tools.dotc.Driver.initCtx(Driver.scala:59)
	at dotty.tools.scripting.ScriptingDriver.compileAndRun(ScriptingDriver.scala:17)
	at dotty.tools.scripting.Main$.main(Main.scala:45)
	at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:249)
	at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:268)
	at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)

Expectation

This runs fine and prints the scala version

References

introduced in #10304

https://github.com/lampepfl/dotty/blob/1130c52a6476d473b41a598e23f0415e0f8d76dc/dist/bin/common#L31-L34

Fix

probably this should default to 80 in case tput fails or not set COLUMNS?

see https://docs.scala-lang.org/scala3/guides/migration/options-new.html

Workaround

looks like -pagewidth 80 4f803eb was applied to tests to fix a similar issue

More testing

docker run --rm amazoncorretto:17.0.4 tput -Tdumb cols
tput: terminal attributes: No such device or address

docker run --rm eclipse-temurin:17.0.3_7-jdk tput -Tdumb cols
80
@francisdb francisdb added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 1, 2022
@WojciechMazur WojciechMazur added stat:needs triage Every issue needs to have an "area" and "itype" label and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 2, 2022
@WojciechMazur
Copy link
Contributor

I've not managed to reproduce it locally using Ubuntu 20.04 LTS, JDK 11/17 Amazon Correctto, and any of the bash, zsh, sh shells. The only way of reproducing it so far involves building docker image locally based on the referenced PR.

@francisdb btw. It looks like your script has a small bug, util.Properties.versionMsg contains a version of Scala 2 library (since Scala 3 uses Scala 2.13 stdlib to allow for cross building between the two)

@WojciechMazur WojciechMazur added area:tooling and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 2, 2022
@francisdb
Copy link
Author

francisdb commented Aug 2, 2022

@francisdb btw. It looks like your script has a small bug, util.Properties.versionMsg contains a version of Scala 2 library (since Scala 3 uses Scala 2.13 stdlib to allow for cross building between the two)

Thanks, got a better in-code one-liner that prints the correct scala version in scala 3?

@francisdb
Copy link
Author

francisdb commented Aug 2, 2022

hmm, I edited the description but this must have been lost. Edited it again (docker run stuff)

@WojciechMazur
Copy link
Contributor

Thanks, got a better in-code one-liner that prints the correct scala version in scala 3?

Not really a one-liner, but works: https://gist.github.com/romanowski/de14691cab7340134e197419bc48919a You can always just curl the gist source and run it

@SethTisue
Copy link
Member

(cool, I didn't know about that gist; this PR links to it from the FAQ entry on the subject: scala/docs.scala-lang#2485)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants