question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sbt.ivy.home and ivy.home properties both required

See original GitHub issue

Steps

  • Create a project for developing a plugin using the scripted plugin.
  • Run sbt scripted with sbt.ivy.home pointing to custom location that is not ~/.ivy2

Problem

  • When the tests run they pull dependencies from a location not specified by sbt.ivy.home, failing tests because they are unable to find the jars published during the publishLocal step

Expectations

  • The publishLocal task will place the plugin jar in the location specified by sbt.ivy.home
  • The scripted tasks will run and dependencies will be pulled from sbt.ivy.home

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
a1kemistcommented, Oct 29, 2019

As @olafurpg points out, this makes it very difficult to run scripted tests in CI where you need to point to a custom ivy.home. Is there any workaround that someone has found?

This is what I tried to do for my situation:

export SBT_OPTS="-Dsbt.global.base=$CI_PROJECT_DIR/sbt-cache/.sbtboot -Dsbt.boot.directory=$CI_PROJECT_DIR/sbt-cache/.boot -Dsbt.ivy.home=$CI_PROJECT_DIR/.ivy"

Where CI_PROJECT_DIR is an env variable set by ci. Then in scripted.sbt I added the following (because apparently SBT_OPTS aren’t respected by the scripted task):

scriptedLaunchOpts := { scriptedLaunchOpts.value ++
    Seq("-Xmx1024M", "-Dplugin.version=" + version.value) ++
    // append SBT_OPTS so scripted launches with the correct cache dirs
    sys.env.get("SBT_OPTS").map(x => x.split(" ").toSeq).getOrElse(Nil)
}
scriptedBufferLog := false

This worked for most of the plugin projects I have been working on, but recently started failing again during a refactor.

After some investigation into that project, I found that the particular issue was due to scoping issues. Inspecting the value of scriptedLaunchOpts for the actual plugin project, revealed that it was missing my passthrough for SBT_OPTS. Adding those settings to my project specific settings made everything resolve properly after that.

I hope this helps someone else running into a similar issue with a custom sbt.ivy.home and running scripted tests for sbt plugins.

0reactions
kterusakicommented, Jun 14, 2022

any update on this? As @a1kemist has pointed out, this the scripted plugin useless if we can’t run it in CICD where we need to point to a custom sbt.ivy.home.

I have the following as my scriptedLaunchOptions:

scriptedLaunchOpts := {
    scriptedLaunchOpts.value ++
      Seq("-Xmx1024M", "-Dplugin.version=" + version.value, "-Dsbt.ivy.home=" + sys.props.get("sbt.ivy.home"))
  }

And I’m passing the sbt.ivy.home system property to sbt like so:

sbt -Dsbt.ivy.home=$HOME/.ivy-custom/ scripted

The error output is:

....
	Note: Unresolved dependencies path:
[info] [error] sbt.librarymanagement.ResolveException: Error downloading my.org:my-project;sbtVersion=1.0;scalaVersion=2.12:5.0-SNAPSHOT
[info] [error]   Not found
[info] [error]   Not found
[info] [error]   not found: /private/var/folders/4x/8xntqh9d3310fgv5s6ncn1980000gp/T/sbt_5918511/Some/Users/me/.ivy-custom/local/my.org/my-project/scala_2.12/sbt_1.0/5.0-SNAPSHOT/ivys/ivy.xml

The sbt.ivy.home system property is treated as a relative URL to the tmp directory used to scope the sbt plugin test. I’m not sure what the right fix is here. If everything needs to be scoped by the /private/var/... directory then maybe the scripted plugin should copy the local snapshot to this folder?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure Ivy cache directory per-user or system-wide?
The sbt.ivy.home property is only half of the solution. It controls where the sbt launcher downloads sbt itself (and related dependencies ...
Read more >
sbt Reference Manual — Library Management
Ivy configurations are a useful feature for your build when you need custom groups of dependencies, such as for a plugin. Ivy configurations...
Read more >
How to configure Ivy cache directory per-user or system-wide
The sbt.ivy.home property is only half of the solution. It controls where the sbt launcher downloads sbt itself (and related dependencies like the...
Read more >
Appendix A. What you need to know about Ivy - sbt in Action
Aether is extracted from the build tool known as Maven, whereas Ivy was built from scratch. Both tools are able to interoperate with...
Read more >
Sbt: Dear Dependency Managment - Medium
By default, SBT uses the standard Ivy home directory location ${user.home}/.ivy2/ . What if I would like to create a dir and ask...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found