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 1.0.1+ fails on loading resources

See original GitHub issue

Scala code to list resources which works in sbt 0.13.x and SBT 1.0.0 fails in SBT 1.0.1 and 1.1.1

steps

Direct link to the code being run: https://github.com/jdrphillips/sbt-testing/blob/master/src/main/scala/foo/Testing.scala

To see a working version using sbt 0.13.17, checkout the branch 1317 on the same project and complete the same steps. To see SBT 1.0.0, checkout branch 100. The code being run does not change between branches.

The code fails on branches 111 (SBT 1.1.1) and 101 (SBT 1.0.1)

problem

When trying to load resources in SBT 1.0.1+ using getClass.getResource, the path generated is something like:

  • file:/tmp/sbt_2a66a2c6/job-1/target/84311835/sbt-testing_2.12-0.1-SNAPSHOT.jar!/subfolder

when it should be something like:

  • ~/sbt-testing/target/scala-2.12/classes/subfolder

This change has the effect of being unable to list files in a resource directory. java.io.File cannot find the first path.

expectation

The scala code which runs on the 1317 branch should also run on the 111 and 101 branches (sbt versions 1.1.1 and 1.0.1 respectively).

notes

scala version 2.12.4

sbt version: 1.1.1, 1.0.1

Confirmed behaviour on Ubuntu and Mac.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
konradmalikcommented, Nov 18, 2018

Can someone explain why is this marked as closed but the problem still presists in SBT 1.2.6? Whenever I use getClass.getResource in my code I cannot use sbt run because it’ll fail to find the files, this makes sbt run basically unusable. I couldn’t even find any workarounds to this. Suggestions?

6reactions
spydoncommented, Mar 25, 2020

This is still an issue, and should be reopened. You can add the following to your build.sbt as a temporary solution: run := Defaults.runTask(fullClasspath in Runtime, mainClass in run in Compile, runner in run).evaluated

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while importing SBT project - Stack Overflow
I'm using IntelliJ IDE and Scala 2.12 and SBT 1.0.3 to build the project. I have verified the IDE Proxy settings ,its setup...
Read more >
sbt/sbt - Gitter
Hi, I have a question regarding Per-configuration classpath dependencies between modules. I'm working on a project where there's different modules for web ...
Read more >
sbt Reference Manual — sbt 1.0.x releases
sbt 1.0.x releases. sbt 1.0.4. This is a hotfix release for sbt 1.0.x series. Bug fixes. Fixes undercompilation of value classes when the...
Read more >
sbt | IntelliJ IDEA Documentation - JetBrains
When you try to import an sbt project that contains an old version of sbt, you might get an error.
Read more >
Problem with proxy settings for SBT - Cloudera Community
d:\Users\user1>sbt.bat [info] Loading project definition from ... est-jar): typesafe-ivy-releases: unable to get resource for ...
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