sbt, the interactive build tool
Go to file
Alonso Montero 86fd6dc058
Use XDG_RUNTIME_DIR environment variable to choose the path used for the creation of sockets (#6887)
The `XDG_RUNTIME_DIR` environment variable will be used to choose the base directory in which the sockets will be created by **sbt**. This can help when issues such as #6777 appear. There are other related issues, such as #6101, [Metals issue #2235](https://github.com/scalameta/metals/issues/2235), [Che issue #18394](https://github.com/eclipse/che/issues/18394). Those are closed issues, but there are some cases in which the solution does not work (such as the case in #6777). Furthermore, the solution given seems more like a workaround than an actual fix.

**What causes this issue?**
At least in my case, the **ServerAlreadyBootingException** is thrown after **sbt** tries to create a Unix domain socket and fails. In my specific environment, I was not able to create the sockets in some directories because they were mounted on an NFS. This prevented me from using any automated sbt command on any of those directories (Metals uses sbt under the hood, and it was not able to start because of the ServerAlreadyBootingException), which in turn resulted in me not being able to use Metals on a project that was created on any of those directories. 

**How is the issue solved in this PR?**
If the `XDG_RUNTIME_DIR` environment variable is set, then sockets will be created in a folder with a hashed name, inside the directory `XDG_RUNTIME_DIR/.sbt/`. If this variable is not set, everything works exactly the same as always.

Let's see an example:

1. My environment variable `XDG_RUNTIME_DIR` is set to /home/alonso/.runtime-dir`
2. I create my project in `/home/alonso/workspace/hello-world`
3. I run `sbt compile`
4. The socket is created in `/home/alonso/.runtime-dir/.sbt/sbt-socket102030405060/sbt-load.sock`. The number **102030405060** is a hash that is computed from the base directory of the project (it is actually the same hash that is produced in order to create sockets in Windows) and it will be different depending on the location of the project
5. The sbt command executed correctly, which would not have happened if the socket had been created in the `home/alonso/workspace` directory or any of its subdirectories (in this example, `/home/BlackDiamond/workspace` corresponds to a network file share)

Co-authored-by: Alonso Montero <lumontero@mobilize.net>
2022-05-26 23:10:41 -04:00
.github Bump actions/setup-java from 2 to 3 2022-04-11 04:02:44 +00:00
client Change remaining sbtc to sbtn 2020-08-15 09:35:59 -07:00
core-macros/src/main/scala/sbt/internal/util/appmacro Use fully qualified name in the macro 2021-03-09 11:55:29 -05:00
dependency-tree/src/main/scala/sbt/plugins Split to MiniDependencyTreePlugin 2020-09-22 21:21:01 -04:00
internal Merge pull request #6839 from sbt/1.7.x 2022-03-18 12:17:26 -04:00
launch launcher 1.3.3 2021-07-11 02:04:48 -04:00
launcher-package launcher: debian package to depend on curl | wget 2022-02-21 17:38:18 +09:00
licenses move remaining pieces of sbt subproject to sbt_pending and fix notices 2010-09-21 21:55:50 -04:00
main fix typo 2022-05-23 07:37:34 +09:00
main-actions/src Fix #6738: register all forked process 2021-12-06 09:12:38 +01:00
main-command/src Use XDG_RUNTIME_DIR environment variable to choose the path used for the creation of sockets (#6887) 2022-05-26 23:10:41 -04:00
main-settings/src Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn 2021-11-14 21:53:57 -05:00
notes Enable the asciiGraphWidth setting to the dependencyTree tasks. #5962 2021-10-19 02:15:31 +09:00
project Try fix CI: Build and test (6) 2022-03-08 18:19:20 +01:00
protocol/src/main feat: generate JVM environment requests 2022-04-06 09:09:51 +02:00
run Fix #6738: register all forked process 2021-12-06 09:12:38 +01:00
sbt-app/src Restore watchOnTermination 2022-04-09 15:49:10 -07:00
scripted-plugin/src/main/scala/sbt -Xfatal-warnings in most subprojects 2018-09-18 11:47:55 -04:00
scripted-sbt-old/src/main/scala/sbt/test Move scripted-sbt-old ScriptedTests file 2020-11-03 09:02:18 -08:00
scripted-sbt-redux Make javaHome that forks scripted tests configurable 2021-10-05 00:35:56 +09:00
server-test/src tests: run&test environment requests 2022-04-06 09:09:51 +02:00
src/main/conscript sbt 1.3.0 2019-09-04 01:24:08 -04:00
tasks fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
tasks-standard fix Scala 2.13 warnings 2021-11-14 22:59:34 +09:00
testing Merge pull request #6839 from sbt/1.7.x 2022-03-18 12:17:26 -04:00
util-cache Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn 2021-11-14 21:53:57 -05:00
util-tracking Merge pull request #6711 from xuwei-k/fix-scala-2-13-warn 2021-11-14 21:53:57 -05:00
vscode-sbt-scala https://www.apple.com 2019-09-05 14:11:07 -04:00
zinc-lm-integration/src Update scalatest 2021-11-14 22:03:59 +09:00
.appveyor.yml Update Jave version to 1.8.0-275 on AppVeyoer 2021-02-15 22:46:06 -05:00
.gitattributes Fix line endings in msi 2021-11-19 20:41:39 -05:00
.gitignore Remove log4j 2021-12-03 17:13:29 +00:00
.java-version Configure JVM 1.8 in .java-version 2016-10-07 08:48:23 -05:00
.mailmap Add mailmap 2019-06-11 09:30:14 +02:00
.sbtopts Restore .sbtopts file 2020-11-19 12:42:26 -08:00
.scalafmt.conf SourcePositionMacro for Scala 3 2021-11-16 16:32:31 +09:00
CONTRIBUTING.md https://www.scala-sbt.org 2019-09-05 14:11:13 -04:00
DEVELOPING.md Follow up on Scala 2.12.15 bump 2021-09-18 18:08:26 -04:00
LICENSE Apache License 2.0 2018-09-14 03:38:58 -04:00
NOTICE Apache License 2.0 2018-09-14 03:38:58 -04:00
PROFILING.md fix typo 2018-07-08 22:18:57 +09:00
README.md Update CI status badge in README 2022-01-17 13:27:21 +09:00
SUPPORT.md Split support into SUPPORT.md 2018-04-25 14:55:09 +01:00
build.sbt Update semanticdbVersion 2022-04-16 21:53:32 +09:00
reset.sh 1.0.3-SNAPSHOT 2017-09-16 15:52:58 -04:00
sbt Merge pull request #6839 from sbt/1.7.x 2022-03-18 12:17:26 -04:00
sbt-allsources.sh Build from fresh modules 2020-11-14 14:23:48 -05:00
sbt.sh Implement sbt-launch.jar download 2021-04-19 23:43:15 -04:00
server.md setting query is "sbt/setting" 2017-10-03 01:45:06 -04:00

README.md

CI Latest version Gitter Chat

sbt

sbt is a build tool for Scala, Java, and more.

For general documentation, see https://www.scala-sbt.org/.

sbt 1.x

This is the 1.x series of sbt. The source code of sbt is split across several GitHub repositories, including this one.

  • sbt/io hosts sbt.io module.
  • sbt/librarymanagement hosts sbt.librarymanagement module that wraps Ivy.
  • sbt/zinc hosts Zinc, an incremental compiler for Scala.
  • sbt/sbt, this repository hosts modules that implements the build tool.
  • Setup: Describes getting started with the latest binary release.
  • FAQ: Explains how to get help and more.
  • sbt/sbt-zero-seven: hosts sbt 0.7.7 and earlier versions

Issues and Pull Requests

Please read CONTRIBUTING carefully before opening a GitHub Issue.

The short version: try searching or asking on StackOverflow.

license

See LICENSE.