Wednesday, November 12, 2014

Fixing pub build on debian

After a long break I'm giving dart a second try this time with the newly released angular dart 1.0 in mind. It didn't took long to hit a problem when trying to integrate the code with the automated deployment jobs we run at koparo.com.

Google does provide sdk packages for debian though out of the box when you try pub build with an angular app you will probably hit the following problem:
Error loading transformer: Illegal argument(s): sdkDirectory must be provided.

This issue was already reported a long time ago here, here & here.

After taking a closer look at the code and the default pub distributed with the apt packages shipped by Google I came up with a solution requiring only a symlink from /opt/sdk-dart to /usr/lib/dart
ln -s /usr/lib/dart /opt/dart-sdk
and a one line change in the /usr/lib/dart/bin/pub file changing the following line
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
to

BIN_DIR=/opt/dart-sdk/bin
You can save the modified /usr/lib/dart/bin/pub to a local file if you don't want to modify the system wide install. Assuming that you saved your changes to /home/user/pub you can run the new pub successfully no longer hitting the mentioned error.
chmod u+x /home/user/pub
/home/user/pub build