Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early-adopters distribution for Windows (with chocolatey package) #1453

Closed
dslomov opened this issue Jun 29, 2016 · 32 comments
Closed

Early-adopters distribution for Windows (with chocolatey package) #1453

dslomov opened this issue Jun 29, 2016 · 32 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) platform: windows type: feature request
Milestone

Comments

@dslomov
Copy link
Contributor

dslomov commented Jun 29, 2016

A binary package that early adopters can use to quickly install Bazel on Windows

@dslomov
Copy link
Contributor Author

dslomov commented Sep 5, 2016

We need to write instructions for this, asking people to install msys and add the dll to PATH somehow.
Eventually we will get rid of msys dependency, and then we won't need these instructions as well

@petemounce
Copy link
Contributor

Just to stitch up links for others that find this, I've started this via #1742. If you tell me which dll needs to be in PATH then I can modify the chocolatey package to make that happen.

@dslomov
Copy link
Contributor Author

dslomov commented Sep 14, 2016

It is msys-2.0.dll

@petemounce
Copy link
Contributor

@dslomov so - I should add the directory containing that DLL (on my system, c:\tools\msys64\usr\bin - this is where the msys2 chocolatey package installs it to, which happily matches the windows.md install steps for where to put msys2) to the Windows PATH (machine level?), and then I can test that out by running bazel.exe version and bazel.exe info (etc) from a non-msys2 shell like powershell or cmd and I should get the same output I would if I were running from msys2?

@dslomov
Copy link
Contributor Author

dslomov commented Sep 14, 2016

@petemounce yes, that's correct

@petemounce
Copy link
Contributor

Ok - I'll add that to #1742 then

@petemounce
Copy link
Contributor

Done in ad316e7

@petemounce
Copy link
Contributor

Having done that, bazel version works fine, but other commands (info, build) fail with output like

λ bazel info
WARNING: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start finding python in PATH.
.
ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 445
                _find_env_vars(repository_ctx, vs_path)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 393, in _find_env_vars
                _execute(repository_ctx, ["wrapper/get_env...."])
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 93, in _execute
                auto_configure_fail(result.stderr)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 50, in auto_configure_fail
                fail("
%sAuto-Configuration Error:%s ...))

Auto-Configuration Error: 'INCLUDE' is not recognized as an internal or external command,
operable program or batch file.

.
λ bazel build
WARNING: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start finding python in PATH.
.
ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 445
                _find_env_vars(repository_ctx, vs_path)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 393, in _find_env_vars
                _execute(repository_ctx, ["wrapper/get_env...."])
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 93, in _execute
                auto_configure_fail(result.stderr)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 50, in auto_configure_fail
                fail("
%sAuto-Configuration Error:%s ...))

Auto-Configuration Error: 'INCLUDE' is not recognized as an internal or external command,
operable program or batch file.

.
INFO: Elapsed time: 2.139s

@dslomov
Copy link
Contributor Author

dslomov commented Sep 14, 2016

@meteorcloudy could you take a look?

@meteorcloudy
Copy link
Member

I guess you haven't installed Visual Studio, right? But, cc_configure should output more helpful information, I'll fix that.

@meteorcloudy
Copy link
Member

And how did you get this bazel.exe? It seems to be an old version, you can download the latest binary from our ci ( or build by yourself
http://ci.bazel.io/view/Bazel%20bootstrap%20and%20maintenance/job/Bazel/JAVA_VERSION=1.8,PLATFORM_NAME=windows-x86_64/

@petemounce
Copy link
Contributor

@meteorcloudy I compiled that version of bazel via compile.sh against HEAD at the time. I hadn't come across where CI was to go grab that - thanks!

I've definitely installed Visual Studio - Pro, 2015, update 3. Perhaps I haven't installed all the necessary options? Here's a shot of my install options.
vs2015u3-cpp

@meteorcloudy
Copy link
Member

Hmm.. Looks like the installation is correct. Can you show me the content of get_env.bat, it should be under C:\temp\Bazel\GL7dEMFB\external\local_config_cc\wrapper on your machine.

@petemounce
Copy link
Contributor

I've just recompiled from 3617a54 and then used that to run bazel info in root of repo, and got the following output.

C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools does not exist on my box.

I should have been explicit - I'm running bazel from an administrator powershell.

λ bazel info
WARNING: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start finding python in PATH.
.
ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 448
                _find_env_vars(repository_ctx, vs_path)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 396, in _find_env_vars
                _execute(repository_ctx, ["wrapper/get_env...."])
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 93, in _execute
                auto_configure_fail(result.stderr)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 50, in auto_configure_fail
                fail("
%sAuto-Configuration Error:%s ...))

Auto-Configuration Error: 'INCLUDE' is not recognized as an internal or external command,
operable program or batch file.

