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

--error does not suppress new batch mode warning in 0.13.15 #3091

Closed
SethTisue opened this issue Apr 10, 2017 · 18 comments
Closed

--error does not suppress new batch mode warning in 0.13.15 #3091

SethTisue opened this issue Apr 10, 2017 · 18 comments
Assignees
Milestone

Comments

@SethTisue
Copy link
Member

% sbt --error compile
[warn] Executing in batch mode.
[warn]   For better performance, hit [ENTER] to switch to interactive mode, or
[warn]   consider launching sbt without any commands, or explicitly passing 'shell'

this regresses on #840

@SethTisue SethTisue changed the title --error does not suppress new batch mode warning --error does not suppress new batch mode warning in 0.13.15 Apr 10, 2017
@eed3si9n eed3si9n added the Bug label Apr 10, 2017
@SethTisue
Copy link
Member Author

also

% sbt --error
WARN: No sbt.version set in project/build.properties, base directory: /Users/tisue/tmp/unused

@dwijnand
Copy link
Member

The primary reason this is happening is because I'm trying to do it as early as possible, when there is a clear distinction between sbt.xMain, and sbt.ScriptMain or sbt.ConsoleMain - ironically exactly for scripting reasons.

I think I can rework this to appease both use cases, but I wonder: @SethTisue what's the severity in your mind of this regression?

@dwijnand dwijnand self-assigned this Apr 11, 2017
@jvican
Copy link
Member

jvican commented Apr 11, 2017

Is it possible to disable this warning @dwijnand?

For instance, I use sbt for scripting intensively. I think that this warning is good when the user types sbt, but I'd like to remove it when I'm programmatically controlling sbt.

@dwijnand
Copy link
Member

By invoke sbt in non-interactive (aka batch) mode.

The easiest way is by appending < /dev/null, e.g:

sbt compile < /dev/null

Or in sbt-extras by passing -batch, e.g:

sbt -batch compile

I'm happy to revise the implementation to strike a better balance.

@jvican
Copy link
Member

jvican commented Apr 11, 2017

Thanks for the pointers.

It would be interesting to have something like --script in the official sbt. To the best of my understanding, it would have the same behaviour as -batch but I think the naming is clearer.

@dwijnand
Copy link
Member

The concept of "script" already refers to http://www.scala-sbt.org/0.13/docs/Scripts.html (and its sbt.ScriptMain), which is not what you're after when you say "script".. :-/

@jvican
Copy link
Member

jvican commented Apr 11, 2017

It's a pity that sbt is using that definition of 'script' when the widely used notion of scripting is substantially different (for example, bash scripts).

In any case, --batch sounds good. Another alternative would be --one-shot.

@dwijnand
Copy link
Member

The nomenclature looks consistent to me: a bash script is a script that bash interprets and an sbt script is a script that sbt interprets (using ScriptMain).

I'd be happy to port -batch to the sbt-launcher-package scripts. Note that --batch is complicated at the moment due to the history of and migration needed for --... #2741.

@jvican
Copy link
Member

jvican commented Apr 11, 2017

The nomenclature looks consistent to me: a bash script is a script that bash interprets and an sbt script is a script that sbt interprets (using ScriptMain).

You're right.

I'd be happy to port -batch to the sbt-launcher-package scripts. Note that --batch is complicated at the moment due to the history of and migration needed for --... #2741.

I would like to see this supported by default, so 👍 .

@eed3si9n
Copy link
Member

If we implement the project/build.properties warning as one of the commands, we might be able to place it after the early commands.

@dwijnand
Copy link
Member

Indeed that was my idea. I'm just not sure what priority to give this regression - i.e if it should be worked on now.

@eed3si9n
Copy link
Member

We can schedule it for next 0.13.x release, but I don't think it's high priority enough to disrupt the current iteration.

@jastice
Copy link
Contributor

jastice commented Apr 12, 2017

sbt new also triggers the warning

@dwijnand dwijnand added this to the 0.13.16 milestone Apr 12, 2017
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 13, 2017
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 13, 2017
@sarahgerweck
Copy link

sarahgerweck commented Apr 19, 2017

This really shouldn't be a warning: it shows up even in things like sbt run. Can we please get a setting that we can put in build.properties and in our ~/.sbt to permanently disable this?

I personally think this was an ill-advised feature. You do this in the docs, not as nagware. I already have a mother, I don't need my build system to scold me—especially if its message is that I'm supposed to change my workflow and keep a JVM around permanently. Tools are supposed to make my life easier, not the other way around.

@jeffrey-aguilera
Copy link

Agree 100% with @sarahgerweck. This warning is just plain annoying and not very reliable.

@eed3si9n
Copy link
Member

eed3si9n commented Apr 22, 2017

