Skip to content

NumberFormatException because of tput No such device or address #15796

Open
@francisdb

Description

@francisdb

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions