Bazel giving "open_proc" error 21 running embedded command - bazel

I'm working on creating a Bazel extension for Haxe and while I've had some initial success in getting things to build, I've hit a roadblock and I'm not sure what the right way around it is.
In Haxe if you declare a dependency on a Haxelib in your build.hxml file, when you perform the build the Haxe compiler will go grab that Haxelib from the internet and install it locally if you don't already have it, using a program named "haxelib". It seems that this process is being blocked by the Bazel sandbox, but I haven't been able to find much documentation on how the sandboxing works, if this is expected, and if there's a way around it. I'm currently working in Windows 10; this is the error that I'm getting:
$ bazel build //:neko-lib --verbose_failures
INFO: Analyzed target //:neko-lib (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: D:/repo/validation/BUILD:3:13: HaxeCompile neko/validation.n failed (Exit 1): haxe.exe failed: error executing command
cd C:/users/user/_bazel_user/s6xipia4/execroot/__main__
external/haxe_windows_amd64/haxe.exe bazel-out/x64_windows-fastbuild/bin/build.hxml
Execution platform: #local_config_platform//:host
Unix.Unix_error(21, "open_proc", "haxelib path hx3compat")
Target //:neko-lib failed to build
INFO: Elapsed time: 1.705s, Critical Path: 0.62s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
hx3compat is the name of the haxelibthat I'm trying to load. Error 21 seems to be "is a directory" but I'm not exactly sure what's actually being complained about. Here's the run action that I'm using:
ctx.actions.run(
outputs = [out],
inputs = inputs,
executable = haxe_cmd,
arguments = [args],
env = env,
mnemonic = "HaxeCompile",
)
haxe_cmd points the haxe.exe file, while the inputs are:
bazel-out/x64_windows-fastbuild/bin/build.hxml (the build file I'm building)
external/haxe_windows_amd64/haxe.exe
external/haxe_windows_amd64/haxelib.exe
Any ideas on things I can try to get around this issue?
Update: I wrote a rule today that runs the command in question (haxelib path hx3compat) and that works, so I think this is an error with invoking that command - not with the command itself.

The particular error that I was getting - Unix error 21 - was caused by the shell that Bazel creates not having the COMSPEC environment variable: see here and here for more details. Adding that variable to the environment via the --action_env=COMSPEC command line got me past that error. However the command shell that gets spawned by the Haxe process cannot handle symlinks, and so has a lot of trouble trying to access the directories brought in by Bazel, so I think using haxe via this route will end up being a lost cause. Just for the record though, I was able to get the haxelib command itself to run through the haxe process, so the answer for this question is to ensure the COMSPEC variable is set.

Related

bazel buid <app-to-build>:"Configurable attribute "actual" doesn't match this configuration"

I'm setting up a ppc64le server and I need to install bazel 0.23.* on it. I compiled bazel for this architecture but it does not work properly.
I'm trying to install an app (ONOS) on an Ubuntu 18.04 ppc64le server. It's not supported for this architecture so I need to build it from source using bazel (as ONOS documentation explains). I installed bazel version 0.23.0 from a binary already compiled for ppc64le architecture.
Now i tried to build the app using bazel (bazel build onos) but it shows an error related to "JDK environment"
root#TEF01:~# javac -version
javac 11.0.3
build ONOS:
root#TEF01:~/onos# bazel build onos
INFO: Build option --host_javabase has changed, discarding analysis cache.
/root/.cache/bazel/_bazel_root/548916f1c2f50851181f393ea08eaba4/external/bazel_tools/tools/jdk/BUILD:419:14: Configurable attribute "actual" doesn't match this configuration: Could not find a JDK for host execution environment, please explicitly provide one using `--host_javabase.`
INFO: Elapsed time: 2.340s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 1737 targets configured)
Fetching #nodejs; fetching
I checked the BUILD file where the error appears:
alias(
name = "remote_jdk10",
actual = select(
{
"//src/conditions:darwin": "#remotejdk10_macos//:jdk",
"//src/conditions:darwin_x86_64": "#remotejdk10_macos//:jdk",
"//src/conditions:windows": "#remotejdk10_win//:jdk",
"//src/conditions:linux_aarch64": "#remotejdk10_linux_aarch64//:jdk",
"//src/conditions:linux_x86_64": "#remotejdk10_linux//:jdk",
},
no_match_error = "Could not find a JDK for host execution environment, please explicitly" +
" provide one using `--host_javabase.`",
),
visibility = ["//visibility:public"],
)
It seems that there's not ppc64le architecture configured in this file and I don't know what can I do. It also says jdk10 while I have jdk11 but there's other "remote_jdk11" with the same structure.
As you may see, I'm just a beginner so sorry if my question do not make sense or if I didnt explain myself correctly. Also, english is not my first language so sorry again.

