I'm trying to build bazel on a Windows machine, but bazel build //src:bazel does not find any target to build:
$ bazel build //src:bazel
Loading:
Loading: 0 packages loaded
INFO: Analysed 0 targets (0 packages loaded).
INFO: Found 0 targets...
[0 / 1] [-----] BazelWorkspaceStatusAction stable-status.txt
INFO: Elapsed time: 0.389s, Critical Path: 0.01s
INFO: Build completed successfully, 1 total action
To be clear: This is happening only with master, I was able to build the 0.10.1 dist version of Bazel (from github) on my Windows machine.
To make sure my 0.10.1 binary is okay I built the cpp example (//examples/cpp:hello-world). It worked as expected - no failures.
I was able to build a stable dist version (namely, 0.10.1)bazel master on a Linux and macOS machines.
Any help here would be greatly appreciated.
It looks like you are running Bazel from MSYS Bash. This is no longer necessary, because Bazel is a native Windows binary since version 0.5.0.
MSYS thinks the argument //src:bazel is a Unix-style path (because it starts with /) so it converts the "path" for Bazel to a Windows path. IIRC the conversion logic just removes one / and the target pattern ends up being /src:bazel.
As a solution, I suggest one of the following:
Run Bazel from cmd.exe or from Powershell. This is how I use Bazel and it works as expected.
Disable the path conversion heuristic in MSYS:
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
Use /// instead of // in the target path. This only works under MSYS and I don't think it's reliable because I don't understand MSYS's path conversion logic, so I don't recommend this solution but here it is anyway:
bazel build ///src:bazel
Related
I observe that my Bazel build agent frequently builds the project from scratch (including compiling grpc, which keeps unchanged) instead of taking results from cache. Is there a way, like query or cquery (pardon my ignorance) to determine why is the cache considered invalid for particular target? Or any techniques to tackle cache invalidation problem?
This is How the bazel build works :
When running a build or a test, Bazel does the following: Loads the BUILD files relevant to the target. Analyzes the inputs and their dependencies, applies the specified build rules, and produces an action graph. Executes the build actions on the inputs until the final build outputs are produced.
If you are having any clear assumptions can you please share the complete details!
This is most likely due to the rebuild sensitivity to particular environment variables. Many build actions will read from environment variables and use them to change the outputs. Bazel keeps track of this and will rebuild seemingly unchanged remote targets when your env changes.
To demonstrate this;
Build grpc (2x ensure it is cached the second time)
Change the PATH environment variable (your IDE may do this without you knowing)
mkdir ~/bin && export PATH=$PATH:~/bin
Rebuild grpc (This should trigger a complete rebuild)
There are a couple helpful flags to combat this rebuild sensitivity, and I'd recommend adding them to your bazelrc.
incompatible_strict_action_env: Freezes your environment and doesn't source environment variables from your shell.
action_env modify environment variables as needed for you build.
# file //.bazelrc
# Don't source environment from shell
build --incompatible_strict_action_env
# Use action_env as needed for your project
build --action_env=CC=clang
I have a user defined build setting at the project level:
Which is fed into the Other Swift flags build setting also at the project level:
This causes the compiler to emit a warning when any function takes longer than 1000 ms to compile. The problem is that CI is much slower than our dev machines, so on our dev machines we would like it to be more like 300 ms, and on CI 2000+ ms, or maybe even just disabled. We run with warnings as errors, so if the CI which is shared machines goes slow this often causes the build to fail.
When running on CI there is a CI environment variable that is set, so I'd like to change the value of the LONG_SWIFT_COMPILE_LIMIT_MS build setting if CI is set or not. How can I do this? I tried adding:
if [ -z ${CI+x} ]; then
# Not running on CI
setenv LONG_SWIFT_COMPILE_LIMIT_MS 300
else
# Running on CI
setenv LONG_SWIFT_COMPILE_LIMIT_MS 2000
fi
as a prebuild script on the scheme, but that didn't work.
You can specify build setting overrides on the xcodebuild command line by adding <setting>=<value> arguments. For your case, LONG_SWIFT_COMPILE_LIMIT_MS=2000.
This can't be done by an Xcode scheme pre-build script.
Bazel is trying to download packages on python test. I've wrote a simple python code, and a test file testing it.
I'm running `bazel test //test:python-test and I get the following error:
/Path/to/build/external/bazel_tools/tools/jdk/build:305:1: no such package '#remotejdk_linux//': java.io.IOException: error downloading [ unknown host: mirror.bazel.build and referenced by '#bazel_tools//tools/jdk:remote_jdk'
Now, that's obviously a problem in my workspace, where we work offline. Is there any way to work offline with bazel?
Using the following flags will force bazel to use your local java:
--host_javabase=#bazel_tools//tools/jdk: absolute_javabase --define=ABSOLUTE_JAVABASE=/path/to/my/jdk
You can add them to your local .bazelrc file to write shorter command-line
You can manually download requested artifact and put it in cache before calling build. Bazel will not download artifact if it's already exists in local cache.
We have a bunch of targets being built by Bazel in our build environment today, targets being cc_binary/cc_test/cc_library etc. Is there some Bazel option that dumps build time for each of these into a file so we can analyze it after the build is done. While building Bazel dumps some timing information that disappears fast but I am looking for something (either text/XML or any other readable format) that can be used in post-build analysis.
To some extent this is possible. Look at the documentation: Performance profiling
There is the build flag --experimental_generate_json_trace_profile that generates a file named command.profile.gz in our outputBase dir (details about the outputBase dir can be fond here).
Example:
bazel build --experimental_generate_json_trace_profile --experimental_profile_cpu_usage //:HelloWorld
command.profile.gz contains a file named command.profile. This can be view in Chrome (chrome://tracing/).
(Tested with Bazel 2.0.0)
all
I'm trying to deploy Nutch1.4 to Hadoop cluster(following this page). I got some problems when compiling Nutch with ant.
problem 1
When I run ant command, I got the following error:
/home/xenserver/apache-nutch-1.4-bin/build.xml:71: invalid Date syntax in "01/25/1971 2:00 pm"
I remove attribute "datetime" from line 71 in file build.xml and run ant again. Then I got another problem.
problem 2
The error is:
/home/xenserver/apache-nutch-1.4/build.xml:412: syntax errors in ivy file: java.text.ParseException: http://java.sun.com/xml/jaxp/properties/schemaLanguage in file:/home/xenserver/apache-nutch-1.4/ivy/ivy.xml
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:273)
........
What's wrong with the steps above? Is there any tutorial for compiling Nutch1.4?
Need your help.Thanks in advance.
For compiling nutch 1.4, all you have to do is run ant clean deploy from the nutch directory. The output is created in the directory named 'runtime' with 2 folders: one for local mode and other one for cluster mode.
please check the date settings and ant installation on your machine. I think that is casing the issue. Also have you tampered/ edited /home/xenserver/apache-nutch-1.4/ivy/ivy.xml ? Please check that file too.
EDIT:
There is some problem with the build file when executed on your Linux box.
Check these out: this and this.
These are the things that you should verify on your setup:
java version and ant version : dont use old ones. get the latest ones or ones that are compatible with your nutch release. FYI: for nutch-1.4 I am using apache-ant-1.8.3 and java jdk1.6.0_18. This combination works perfectly fine with me.
Check that you have installed a JDK and not a JRE
Check if your JAVA_HOME environment variable point to the JDK. System PATH variable must have $JAVA_HOME/bin and $ANT_HOME/bin appended to it. ANT_HOME variable must point to the ant installation directory.
Can you successfully run normal ant targets on any other build files ? try out with small ant build file.
Still facing the same issue, run ant command with -v option. This will provide more information about the error faced.
eg.
ant -v clean deploy