问题
Similar to this question I'd like to stop sbt from spamming the shell with messages and blank lines. It stops if I run sbt with the option sbt -Dsbt.supershell=false
, but I'd like to disable it globally via a dotfile in ~/.sbt
or similar. I could replace the sbt
binary with a wrapper which always adds this option, but that seems inelegant.
I've tried each of the following in a file called ~/.sbt/1.0/global.sbt
and ~/.sbt/1.3/global.sbt
, but none have an effect:
sbt.supershell := false
useSuperShell := false
sbt.useSuperShell := false
useSuperShell := false
supershell := false
ThisBuild / useSuperShell := false
As an example of what I'm trying to avoid, here's what happens when I start sbt
for a project I'm working on (a similar amount of spam gets sprinkled around when compiling, testing, etc.):
$ sbt
[info] Loading settings for project global-plugins from metals.sbt ...
[info] Loading global plugins from /Users/chris/.sbt/1.0/plugins
| => global-plugins / updateCacheName 0s
| => global-plugins / updateCacheName 0s
| => Global / skip 0s
| => global-plugins / updateCacheName 0s
| => Global / skip 0s
| => global-plugins / updateCacheName 0s
| => global-plugins / updateCacheName 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / scalaCompilerBridgeResolvers 0s
| => global-plugins / Compile / externalHooks 0s
| => global-plugins / Compile / externalHooks 0s
| => global-plugins / dependencyPositions 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / moduleSettings 0s
| => global-plugins / csrConfiguration 0s
| => global-plugins / projectDescriptors 0s
| => global-plugins / dependencyPositions 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / csrRecursiveResolvers 0s
| => global-plugins / moduleSettings 0s
| => global-plugins / csrConfiguration 0s
| => global-plugins / projectDescriptors 0s
| => global-plugins / dependencyPositions 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / csrRecursiveResolvers 0s
| => global-plugins / moduleSettings 0s
| => global-plugins / csrConfiguration 0s
| => global-plugins / projectDescriptors 0s
| => global-plugins / dependencyPositions 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / update 0s
| => global-plugins / Runtime / unmanagedClasspath 0s
| => global-plugins / update 0s
| => global-plugins / Compile / previousCompile 0s
| => global-plugins / Compile / compileIncremental 0s
| => global-plugins / Compile / compileIncremental 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 0s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 1s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 2s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 3s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 4s
| => <anon-3eb292cd> 5s
[info] Loading project definition from /Users/chris/repos/scalacheck-demo/project
| => scalacheck-demo-build / bootResolvers 0s
| => scalacheck-demo-build / bootResolvers 0s
| => scalacheck-demo-build / bootResolvers 0s
| => scalacheck-demo-build / bootResolvers 0s
| => scalacheck-demo-build / otherResolvers 0s
| => scalacheck-demo-build / dependencyPositions 0s
| => scalacheck-demo-build / dependencyPositions 0s
| => Global / classpathEntryDefinesClass 0s
| => scalacheck-demo-build / Compile / discoveredSbtPlugins 0s
| => scalacheck-demo-build / csrFallbackDependencies 0s
| => scalacheck-demo-build / Compile / unmanagedSources / allInputPathsAndAttributes 0s
| => scalacheck-demo-build / Compile / externalHooks 0s
| => scalacheck-demo-build / Compile / compileIncremental 0s
[info] Loading settings for project scalacheck-demo from secrets.sbt,build.sbt ...
[info] Set current project to scalacheckdemo (in build file:/Users/chris/repos/scalacheck-demo/)
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / previousCache 0s
| => Global / checkBuildSources 0s
| => Global / fileTreeView 0s
| => Zero / checkBuildSources / dynamicInputs 0s
| => Global / fileTreeView 0s
| => Global / previousCache 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / previousCache 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / fileTreeView 0s
| => Global / previousCache 0s
| => Global / fileTreeView 0s
[info] sbt server started at local:///Users/chris/.sbt/1.0/server/bba992971696ad25eaa9/sock
sbt:scalacheckdemo>
回答1:
sbt launcher script provides sbt -help
which should printout the location of global configuration which on my machine after running brew install sbt
to install sbt 1.3.12 gives
SBT_OPTS environment variable, if unset uses ""
.sbtopts if this file exists in the current directory, its contents
are prepended to the runner args
/usr/local/etc/sbtopts if this file exists, it is prepended to the runner args
So try putting
-Dsbt.supershell=false
in /usr/local/etc/sbtopts
which is sbt's system-wide configuration file. However I can see that the default location specified in source code is /etc/sbt/sbtopts
which then brew
seems to replace
s.gsub! 'etc_sbt_opts_file="/etc/sbt/sbtopts"', "etc_sbt_opts_file=\"#{etc}/sbtopts\""
hence I think the safest bet is to just run sbt -h
to see what is the value on your machine. I am not familiar with nixpkgs but you could have a look at the its source for sbt, or directly analyse etc_sbt_opts_file
variable in the resulting sbt launcher script with perhaps
vim `which sbt`
来源:https://stackoverflow.com/questions/62230806/globally-disable-sbt-supershell