golem-add-scala-dependency

Adds Scala.js-compatible library dependencies to Golem Scala component build.sbt files.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-add-scala-dependency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-add-scala-dependency
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/scala/golem-add-scala-dependency
Command: npx skills add https://github.com/golemcloud/golem --skill golem-add-scala-dependency

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding third-party libraries to a Golem Scala project is error-prone because components compile to WebAssembly via Scala.js, so only Scala.js-compatible artifacts work. This Skill guides the correct way to declare dependencies and verify them.

Core Features & Use Cases

  • Correct dependency declaration: Adds libraries to build.sbt using the %%% operator so sbt resolves the _sjs1_ Scala.js cross-published variant instead of the JVM artifact.
  • Build verification: Runs golem build --yes (never sbt compile directly) to confirm the library compiles to WebAssembly.
  • Failure diagnosis: Helps identify missing Scala.js artifacts, JVM-only transitive dependencies, and suggests Scala.js-compatible alternatives.
  • Use Case: When you want to add an HTTP or utility library to a Golem Scala agent, this Skill ensures you pick a Scala.js-published version and avoid JVM-only APIs like java.net or reflection.

Quick Start

Add the Scala.js-compatible library I need to my Golem Scala project's build.sbt and verify it with golem build.

Frequently Asked Questions about golem-add-scala-dependency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a library dependency to a Scala.js project in build.sbt?

Add the library under libraryDependencies in build.sbt using the %%% operator, for example libraryDependencies += "com.example" %%% "library-name" % "1.0.0". The triple percent tells sbt to resolve the _sjs1_ Scala.js cross-published variant.

How do I add a dependency to a Golem Scala component?

Edit the component's build.sbt and add the library with %%% so the Scala.js artifact is resolved, then run golem build --yes to verify. Do not run sbt compile directly; always use golem build.

Can I use any JVM library in a Scala.js WebAssembly project?

No. Libraries depending on JVM-specific APIs such as reflection, java.io.File, java.net.Socket, or threads will not work. Only pure Scala libraries and libraries published for Scala.js are compatible.

Why does my build fail after adding a Scala library dependency?

The library may not publish a Scala.js artifact or may pull in JVM-only transitive dependencies. Check the Maven or Sonatype listing for an _sjs1_ variant, inspect the dependency tree, or find a Scala.js-compatible alternative.

How do I make HTTP requests in a Golem Scala component?

Use the Golem SDK's HTTP client utilities. Standard JVM networking through java.net is not available in Scala.js and WebAssembly environments.