Previously my application workspace looked basically like this:
/foo/WORKSPACE
/foo/my_appengine_dir/
/foo/my_appengine_dir/BUILD
/foo/my_appengine_dir/webapp/
...
/foo/my_appengine_ui/
...
The ui module is a dart module and because of this issue (
https://youtrack.jetbrains.com/issue/WEB-24605) I ended up moving my project WORKSPACE file into /foo/my_appengine_dir/ as the dart UI wasn't really using bazel yet anyway. After I did that, however, I got this error when running the appengine dev server:
/home/jesse/.cache/bazel/_bazel_jesse/913e32167429706965f96523edb1ecb0/execroot/my-appengine-app/bazel-out/local-fastbuild/bin/my_appengine_app: line 42: cd: my_appengine_app.wa/webapp/: No such file or directory
Dec 22, 2016 9:46:55 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing /home/jesse/.cache/bazel/_bazel_jesse/913e32167429706965f96523edb1ecb0/execroot/my-appengine-app/bazel-out/local-fastbuild/bin/my_appengine_app.runfiles/__main__/WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Could not locate /home/jesse/.cache/bazel/_bazel_jesse/913e32167429706965f96523edb1ecb0/execroot/my-appengine-app/bazel-out/local-fastbuild/bin/my_appengine_app.runfiles/__main__/WEB-INF/appengine-web.xml
at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:141)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:75)
The no such file or directory error occurs in the runner template where the script tries to change to the 'data_path' directory. In my build file the appengine_war() rule sets the data_path to "webapp/", something like this:
load("@io_bazel_rules_appengine//appengine:appengine.bzl", "appengine_war")
java_library(
name = "my_lib",
...
)
appengine_war(
name = "my_appengine_app",
data = glob(["webapp/**/*"]),
data_path = "webapp/",
jars = [":my_lib"],
)
After a bit of print debugging, I discovered that with the new directory structure, the _short_path_dirname() function didn't seem to be producing the correct result. It was returning a data_path of "my_appengine_app.wa"--note the missing 'r'. The last line, 'return sp[0:len(sp)-len(path.basename)-1]', was evaluating to sp[0:-1], which is clearly incorrect.
I'm not really familiar with bazel APIs, but in my case the short path and base name in that function were the same (after changing the directory structure as above), and I assumed that it was trying to compute the directory name of the app module directory (previously 'my_appengine_dir'). After my directory layout change, the app directory is actually '.' (relative to the WORKSPACE file).
I'm not sure if the patch is correct either, but it fixes my particular issue.
Jesse