TFS2015 Build fails on all Command Line Commands with 'file not found'

In Team Foundation Server 2015 Build (on-premise), I'm having issues running simple command line commands. All Command Line tasks simply fail with the following error: "File not found: ".
Take for example the following build definition:
This is executed using an on-premise Build Agent and will fail with the following exception in the logs:
BUILD FAILED
2016-01-20T12:04:47.5127709Z ##[warning]Filename doesn't indicate a full path to a executable file.
2016-01-20T12:04:47.5127709Z Executing the following commandline. (workingFolder = D:\_work\2\s)
2016-01-20T12:04:47.5127709Z date
2016-01-20T12:04:47.5127709Z Error message highlight pattern:
2016-01-20T12:04:47.5127709Z Warning message highlight pattern:
2016-01-20T12:04:47.5439748Z ##[error]File not found: date
Of course this is a simplified example where I simply want to output the current date using the date /t command. But the same problem occurs with all general command line commands which I've tried, such as dir, time, path etc. The MSDN does not provide any troubleshooting info on it, other than that the tool executed must reside in the PATH variable.
The issue is not specific to one build definition or repo; it can be reproduced on others as well.
The builds run as the built-in svc_tfsbuild account.
I'm perhaps thinking this is either a simple setting, or - wildly guessing - an issue related to rights, but cannot find any documentation where to look or what to check. Any help would be appreciated.
It appears this is a known issue on MS Connect as well.
In short a MSFT mentions the following:
Commands that are built-in to command prompt don't work. Anything resolvable based on your PATH/PATHEXT will work.
In the comment from 27 Oct, 2015 it is stated that this will be fixed in the next sprint. The mentioned workaround for now is simply executing cmd.exe first and provide the rest as arguments.
Using the example from the original question this would lead to:
Tool: cmd.exe
Arguments: /c "date /t"
And I can indeed confirm this works.

Any ZMQ bindings for Erlang on Windows?

Is it possible to use Erlang with ZMQ on Windows? I have tried to use erlzmq2, but rebar fails to compile it with cryptic linker errors. Of course i can invest some time and investigate makefiles, but maybe other way exists?
Update
Whose who are interested in compilation errors can download latest erlang for windows and try to build erlzmq2 (Visual Studio 2012 compiler, msys sh and make). Error looks like:
cl : Command line error D8021 : invalid numeric argument '/Wl,-DLL,-IMPLIB:.libs
\zmq.dll.lib'
Makefile:541: recipe for target 'libzmq.la' failed
make[3]: *** [libzmq.la] Error 2
Please note that other erlang libs are compiling with this setup without any problems.
Your problem lies in compiling ZeroMQ for Windows. You haven't actually gotten to any Erlang yet. Here are some of the clues that tell you this:
Makefile:541: recipe for target 'libzmq.la' failed
This line says there's a problem on line 541 of the Makefile. But in erlzmq2, you can see that neither the main Makefile nor the c_src Makefile (which is what would build libzmq.la) has anything close to that many lines.
make3: * [libzmq.la] Error 2
The [3] means that you're 3 invocations deep into Make. Specifically, you started at the top-level Makefile, which called Rebar, which ran make -C c_src, which downloads ZeroMQ version 3.2.2 and tries to do a ./configure && make
To fix this Unix-style, go into the deps directory of erlzmq2 and figure out how to correctly compile ZeroMQ. Hopefully, you will just need to pass some arguments to configure. Then you can edit c_src/Makefile and set ZMQ_FLAGS to whatever you had to do for configure, clean, and make.
To fix it more Windows-style, follow the Windows build instructions for ZeroMQ. Put the compiled libzmq under deps and just edit the c_src Makefile to a no-op.
Finally, if you don't actually need to run this code on Windows, but are just using Windows as your development environment, I think you'll have the easiest time by running the build inside a Linux VM (not a hard thing at all with tools like Vagrant). Sorry, but Unix is the real system for this stuff; Windows support is an afterthought.

