Skip to content

Commit

Permalink
Improve bleep binary detection for bleep setup-ide (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg authored Dec 5, 2022
1 parent ed555a4 commit 7900106
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bleep-cli/src/scala/bleep/commands/SetupIde.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ case class SetupIde(buildPaths: BuildPaths, logger: Logger, maybeSelectedProject
)(x => (x.getName, x.getArgv, x.getVersion, x.getBspVersion, x.getLanguages))

override def run(): Either[BleepException, Unit] = {
val bleepExecutablePath: Path = (new Argv0).get(null) match {
case null =>
val maybeExecutablePath = Option((new Argv0).get(null))
.map {
case absolute if absolute.startsWith("/") =>
Path.of(absolute)
case relative =>
internal.Os.cwd / relative
}
.filter(Files.isRegularFile(_))
.filter(Files.isExecutable)

val bleepExecutablePath: Path =
maybeExecutablePath.getOrElse {
val latestRelease = model.BleepVersion.current.latestRelease
logger.warn(s"couldn't determine name of Bleep executable. Setting up version ${latestRelease.value}")
FetchBleepRelease(latestRelease, new BleepCacheLogger(logger), ec).orThrow
case absolute if absolute.startsWith("/") =>
Path.of(absolute)
case relative =>
internal.Os.cwd / relative
}
}

val details = new bsp4j.BspConnectionDetails(
"bleep",
Expand Down

0 comments on commit 7900106

Please sign in to comment.