-
Notifications
You must be signed in to change notification settings - Fork 386
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
Gazelle fails to run on Windows #321
Comments
While the error says that the file below does not exist:
I can
However, there is another referenced file that does not indeed exist:
This file is listed on the runfiles manifest however:
So perhaps the issue here is that the binaries are not availing of the runfiles lookup on Windows (https://github.com/bazelbuild/bazel/blob/master/tools/bash/runfiles/runfiles.bash#L15-L64) Edit: nevermind, just realized the .exe is the output actually. |
I played around with the path to the The directory from where these commands run is, in my machine (55 chars):
The original path to the file, which causing the missing
The longest path I could use that didn't show the error was (204 chars):
Going to 205 chars by changing This got me thinking about the 256 path length limit in Windows. There seems to be an issue about this in golang/go#18468, with a fix released in go1.11. Running So I had a second look at the path length. A 55+205=260 char path does not work but a 55+204=259 path does, so the 260 length seems to be the magic number. bazelbuild/bazel#4550 mentions that MSYS (the bash that Bazel uses on Windows) supports a maximum of 260 characters, and that issue is marked as a duplicate of bazelbuild/bazel#4149. That Bazel issue looks like it was resolved with the addition of the The option now seems to be deprecated and nothing seems to really change when using it:
@meteorcloudy do you perhaps have some insight on this problem? golang/go#17835 might also be relevant from the Go side. |
Yes, this indeed is a long path issue again. The I think there are generally two ways to address long path issue:
|
@jayconrod
Do you think |
FYI @filipesilva Then the build works. |
I can confirm that effecting that change will get past the long path roadblock:
This now is a separate problem likely related to runfiles. I don't think it's safe to change a Go importpath like this though... I think they are used for importing libraries within Go. |
Windows has trouble with long paths. Other paths to .a files are absolutized already. Related bazel-contrib/bazel-gazelle#321
The script produced by the gazelle rule tries to set GOROOT to the SDK used by rules_go. This depends on runfiles. With this change, the script will read the MANIFEST file if runfile symlinks aren't present. It will also skip setting GOROOT if it fails. Fixes bazel-contrib#321
The script produced by the gazelle rule tries to set GOROOT to the SDK used by rules_go. This depends on runfiles. With this change, the script will read the MANIFEST file if runfile symlinks aren't present. It will also skip setting GOROOT if it fails. Fixes #321
Windows has trouble with long paths. Other paths to .a files are absolutized already. Related bazel-contrib/bazel-gazelle#321
I think this should work now, but you'll need to update both rules_go and gazelle to tip of master. As you have both found, Windows has trouble with long paths which are common in Bazel. Relative paths have some very low limit. Converting the path of the main .a file passed to the linker to an absolute path allows The other issue is that runfile symlinks aren't created on Windows, so the go executable isn't visible. I've updated the runner script to read the runfile MANIFEST if the symlink isn't present. |
Heya @jayconrod, that was a really quick couple of fixes, thanks! I updated https://github.com/filipesilva/gazelle-windows to use the latest tip:
But I think I'm still running into an issue with runfiles:
Trying to debug atm. |
I think the first issue is https://github.com/bazelbuild/bazel-gazelle/blob/6d34b3ce6607023ed9626f42db1231df978332bd/internal/gazelle.bash.in#L1 I've seen this problem before in Changing this allows the script processing to progress and shows a couple more errors:
I think this happens when the binary is not actually compatible with Windows and isn't hooked up to use MSYS through Bazel. It's still a sh_binary should take care of this, when used, I'm not sure of @jayconrod should I open a new issue with these newly surfaced problems, or would you prefer to reopen this on? |
* find_runfile is new function used to locate runfiles. This is used to locate the go tool and the gazelle executable. * BUILD_WORKSPACE_DIRECTORY is used instead of dereferencing the WORKSPACE symlink. Fixes bazel-contrib#321
#324 should fix the first issue. Please try it out and let me know if it works for you. A contributor changed About the other missing executables: I'm not able to reproduce that. It sounds like they aren't in I fixed a couple other problems I noticed. |
@jayconrod tried with your commit:
Finishes successfully! I think the other missing executables were just because I also tried it on another repository (the main one where this came up, https://github.com/bazelbuild/rules_typescript), and it also seems to have run successfully:
Great work! |
* find_runfile is new function used to locate runfiles. This is used to locate the go tool and the gazelle executable. * BUILD_WORKSPACE_DIRECTORY is used instead of dereferencing the WORKSPACE symlink. Fixes #321
Awesome, glad it works for you! To be honest, I expected to have to jump through more hoops to get this working. Bash scripting on Windows, especially through Bazel, is a bit hairy. |
Indeed! We're doing a big push towards Windows compat so we're trying to get all of the Angular repos to build correctly on windows, loads of stuff like this comes up. Runfiles lookup, bash scripting, and path separators are the biggest culprits. |
Wow, this is awesome! Do we have any test for gazelle on CI? If so, can we add a job to guard the Windows build? |
Trying to run gazelle remotely on our Windows CI (bazelbuild/rules_typescript#280) seems to reveal another problem:
The crux of it seems to be Not sure why this wasn't revealed locally. I tried running |
I think maybe on your Windows CI, you don't have bash binary in PATH? |
@meteorcloudy probably not, but should I? I don't think that's a part of the Windows setup for Bazel. I tried to make a basic shell script that has Checking on my gitbash shell, I have these environment variables:
And on CMD I have
This makes sense since On my CI run I saw:
Seeing that there is no But I am surprised that I tried using Bazel 0.16.1 locally and can see that On rules_typescript we use the https://github.com/bazelbuild/continuous-integration setup, so I'd say it we need to make sure it's updated to 0.17.1 to fix binary issues on Windows. |
Indeed, just realized the fix bazelbuild/bazel@7aaa34a is not included in 0.16.1 |
Windows has trouble with long paths. Other paths to .a files are absolutized already. Related bazel-contrib/bazel-gazelle#321
Windows has trouble with long paths. Other paths to .a files are absolutized already. Related bazel-contrib/bazel-gazelle#321
Windows has trouble with long paths. Other paths to .a files are absolutized already. Related bazel-contrib/bazel-gazelle#321
@filipesilva @jayconrod How did you all solve the I am using the latest 0.21.0 version of Bazel for windows, I have MSYS installed and the
I see the gazelle.bash.in file exists, but I don't see how you all solved it. Edit: I also see that gazelle.bash also exists, not sure why it says it doesn't, or that bash can't find it:
Edit2: If I run bazel from MSYS instead of from Powershell, (after the bazel server was started from Powershell), I get the following error instead:
Line 80 is: # If the script was invoked by "bazel run", jump out of the execroot, into
# the workspace before running Gazelle.
# TODO(jayconrod): detect when a command can't be run this way.
export GOROOT=$(cd "$(dirname "$GOTOOL")/.."; pwd) |
@veqryn Could you open a new issue? This one's covered a lot of ground already. Some things to try first though:
|
ok: #416 |
I am using Windows 10 and Bazel 0.17.1.
Following the steps in https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel, on a new workspace, I get the following output:
I've created a repo the the bare minimum of code and files to reproduce this in https://github.com/filipesilva/gazelle-windows.
The text was updated successfully, but these errors were encountered: