Hadoop, Pig, and Broken Dreams of Environment Variables
Join the DZone community and get the full member experience.
Join For FreeUnfortunately there doesn’t seem to be a Debian package for it, at least not in the set of repositories I have available to me on this machine so I thought I’d just compile it – it is dynamically loadable from an arbitrary path in a Pig script so this is not a big issue. The process is two-fold:
- Compile Pig itself (or locate the pig-withouthadoop.jar pre-compiled on your system)
- Compile Piggybank against that version of Pig
Pig uses the Ant build system, and it really is as trivial as running ant from the top-level directory. I checked out the tagged release of 0.10.0 and successfully built Pig. Building Piggybank against it, however, errored out with something I wasn’t immediately able to find on the interwebs:
$ ant Buildfile: /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml init: [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test/classes [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/docs/api compile: [echo] *** Compiling Pig UDFs *** [javac] /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 154 source files to /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes [javac] error: error reading /home/oliver/release-0.10.0/pig-withouthadoop.jar; invalid header field [javac] 1 error BUILD FAILED /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: Compile failed; see the compiler error output for details. Total time: 0 seconds
Now, I’m not a Java guy so this means very little to me. However I do at least know that a Jar file is simply a zip archive so I went digging. Assuming that the ‘invalid header field’ is in the metadata of the Jar file, I looked in the contained META-INF/MANIFEST.MF:
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.0 Created-By: 1.6.0_26-b03 (Sun Microsystems Inc.) Main-Class: org.apache.pig.Main Name: org/apache/pig Implementation-Vendor: Apache Implementation-Title: Pig Implementation-Version: 0.10.0-SNAPSHOT Build-TimeStamp: Sep 12 2012, 08:14:45 Svn-Revision: svnversion: warning: cannot set LC_CTYPE locale svnversi on: warning: environment variable LC_CTYPE is UTF-8 svnversion: warni ng: please check that your locale name is correct 1383830
It seems that some locale settings in the environment are causing issues with the svnversion program, and indeed when running it separately I can confirm the same issue:
~/release-0.10.0$ svnversion svnversion: warning: cannot set LC_CTYPE locale svnversion: warning: environment variable LC_CTYPE is UTF-8 svnversion: warning: please check that your locale name is correct 1383830
I’ve been seeing this on a bunch of machines I’ve been using recently but frankly I haven’t had the time to diagnose it. It is easily worked around with unset LC_CTYPE:
~/release-0.10.0$ unset LC_CTYPE ~/release-0.10.0$ svnversion 1383830
There's some contention around adding superfluous metadata fields in Ant builds, but again, this is something I don’t particularly care to dive into at the moment. An acceptable alternative workaround in this case would have been to remove the additional metadata generation in the Ant build.xml.
Rebuilding Pig now and Piggybank against it works. Huzzah! On to the next problem.Published at DZone with permission of Oliver Hookins, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments