tutorials
tutorials copied to clipboard
Issues with bazel example
command to be used in windows is they need to give output directory without any space, like this..
bazel --output_user_root=c:/temp/bazel build //bazelapp:BazelApp
and also change root WORKSPACE file these two keys values as
RULES_JVM_EXTERNAL_TAG = "4.2" RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"
error with default JVM tags is
\DWork\eugenp\tutorials\bazel>e:bazel --output_user_root=c:/temp/bazel build //bazelapp:BazelApp
INFO: Repository maven instantiated at:
G:/dwork/eugenp/tutorials/bazel/WORKSPACE:18:14: in <toplevel>
C:/temp/bazel/4jr45744/external/rules_jvm_external/defs.bzl:35:19: in maven_install
Repository rule coursier_fetch defined at:
C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl:559:33: in <toplevel>
INFO: Repository 'maven' used the following cache hits instead of downloading the corresponding file.
* Hash '8e7333506bb0db2a262d747873a434a476570dd09b30b61bcbac95aff18a8a9b' for https://jcenter.bintray.com/io/get-coursier/coursier-cli_2.12/1.1.0-M9/coursier-cli_2.12-1.1.0-M9-standalone.jar
If the definition of 'maven' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'maven':
Traceback (most recent call last):
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 509, column 36, in _coursier_fetch_impl
dep_tree = json_parse(_cat_file(repository_ctx, "dep-tree.json"))
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 427, column 13, in _cat_file
fail("Error while trying to read %s: %s" % (filepath, exec_result.stderr))
Error in fail: Error while trying to read dep-tree.json: cat: 'C:/temp/bazel/4jr45744/external/maven/dep-tree.json': No such file or directory
ERROR: G:/dwork/eugenp/tutorials/bazel/WORKSPACE:18:14: fetching coursier_fetch rule //external:maven: Traceback (most recent call last):
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 509, column 36, in _coursier_fetch_impl
dep_tree = json_parse(_cat_file(repository_ctx, "dep-tree.json"))
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 427, column 13, in _cat_file
fail("Error while trying to read %s: %s" % (filepath, exec_result.stderr))
Error in fail: Error while trying to read dep-tree.json: cat: 'C:/temp/bazel/4jr45744/external/maven/dep-tree.json': No such file or directory
ERROR: G:/dwork/eugenp/tutorials/bazel/bazelapp/BUILD:2:13: //bazelapp:BazelApp depends on @maven//:org_apache_commons_commons_lang3 in repository @maven which failed to fetch. no such package '@maven//': Error while trying to read dep-tree.json: cat: 'C:/temp/bazel/4jr45744/external/maven/dep-tree.json': No such file or directory
ERROR: Analysis of target '//bazelapp:BazelApp' failed; build aborted: Analysis failed
INFO: Elapsed time: 11.654s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (22 packages loaded, 80 targets co\
nfigured)
error with out output option is
DWork\eugenp\tutorials\bazel>e:bazel build //bazelapp:BazelApp
WARNING: Output user root "C:/Users/Raja Nagendra Kumar/_bazel_Raja Nagendra Kumar" contains a space. This will probably break the build. You should set a different --output_user_root.
INFO: Repository maven instantiated at:
G:/dwork/eugenp/tutorials/bazel/WORKSPACE:17:14: in <toplevel>
C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/defs.bzl:121:19: in maven_install
Repository rule coursier_fetch defined at:
C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl:1173:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'maven':
Traceback (most recent call last):
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 846, column 38, in _coursier_fetch_impl
dep_tree = make_coursier_dep_tree(
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 777, column 13, in make_coursier_dep_tree
fail("Error while fetching artifact with coursier: " + exec_result.stderr)
Error in fail: Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: G:/dwork/eugenp/tutorials/bazel/WORKSPACE:17:14: fetching coursier_fetch rule //external:maven: Traceback (most recent call last):
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 846, column 38, in _coursier_fetch_impl
dep_tree = make_coursier_dep_tree(
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 777, column 13, in make_coursier_dep_tree
fail("Error while fetching artifact with coursier: " + exec_result.stderr)
Error in fail: Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: G:/dwork/eugenp/tutorials/bazel/bazelapp/BUILD:2:13: //bazelapp:BazelApp depends on @maven//:org_apache_commons_commons_lang3 in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: Analysis of target '//bazelapp:BazelApp' failed; build aborted: Analysis failed
INFO: Elapsed time: 11.499s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets conf\
igured)
error with out output option is my default user home is C:/Users/Raja Nagendra Kumar/
DWork\eugenp\tutorials\bazel>e:bazel build //bazelapp:BazelApp
WARNING: Output user root "C:/Users/Raja Nagendra Kumar/_bazel_Raja Nagendra Kumar" contains a space. This will probably break the build. You should set a different --output_user_root.
INFO: Repository maven instantiated at:
G:/dwork/eugenp/tutorials/bazel/WORKSPACE:17:14: in <toplevel>
C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/defs.bzl:121:19: in maven_install
Repository rule coursier_fetch defined at:
C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl:1173:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'maven':
Traceback (most recent call last):
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 846, column 38, in _coursier_fetch_impl
dep_tree = make_coursier_dep_tree(
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 777, column 13, in make_coursier_dep_tree
fail("Error while fetching artifact with coursier: " + exec_result.stderr)
Error in fail: Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: G:/dwork/eugenp/tutorials/bazel/WORKSPACE:17:14: fetching coursier_fetch rule //external:maven: Traceback (most recent call last):
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 846, column 38, in _coursier_fetch_impl
dep_tree = make_coursier_dep_tree(
File "C:/users/raja nagendra kumar/_bazel_raja nagendra kumar/4jr45744/external/rules_jvm_external/coursier.bzl", line 777, column 13, in make_coursier_dep_tree
fail("Error while fetching artifact with coursier: " + exec_result.stderr)
Error in fail: Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: G:/dwork/eugenp/tutorials/bazel/bazelapp/BUILD:2:13: //bazelapp:BazelApp depends on @maven//:org_apache_commons_commons_lang3 in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with coursier: Error: Unable to access jarfile C:/users/raja
ERROR: Analysis of target '//bazelapp:BazelApp' failed; build aborted: Analysis failed
INFO: Elapsed time: 11.499s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets conf\
igured)
if the error is
`G:\DWork\eugenp\tutorials\bazel>g:bazel --output_user_root=c:/temp/bazel build //bazelapp:BazelApp
'g:bazel' is not recognized as an internal or external command,
operable program or batch file.
G:\DWork\eugenp\tutorials\bazel>e:bazel --output_user_root=c:/temp/bazel build //bazelapp:BazelApp
INFO: Repository maven instantiated at:
G:/dwork/eugenp/tutorials/bazel/WORKSPACE:16:14: in <toplevel>
C:/temp/bazel/4jr45744/external/rules_jvm_external/defs.bzl:121:19: in maven_install
Repository rule coursier_fetch defined at:
C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl:1173:33: in <toplevel>
INFO: Repository 'maven' used the following cache hits instead of downloading the corresponding file.
* Hash 'a51d36968dcbdeabb3142c6f5cf9b401a65dc3a095f3144bd0c118d5bb192753' for https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe
* Hash 'af986793a515d500ab2d35f8d2aecd656e764504b789b66d7e1a0b727a124c44' for https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
* Hash '076de041cbebc0a1272b84f1e69f6da5df4961847850b95cb3dfa3f776145225' for https://github.com/coursier/coursier/releases/download/v2.0.16/coursier.jar
* Hash '5c0a0a3ea600f302ee458b30317425dd9632d1ad8882259fcaf4e9b868b2b1ef' for https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64
If the definition of 'maven' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'maven':
Traceback (most recent call last):
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 821, column 13, in _coursier_fetch_impl
fail("Unable to run coursier: " + exec_result.stderr)
Error in fail: Unable to run coursier: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\temp\bazel\4jr45744\external\maven\coursier" --help): %1 is not a valid Win32 application.
(error: 193)
ERROR: G:/dwork/eugenp/tutorials/bazel/WORKSPACE:16:14: fetching coursier_fetch rule //external:maven: Traceback (most recent call last):
File "C:/temp/bazel/4jr45744/external/rules_jvm_external/coursier.bzl", line 821, column 13, in _coursier_fetch_impl
fail("Unable to run coursier: " + exec_result.stderr)
Error in fail: Unable to run coursier: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\temp\bazel\4jr45744\external\maven\coursier" --help): %1 is not a valid Win32 application.
(error: 193)
ERROR: G:/dwork/eugenp/tutorials/bazel/bazelapp/BUILD:2:13: //bazelapp:BazelApp depends on @maven//:org_apache_commons_commons_lang3 in repository @maven which failed to fetch. no such package '@maven//': Unable to run coursier: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\temp\bazel\4jr45744\external\maven\coursier" --help): %1 is not a valid Win32 application.
(error: 193)
ERROR: Analysis of target '//bazelapp:BazelApp' failed; build aborted: Analysis failed
INFO: Elapsed time: 1.382s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets conf\
igured)`
then make sure jdk home is correct..
readme.md should contain these commands for ready reference
bazel --output_user_root=c:/temp/bazeel build //bazelapp:BazelApp
bazel --output_user_root=c:/temp/bazeel build //bazelapp:BazelApp_deploy.jar
bazel --output_user_root=c:/temp/bazeel run //bazelapp:BazelApp
bazel-bin\bazelapp\BazelApp.exe
special mention of bazel-bin\bazelapp\BazelApp.exe as a way to create native windows exe to run the solution without JRE
Thanks @nagkumar These commands might be helpful for Windows users, but are too specific to include in our code/article. I think it's best to check the official documentation on using Windows: https://bazel.build/docs/windows