.
C:\Users\Pete\bazel [windows_package ≡]
λ ls C:\temp\Bazel\GL7dEMFB\external\local_config_cc\wrapper\
ls : Cannot find path 'C:\temp\Bazel\GL7dEMFB\external\local_config_cc\wrapper\' because it does not exist.
At line:1 char:1
+ ls C:\temp\Bazel\GL7dEMFB\external\local_config_cc\wrapper\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\temp\Bazel\G...fig_cc\wrapper\:String) [Get-ChildItem], ItemNotFo
   undException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

C:\Users\Pete\bazel [windows_package ≡]
λ echo $env:TEMP
C:\Users\Pete\AppData\Local\Temp
C:\Users\Pete\bazel [windows_package ≡]
λ echo $env:TMP
C:\Users\Pete\AppData\Local\Temp
C:\Users\Pete\bazel [windows_package ≡]
λ ls C:\Users\Pete\AppData\Local\Temp\ba*


    Directory: C:\Users\Pete\AppData\Local\Temp


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       17/08/2016     11:34                bazel.562IuSIL
d-----       17/08/2016     11:34                bazel.w8YIPlcC
-a----       13/07/2016     11:00        2063362 bash.exe.q14420
-ar---       13/07/2016     11:00           6872 bashbug.a14420

λ ls C:\tools\msys64\var\tmp\Bazel\GL7dEMFB\


    Directory: C:\tools\msys64\var\tmp\Bazel\GL7dEMFB


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       14/09/2016     14:36                execroot
d-----       14/09/2016     17:51                external
d----l       14/09/2016     17:51                install
d-----       14/09/2016     17:51                server
d-----       14/09/2016     15:07                worker-logs
------       14/09/2016     17:51            271 command.log
-a----       14/09/2016     17:51             19 DO_NOT_BUILD_HERE
-a----       14/09/2016     17:51            317 javalog.properties
-a----       14/09/2016     17:51             40 lock
-a----       14/09/2016     17:51            788 README

@meteorcloudy
Copy link
Member

I see, get_env.bat should be under C:\tools\msys64\var\tmp\Bazel\GL7dEMFB\external\local_config_cc\wrapper\ if you are running from powershell.
Can you check the content?

@petemounce
Copy link
Contributor

petemounce commented Sep 15, 2016

@meteorcloudy its content is

@echo off
call "C:\Program Files (x86)/E r r o r :   0 x 8 0 0 7 0 0 5 7 


 /VC/VCVARSALL.BAT" amd64 
echo PATH=%PATH%,INCLUDE=%INCLUDE%,LIB=%LIB% 

I think it should contain:

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT" amd64 
echo PATH=%PATH%,INCLUDE=%INCLUDE%,LIB=%LIB% 

@meteorcloudy
Copy link
Member

Yes, that's exactly the content on my machine.
Looks like it failed to find the Visual Studio path and returned a weird error message as result.

Can you try ls 'C:\\Program Files (x86)' | grep -E 'Microsoft Visual Studio [0-9]+' | sort | tail -n 1 in your MSYS console and see what happens?

@meteorcloudy
Copy link
Member

Or run C:\tools\msys64\usr\bin\bash.exe -c "ls 'C:\\Program Files (x86)' | grep -E 'Microsoft Visual Studio [0-9]+' | sort | tail -n 1" directly from cmd.exe or Powershell.

@petemounce
Copy link
Contributor

msys shell:

Pete@petemounce-win-imp MSYS ~
$ ls 'C:\\Program Files (x86)' | grep -E 'Microsoft Visual Studio [0-9]+' | sort | tail -n 1
Microsoft Visual Studio 14.0

powershell:

C:\Users\Pete\src\oss
λ C:\tools\msys64\usr\bin\bash.exe -c "ls 'C:\\Program Files (x86)' | grep -E 'Microsoft Visual Studio [0-9]+' | sort | tail -n 1"
Microsoft Visual Studio 14.0

@meteorcloudy
Copy link
Member

meteorcloudy commented Sep 15, 2016

Hmm.. This is a weird problem. However, here is what I found.
By searching the error message, I get these results.
Are you running on Windows 10 with bash on Windows?
cc_configure.bzl probably found the wrong bash binary. Can you check the result of which bash from both msys and powershell ?

If it's the problem, I can fix it by checking BAZEL_SH environment variable first.

@petemounce
Copy link
Contributor

petemounce commented Sep 15, 2016

I am on Win10 Anniversary edition, and bash-on-windows is installed. I also have gow installed (for things like dos2unix).

