mdedetrich / sbt-bower

A SBT wrapper around Twitter's bower
Other
16 stars 8 forks source link

Cannot find 'bower' #5

Open Christewart opened 9 years ago

Christewart commented 9 years ago

I am getting an error when I am trying to go through the tutorial saying that sbt cannot find bower on the following line of code:

web/build.sbt:28: error: not found: value Bower BowerKeys.installDirectory <<= (sourceDirectory in Bower) (_ / "js" / "myStuffGoesHere")

I ran 'sudo npm install bower' in my application directory before running 'sbt compile', so I am not sure why I am getting this error.

alexflav23 commented 9 years ago

Hi @Christewart, the Bower object can be found like this:

BowerKeys.installDirectory <<= (sourceDirectory in BowerKeys.Bower) (_ / "js" / "myStuffGoesHere")

Or simply import BowerKeys._ at the top of your build definition.

shepdl commented 9 years ago

This was very helpful! I'm actually facing a similar issue. I wanted to define my installDirectory like so:

BowerKeys.sourceDirectory <<=  baseDirectory ( _ / "app" / "assets" )
BowerKeys.installDirectory <<= (sourceDirectory) ( _ / "lib" )

But when I run bower:install, I get the following:

java.util.NoSuchElementException: head of empty list
at scala.collection.immutable.Nil$.head(List.scala:337)
at scala.collection.immutable.Nil$.head(List.scala:334)
at SbtBowerPlugin$$anonfun$setupFilesTask$1.apply(SbtBowerPlugin.scala:28)
at SbtBowerPlugin$$anonfun$setupFilesTask$1.apply(SbtBowerPlugin.scala:23)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
[error] (bower:install) java.util.NoSuchElementException: head of empty list

I think I've traced that to Line 28 in SbtBowerPlugin.scala, the step where it tries to determine the installDirectory. It looks to me like the plugin expects a relative path, but I'm not sure how to specify that. I tried (sourceDirectory in BowerKeys.Bower) (_ / "js" / "myStuffGoesHere") and that works if I create the appropriate directory structure (src/main/webapp/js/myStuffGoesHere), but I'd rather not using that particular directory structure, because I'm not using xsbt-web-plugin. sbt-bower seems to always insert "main/webapp" into the path. Do you have any suggestions? I'd really like to be able to make the installDirectory something like [myProjectBase]/app/assets/javascripts/lib.

mdedetrich commented 9 years ago

It seems you are using the wrong config. Try using sourceDirectory in Bower, i.e.

BowerKeys.installDirectory <<=  (sourceDirectory in Bower) (_ / "lib")

rather than

BowerKeys.installDirectory <<= (sourceDirectory) ( _ / "lib" )