18

I am trying to build simple hello world SBT-Scala project using IntelliJ.

When I tried to created the project for the first time, after installing the scala/ SBT plugins, I am getting the following error:

Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving org.scala-lang#scala-reflect;2.11.8 ...
[info] Resolving org.scala-lang#scala-reflect;2.11.8 ...
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[info] Resolving org.scala-lang.modules#scala-parser-combinators_2.11;1.0.4 ...
[info] Resolving jline#jline;2.12.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang:scala-reflect:2.11.8
[warn]        +- org.scala-lang:scala-compiler:2.11.8
[warn]        +- default:supersimplerootscalasbt3_2.11:1.0
[trace] Stack trace suppressed: run 'last *:ssExtractProject' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractProject) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[error] Total time: 3 s, completed 22 May, 2017 4:42:05 PM</pre><br/>See complete log in <a href="file:/root/.IdeaIC2017.1/system/log/sbt.last.log">file:/root/.IdeaIC2017.1/system/log/sbt.last.log</a>

Any idea how to solve the origin location must be absolute error in this?

[Kindly note that I am able to find the file scala-reflect-2.11.8.pom unlike the error specifies: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom]

My build.sbt file:

name := "SuperSimpleRootScalaSBT4"

version := "1.0"

scalaVersion := "2.11.8"

My sbt version is 0.13.15.

  • You appear to be trying to use a local _Maven_ repository. Do you have a `/root/.sbt/repositories` file defined? Is so, what are its contents? Alternatively, do you have a `resolver` defined for your local _Maven_ repository? – Mike Allen May 23 '17 at 02:02
  • @MikeAllen, No `/root/.sbt/repositories` is not defined. Also, I tried defining the resolver like this: `resolvers += Resolver.mavenLocal`, the same error. I identified that the problem is occurring for only `scala version: 2.11.8`, not for above or below. –  May 23 '17 at 07:17
  • 2
    Could it be a file permission issue? Do you have the rights to access `/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom`? Altnernatively, it could also be a corrupted _Ivy_ repository. Try deleting `/root/.ivy2` then rebuilding. (This directory is just a cache of downloaded artifacts - there's no issues deleting it. You could rename it instead if you're in any doubt.) – Mike Allen May 23 '17 at 14:25

5 Answers5

31

For me deleting my ~/.ivy2 helped

Arkadiusz Bicz
  • 486
  • 4
  • 6
  • 1
    This can solve the problem, but if you have other projects it might damage them and requires them to be build again. So maybe deleting some some only specific files or directories in ` ~/.ivy2` could be better, instead of deleting it all. – Arsinux Apr 19 '18 at 09:54
  • Only you can have problems when your projects depending on the local publishing of artifacts, but when used with external service like artifactory nothing wrong happen. – Arkadiusz Bicz Apr 19 '18 at 10:23
  • I am also facing same issue https://stackoverflow.com/q/54176184/3301316 – Jet Jan 14 '19 at 09:14
6

Deleting ~/.ivy2 works, but not the best option, then you have to download all the cache again. Rather delete the particular directory from cache where you are facing issue.

In your case, it should be ~/.ivy2/cache/scala.lang and rebuild

deo
  • 916
  • 7
  • 8
1

i was facing the same issue:
instead of of deleting the .ivy folder, just back it up (rename the folder .ivy2 as .ivy2.backup in instance), then test again eg
$ sbt new scala/hello-world.g8
the project should be created and set up correctly now

0

For me helped when I granted permissions for full Maven repo:

chmod -R 755 /Users/<your_user>/.m2/
0

Deleting the specific dependency from ~/.ivy2/ worked for me. At times it is not a good idea to remove all dependencies as it takes long time to get them back onto the machine.

Devendra Singh
  • 81
  • 1
  • 2
  • 9