Generate reports using Clang Analyzer - scan-build

I am new to Clang analyzer and I am trying to generate reports using scan-build. While using the scan-build as below:
./scan-build --use-analyzer=/build/Debug+Asserts/bin/clang -v -o report_location sample.xcodeproj
I am always getting the below error:
scan-build: Using `/build/Debug+Asserts/bin/clang' for static analysis ; Can't exec "sample.xcodeproj":
Permission denied at ./scan-build line 1029. ;
scan-build: Removing directory 'report_location/2013-06-25-1' because it contains no reports. ;
scan-build: No bugs found.
Please help me resolving this issue.
The way scan build works is it either
invokes the command you provide e.g. make
executes the file that you provide e.g. some shell script
And when it does that it overrides the $CC environment variable to point to another script from where it forks two processes. In one the compiler runs as regular build and in another static-analyzer runs to generate report.
You are getting this error because 'sample.xcodeproj' is not an executable.
I'm not very familiar with xcode but I think if you chmod +x sample.xcodeproj then things should work.
clang-static analyzer can be integrated with xcode as well:
http://clang-analyzer.llvm.org/xcode.html
https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode_User_Guide/000-About_Xcode/about.html#//apple_ref/doc/uid/TP40010215-CH3-SW17

TFS build partially succeeded when calling a batch file, but no error in log

I’m building a solution which requires a batch file to be run after the build (there's a sequence in the workflow for this). TFS flags the build as partially succeeded, but there’s no error in the log even in full verbose mode ("diagnostic"). I’m checking the errorlevel after each line in the batch file and it’s always 0. I’ve also tested redirecting stdout and stderr in a file after each line and there’s no clue there.
It’s got nothing to do with unit tests because I’m skipping them for the time being.
I’ve noticed that usually when an error occurs in a batch file (e.g. file not found) there’s a visual cue to indicate the error and this matches the partially succeeded status. But I don’t see any visual cue.
So how can TFS decide that the build is only partially succeeded?
Thank you,
Solved.
It turns out the GetImpactedTests activity is throwing an exception (I can see it in the event viewer of the TFS machine), but it doesn't show at all in the build log.
I'm guessing that this exception makes the build partially succeeded (because the compilation part succeeded) but I couldn't see the assignment explicitly in the buid log. When I bypass the impact analysis (either by setting Analyze Test Impact to False or by removing the GetImpactedTests activity altogether), the error does not occur.
We experiment something similar here using the Lab Workflow (to kick our CodedUI tests). Different build template, same symptoms.
I have noticed that the build process reports that it partially succeeded, highlighting what seems to be a successful step in the deploy script (batch file).
The command is question is a command to install our mobile app on a mobile device (in order to test it at night):
adb install -d -r test.apk
I thought about looking the errorlevel right after running the adb command but the errorlevel was 0.
Then I thought that maybe the command is sending its output to stderr and found out this article on the android open source project, which confirms my hypothesis.
Following is my fix:
adb install -r -d test.apk 2>&1
Appending 2>&1 simply redirects stderr to stdout and now my deploy script does not report an error anymore and the build now succeeds (when all tests pass!).
Conclusion: When a script writes anything to stderr, the build workflow will report it as an error (partial success since it does not prevent execution of the workflow).
I know this is not your particular issue but since we had the same symptoms, I thought the stderr information could help somebody else find out the reason why their build process is reporting a partial success even though everything seems to work.

Resources