Due to JIT (and startup time of sbt itself too I assume), there's a significant difference in compiler performance if you keep the sbt shell around, so I think it warrants displaying a message to let people know that running batch mode is slower.
See https://twitter.com/eed3si9n/status/837585213563801600

Here are the some changes I suggest:

  • The message should be reduced to [info] level since it literally is an information, not something that could break correctness.
  • Respect the log level.
  • It should only be displayed on passing a single compile as argument.
  • Reduce the message to a single line, for example [info] Compiling in batch mode is slower than from interactive shell.
  • Provide a globally scoped setting to opt out.

@koertkuipers
Copy link

koertkuipers commented Apr 26, 2017

i too find this new batch mode warning annoying. not so much the warning itself (i can live with the extra text) but the fact that by accident hitting [ENTER] puts me in interactive mode. this makes batch/scripting usage more difficult as others have mentioned before me.

dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 27, 2017
Specifically:

* Make them both commands, so they run after early commands (--error).
* Make notifyUsersAboutShell aware of "iflast shell" instead of "boot".
* Make writeSbtShell use a logger and tweak the message

Refs sbt#3091
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 27, 2017
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 27, 2017
This requires moving the notification to after LoadProject, so much
later in time, sadly..

Refs sbt#3091
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 27, 2017
This is a change in strategy.

The motivation is the need to find a good balance between:

  + informing the uninformed that would benefit from this information, &
  + not spamming the already informed

Making it dependent on "compile" being present in remainingCommands will
probably make it trigger for, for example, Maven users who are used to
running "mvn compile" and always run "sbt compile", and who therefore
are unneccesarily suffering terribly slow compile speeds by starting up
the jvm and sbt every time.

Fixes sbt#3091
dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 28, 2017
In sbt 0.13.15, in addition to notifying the user about the existence of
sbt's shell, a feature was added to allow the user to switch to sbt's
shell - a more pro-active approach to just displaying a message.

Unfortunately sbt is often unintentionally invoked in shell scripts in
"interactive mode" when no interaction is expected by, for exmaple,
invoking `sbt package` instead of `sbt package < /dev/null`. In that
case hitting [ENTER] would silently trigger sbt to run its shell,
easily wrecking the script. In addition to that I was unhappy with the
implementation as it created a tight coupling between sbt's command
processing abstraction to sbt's shell command.

If you want to stay in sbt's shell after running a task like `package`
then invoke sbt like so:

    sbt package shell

Fixes sbt#3091
@dwijnand
Copy link
Member

@koertkuipers thanks for your feedback. I've opened #3153 to remove the [ENTER] feature, targeting sbt 0.13.16.

dwijnand added a commit to dwijnand/sbt that referenced this issue Apr 28, 2017
In sbt 0.13.15, in addition to notifying the user about the existence of
sbt's shell, a feature was added to allow the user to switch to sbt's
shell - a more pro-active approach to just displaying a message.

Unfortunately sbt is often unintentionally invoked in shell scripts in
"interactive mode" when no interaction is expected by, for exmaple,
invoking `sbt package` instead of `sbt package < /dev/null`. In that
case hitting [ENTER] would silently trigger sbt to run its shell,
easily wrecking the script. In addition to that I was unhappy with the
implementation as it created a tight coupling between sbt's command
processing abstraction to sbt's shell command.

If you want to stay in sbt's shell after running a task like `package`
then invoke sbt like so:

    sbt package shell

Fixes sbt#3091
eed3si9n pushed a commit to eed3si9n/sbt that referenced this issue May 27, 2017
This is a change in strategy.

The motivation is the need to find a good balance between:

  + informing the uninformed that would benefit from this information, &
  + not spamming the already informed

Making it dependent on "compile" being present in remainingCommands will
probably make it trigger for, for example, Maven users who are used to
running "mvn compile" and always run "sbt compile", and who therefore
are unneccesarily suffering terribly slow compile speeds by starting up
the jvm and sbt every time.

Fixes sbt#3091
Fixes sbt#3097
eed3si9n pushed a commit to eed3si9n/sbt that referenced this issue May 27, 2017
In sbt 0.13.15, in addition to notifying the user about the existence of
sbt's shell, a feature was added to allow the user to switch to sbt's
shell - a more pro-active approach to just displaying a message.

Unfortunately sbt is often unintentionally invoked in shell scripts in
"interactive mode" when no interaction is expected by, for exmaple,
invoking `sbt package` instead of `sbt package < /dev/null`. In that
case hitting [ENTER] would silently trigger sbt to run its shell,
easily wrecking the script. In addition to that I was unhappy with the
implementation as it created a tight coupling between sbt's command
processing abstraction to sbt's shell command.

If you want to stay in sbt's shell after running a task like `package`
then invoke sbt like so:

    sbt package shell

Fixes sbt#3091
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

8 participants