Question

I've been experimenting with buildr in lieu of maven on a project.

When I request the transient dependencies for a given package, I get this error:

$ buildr --trace=all
...
** Invoke /home/tcc/timd/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.pom (first_time, not_needed)
Loading m2 pom file from /home/tcc/timd/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.pom
** Invoke /home/tcc/timd/.m2/repository/org/slf4j/slf4j-parent/1.5.6/slf4j-parent-1.5.6.pom (first_time, not_needed)
Loading m2 pom file from /home/tcc/timd/.m2/repository/org/slf4j/slf4j-parent/1.5.6/slf4j-parent-1.5.6.pom
** Invoke /home/tcc/timd/.m2/repository/org/apache/commons/commons-exec/1.0/commons-exec-1.0.pom (first_time, not_needed)
Loading m2 pom file from /home/tcc/timd/.m2/repository/org/apache/commons/commons-exec/1.0/commons-exec-1.0.pom
Buildr aborted!
ArgumentError : invalid byte sequence in US-ASCII
...
$

I can confirm that the file commons-exec-1.0.pom has non US-ASCII characters. But I believe they are valid UTF-8.

The troublesome files is from a third party, so I can't easily change it. Is there something I can do to have buildr process it correctly?

Was it helpful?

Solution

I believe there's a bug in the way buildr reads POMs on Ruby 1.9 (or compatible) rubies. It assumes that the POM's XML can be read in the ruby's default external encoding. On my machine with ruby 1.9.3-p194 that encoding is UTF-8 (so the commons-exec POM is read fine), but in your environment the default encoding seems to be US-ASCII (causing your problem). You could confirm this by putting puts Encoding.default_external.inspect somewhere in your buildfile and seeing what it gives you.

So long as all the files you want buildr to read are UTF-8 (or UTF-8 compatible, like ASCII), you should be able to work around this problem by putting the following at the top of your buildfile:

Encoding.default_external = 'UTF-8'

See if that works. If it does, I encourage you to file a bug against buildr so that they know about the problem. (In general, you do not want to be messing with Encoding.default_external since it's a global setting.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top