全局禁用 sbt 的 SuperShell

3
这个问题类似,我想停止sbt向Shell发送消息和空行。如果我使用选项sbt -Dsbt.supershell=false运行sbt,则会停止,但我想通过在~/.sbt或类似位置的点文件中全局禁用它。我可以用一个包装器替换sbt二进制文件,该包装器总是添加此选项,但这看起来不太优雅。
我已经尝试在名为~/.sbt/1.0/global.sbt~/.sbt/1.3/global.sbt的文件中尝试了以下每个选项,但都没有效果:
sbt.supershell := false
useSuperShell := false
sbt.useSuperShell := false
useSuperShell := false
supershell := false
ThisBuild / useSuperShell := false

作为我尝试避免的一个例子,以下是我启动正在工作中的项目时发生的情况(编译、测试等过程中会散布类似数量的垃圾信息):

sbt

$ 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
你的 .bashrc 或者 .zshrc 文件中加入 alias sbt="sbt -Dsbt.supershell=false" 怎么样? - Mateusz Kubuszok
1个回答

7

sbt启动脚本提供了sbt -help命令,该命令应该会打印出全局配置文件的位置。在我的电脑上,安装sbt 1.3.12之后运行brew install sbt,全局配置文件的位置如下:

  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

所以尝试放置

-Dsbt.supershell=false

/usr/local/etc/sbtopts 中,这是 sbt 的系统范围配置文件。然而,我可以看到 source 代码中指定的默认位置是 /etc/sbt/sbtopts,然后 brew 似乎会 替换

s.gsub! 'etc_sbt_opts_file="/etc/sbt/sbtopts"', "etc_sbt_opts_file=\"#{etc}/sbtopts\""

因此,我认为最安全的选择是运行sbt -h以查看您的机器上的值。我不熟悉nixpkgs,但您可以查看其source,了解sbt的相关信息,或直接分析生成的sbt启动脚本中的etc_sbt_opts_file变量。
vim `which sbt`

在项目目录中,SBT_OPTS.sbtopts都可以工作,但是/usr/local/etc/sbtopts(在macOS上)对我来说不起作用。 我还尝试了/etc/sbtopts~/.sbtopts是否能够起作用,但不幸的是它们也不起作用 :( - Warbo
我接受了这个答案,因为在每个项目中放置.sbtopts并不太糟糕:我可以在.gitignore中标记它,而且不会影响其他开发人员。 - Warbo
@Warbo 你是用 brew install sbt 安装的吗? - Mario Galic
不,它是使用Nix(nixpkgs和nix-darwin)安装的 https://github.com/Warbo/nix-config/blob/master/overrides/metaPackages.nix#L71 - Warbo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接