I do not have the BAZEL_SH set in my windows environment variables (because I'd forgotten to, and I'll add that setup to #1742 shortly).

TL;DR - changing the the order of directories in my windows PATH so that msys is before c:\windows\system32 fixed the issue for me in powershell.

I'm not sure there's a chocolatey built-in for "prepend directory to path", but I'll try to do that in the installer too. Might be separate PR.

msys:

Pete@petemounce-win-imp MSYS ~
$ which bash
/usr/bin/bash

powershell (with gow installed):

λ which bash
C:\Program Files (x86)\Gow\bin\bash.EXE

powershell (with gow moved to last in my PATH):

C:\Users\Pete
λ which bash
/c/Windows/system32/bash
C:\Users\Pete
λ cd .\bazel\
C:\Users\Pete\bazel [windows_package ≡]
λ bazel info
..
WARNING: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start finding python in PATH.
.
ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 448
                _find_env_vars(repository_ctx, vs_path)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 396, in _find_env_vars
                _execute(repository_ctx, ["wrapper/get_env...."])
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 93, in _execute
                auto_configure_fail(result.stderr)
        File "C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl", line 50, in auto_configure_fail
                fail("
%sAuto-Configuration Error:%s ...))

Auto-Configuration Error: 'INCLUDE' is not recognized as an internal or external command,
operable program or batch file.

powershell (with /usr/bin before c:\windows\system32 in PATH):

C:\Users\Pete
λ which bash
/usr/bin/bash
C:\Users\Pete
λ cd bazel
C:\Users\Pete\bazel [windows_package ≡]
λ bazel info
WARNING: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start finding python in PATH.
.
bazel-bin: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/execroot/bazel/bazel-out/local-fastbuild/bin
bazel-genfiles: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/execroot/bazel/bazel-out/local-fastbuild/genfiles
bazel-testlogs: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/execroot/bazel/bazel-out/local-fastbuild/testlogs
command_log: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/command.log
committed-heap-size: 198MB
execution_root: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/execroot/bazel
gc-count: 5
gc-time: 46ms
install_base: C:/tools/msys64/var/tmp/_bazel_Pete/install/0351956d1005eaa9274c289f91f6cb4b
max-heap-size: 3790MB
message_log: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/message.log
output_base: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB
output_path: C:/tools/msys64/var/tmp/Bazel/GL7dEMFB/execroot/bazel/bazel-out
package_path: %workspace%
release: release 0.3.1-2016-09-14 (@3617a54)
server_pid: 14744
used-heap-size: 65MB
workspace: C:/Users/Pete/bazel

@meteorcloudy
Copy link
Member

I also sent a change here: https://bazel-review.googlesource.com/#/c/6072/1
So user can set BAZEL_SH to explicitly specify which bash Bazel should use in cc_configure.

Thank you so much for your help! :)

@petemounce
Copy link
Contributor

@meteorcloudy my pleasure!

In #1608 it's called out that bazel does not currently support bash-on-windows, so perhaps your change should warn the user (or just silently skip) that if that bash is found ahead of msys', it won't be used yet, or the PATH should be modified so b-o-w's isn't first?

@meteorcloudy
Copy link
Member

That is a great suggestion! I think we should warm the user to either set BAZEL_SH or adjust PATH if we found a b-o-w binary.
Is it always at C:\Windows\system32\bash.exe ?

bazel-io pushed a commit that referenced this issue Sep 16, 2016
In case cc_configure finds the wrong bash binary if user is running Windows 10 with bash on Windows.
This should help #1453

--
Change-Id: Iffd365e3e2dd2389882390dffdf6f3a88719530e
Reviewed-on: https://bazel-review.googlesource.com/#/c/6072
MOS_MIGRATED_REVID=133270634
@petemounce
Copy link
Contributor

I agree to both.

I think the b-o-w binary will always be there, subject to the usual caveat of MS might change their mind at any point ;-) (I'd be surprised if it moves if it is there now, even though it's not yet rtm)

@meteorcloudy
Copy link
Member

Great! I will send the change. :)

@petemounce
Copy link
Contributor

@meteorcloudy This is in 0.4 milestone, but the commit that will fix it is in #1742, which is not. Should the PR be added to 0.4 as well?

@dslomov
Copy link
Contributor Author

dslomov commented Sep 21, 2016

We haven't cut the 0.4 yet so you are fine

@damienmg damienmg changed the title Early-adopters distribution for Windows Early-adopters distribution for Windows (with chocolatey package) Oct 12, 2016
@damienmg damienmg added type: feature request P1 I'll work on this now. (Assignee required) labels Oct 13, 2016
@petemounce
Copy link
Contributor

The package is in the moderation queue at https://chocolatey.org/packages/bazel/0.3.2 . The queue is quite long, currently. I'll ping here once it is approved.

@petemounce
Copy link
Contributor

The package has been approved: https://chocolatey.org/packages/bazel/

Install via choco install bazel and then heed the output after it completes regarding environment variables etc.

Ping @dslomov.

@laszlocsomor
Copy link
Contributor

w00t, awesome! Thank you @petemounce , this is great work!

@laszlocsomor
Copy link
Contributor

Closing because the package is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) platform: windows type: feature request
Projects
None yet
Development

No branches or pull requests

5 participants