intellij icon indicating copy to clipboard operation
intellij copied to clipboard

Add support for Windows

Open abergmeier-dsfishlabs opened this issue 7 years ago • 24 comments

When trying to import Bazel into the Plugin on Windows it fails with:

Running Bazel info...
...............
____Loading package: @bazel_tools//tools/jdk
WARNING: C:/users/a.bergmeier/appdata/local/temp/_bazel_a.bergmeier/uys7wfg8/external/bazel_tools/tools/cpp/cc_configure.bzl:67:3: 
Auto-Configuration Warning: 'BAZEL_PYTHON' is not set, start looking for python in PATH.
.
ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
	File "C:/users/a.bergmeier/appdata/local/temp/_bazel_a.bergmeier/uys7wfg8/external/bazel_tools/tools/cpp/cc_configure.bzl", line 759
		_find_python(repository_ctx)
	File "C:/users/a.bergmeier/appdata/local/temp/_bazel_a.bergmeier/uys7wfg8/external/bazel_tools/tools/cpp/cc_configure.bzl", line 452, in _find_python
		_which_cmd(repository_ctx, "python.exe")
	File "C:/users/a.bergmeier/appdata/local/temp/_bazel_a.bergmeier/uys7wfg8/external/bazel_tools/tools/cpp/cc_configure.bzl", line 96, in _which_cmd
		auto_configure_fail("Cannot find %s in PATH, please ...))
	File "C:/users/a.bergmeier/appdata/local/temp/_bazel_a.bergmeier/uys7wfg8/external/bazel_tools/tools/cpp/cc_configure.bzl", line 60, in auto_configure_fail
		fail("\n%sAuto-Configuration Error:%s...))

Auto-Configuration Error: Cannot find python.exe in PATH, please make sure python.exe is installed and add its directory in PATH.

Would be good to have an option to set environment variables prior to starting bazel.exe.

abergmeier-dsfishlabs avatar Jul 18 '17 09:07 abergmeier-dsfishlabs

Currently the plugin only supports Linux.

We plan to support Mac in the near future, and in the longer term Windows as well, but there are no fixed dates planned.

brendandouglas avatar Jul 18 '17 14:07 brendandouglas

Any updates on this? I can start the plugin with Clion 2017.2 (not 2017.3, see #175), but include paths are not recognized and therefore navigation through code is impossible. Instead of filing a separate bug report I assume that lacking Windows support causes my problem.

grefab avatar Jan 10 '18 23:01 grefab

No updates yet. As I understand it, Bazel support still isn't quite there for Windows.

Added to that, we simply don't have the bandwidth at the moment to look at Windows support for the plugin.

brendandouglas avatar Jan 11 '18 14:01 brendandouglas

@brendandouglas What about MacOS? Is it supported? (as you mentioned "We plan to support Mac in the near future")

arjantop avatar Jan 17 '18 12:01 arjantop

We don't yet officially support MacOS, though a significant fraction of users are on Macs -- other than a few known issues, it should basically work.

brendandouglas avatar Jan 17 '18 13:01 brendandouglas

I've tried the plug-in again on Windows and it seems to work well, except for one issue during the project setup. When choosing the option "Import project view file", it doesn't recognize, that the selected path is actually under the workspace path and complains.

As a workaround I just use "Copy external" which works fine. I'm able to sync and build Bazel's project then and all features seem to work fine, including the IDE being able to find all references. Yay :)

philwo avatar Jan 26 '19 16:01 philwo

I just wanted to comment that for the most part the plugin works great on Windows now, however the issue mentioned in #229 (and #372) is still happening for me.

mattnathan avatar Feb 25 '19 09:02 mattnathan

A work around for the "can't debug on windows" issue is to disable hotswap by placing the following into the file ~/.intellij-experiments

java.hotswapping.enabled=0

mattnathan avatar Feb 25 '19 10:02 mattnathan

FWIW, I can resolve the Bazel project on Windows using 2018.2 minus a few path separator issues.

ijwb-windows

I think we can close this issue now and open new issues for individual problems.

jin avatar Apr 24 '19 23:04 jin

I wanted to ask about #229 Has that been resolved yet? I am trying to run a bazel project on Android Studio for windows 10, and I am facing the following issue:

Error:Cannot run program "bazel" (in directory "my project directory"): CreateProcess error=2, The system cannot find the file specified

And I am getting this in the bazel console:

Syncing project: Sync (full)... Updating VCS... Running Bazel info... Command: bazel info --tool_tag=ijwb:AndroidStudio --curses=no --color=yes --progress_in_terminal_title=no --

Sync finished Sync failed

Hemanth715 avatar Sep 05 '19 12:09 Hemanth715

@Hemanth715 where is your bazel.exe installed? Can you try providing the full path to bazel.exe in "Settings -> Other Settings -> Bazel Settings"?

jin avatar Sep 11 '19 14:09 jin

Just raised #1186 - doesn't seem to handle directories well in the .bazelproject file in Windows. Would be awesome if that could also be fixed!

lunivore avatar Sep 23 '19 17:09 lunivore

@jin What's the status of this? Is there no interest/bandwidth here from Google? There are a handful of community PRs to fix blocking Windows issues, but they've been unmerged for 1-2 years. The plugin seems to work fine on Windows with those patches pulled in (and VCS integration disabled https://github.com/bazelbuild/intellij/issues/2277).

We're converting a large, critical Java code base to Bazel, and this is my biggest concern. We're going to have to maintain an internal fork of this plugin, but I'd love to see the maintainers be more receptive to fixes affecting Windows.

khogeland avatar Apr 30 '21 21:04 khogeland

@khogeland Thanks for raising this. I totally understand that this is a big issue for you. I also think it's one of the big blockers for making Bazel development (as in "developing Bazel itself") on Windows actually easy and doable.

So, yes, better Windows support for the IntelliJ plug-in would be really nice to have. That said, we want to get other, even more highly ranked requests done first (like better support for new IntelliJ versions). We'll get back to this eventually, unfortunately I can't promise more yet.

I can see whether we can already merge some PRs that improve Windows support. Could you or others following this issue point me to those that you think are important?

philwo avatar May 17 '21 19:05 philwo

@philwo That would be great! Everything seems to be working after merging these two PRs:

https://github.com/bazelbuild/intellij/pull/1204 https://github.com/bazelbuild/intellij/pull/1541

And this patch from @KrauseStefan which doesn't have an associated PR: https://github.com/bazelbuild/intellij/issues/1186#issuecomment-633961698

I also had to disable VCS integration for the project to work around https://github.com/bazelbuild/intellij/issues/2277, which doesn't look to have been investigated yet.

khogeland avatar May 18 '21 21:05 khogeland

I don't remember exactly why and how I made those changes. I never ended up using that patch my self it is not tested and have not even been seen to work on a Linux machine.

That is why there is no PR

KrauseStefan avatar May 25 '21 05:05 KrauseStefan

I try to sync but it fails: invalid target format '//hydra\kotlin\vn\com\asao\hydra\services\templateengine:template_engine': invalid package name 'hydra\kotlin\vn\com\asao\hydra\services\templateengine': package names may contain A-Z, a-z, 0-9, or any of ' !"#$%&'()*+,-./;<=>?[]^_{|}~' (most 7-bit ascii characters except 0-31, 127, ':', or '')`

About the system:

  • IntelliJ IDEA 2021.1.2 (Community Edition) Build #IC-211.7442.40, built on June 1, 2021 Runtime version: 11.0.11+9-b1341.57 amd64 VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 2042M Cores: 8 Non-Bundled Plugins: org.jetbrains.kotlin (211-1.5.10-release-891-IJ7142.45), com.google.idea.bazel.ijwb (2021.06.04.0.1) Kotlin: 211-1.5.10-release-891-IJ7142.45
  • Installed go bazelisk: Bazelisk version: development Build label: 3.7.1 Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Tue Nov 24 17:43:51 2020 (1606239831)
  • Bazel plugin for IntelliJ: v2021.06.04.0.1

dkthezero avatar Jun 22 '21 21:06 dkthezero

PLEASE merge https://github.com/bazelbuild/intellij/pull/2976 in regards to this. If I manually merge this and rebuild the plugin, importing a C++ project (as was tried in #3037 but this time in a path without spaces) actually works and syncs!

Previously:

Syncing project: Full Sync (full)...
Updating VCS...
Running Bazel info...
Command: C:\Users\Max\Downloads\bazel-6.0.0-pre.20211019.1-windows-x86_64\bazel.exe info --tool_tag=ijwb:CLion --curses=no --color=yes --progress_in_terminal_title=no --

Computing VCS working set...
Querying targets in project directories...
Command: C:\Users\Max\Downloads\bazel-6.0.0-pre.20211019.1-windows-x86_64\bazel.exe query --tool_tag=ijwb:CLion --output=label_kind --keep_going "attr(\"tags\", \"^((?!manual).)*$\", //main/...:all)" --

Sync finished
Sync failed

After PR:

Syncing project: Sync (incremental)...
Updating VCS...
Running Bazel info...
Command: C:\Users\Max\Downloads\bazel-6.0.0-pre.20211019.1-windows-x86_64\bazel.exe info --tool_tag=ijwb:CLion --curses=no --color=yes --progress_in_terminal_title=no --

Computing VCS working set...
Querying targets in project directories...
Command: C:\Users\Max\Downloads\bazel-6.0.0-pre.20211019.1-windows-x86_64\bazel.exe query --tool_tag=ijwb:CLion --output=label_kind --keep_going "attr('tags', '^((?!manual).)*$', //main/...:all)" --

1 targets found under project directories; syncing 1 of them.
Sync targets from project view directories:
  //main:hello-world

Building Bazel targets...
Command: C:\Users\Max\Downloads\bazel-6.0.0-pre.20211019.1-windows-x86_64\bazel.exe build --tool_tag=ijwb:CLion --keep_going --build_event_binary_file=C:\Users\Max\AppData\Local\Temp\intellij-bep-2b464c42-33c1-4260-bd18-0d519e83168b --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --noexperimental_run_validations --aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=C:\Users\Max\AppData\Roaming\JetBrains\CLion2021.2\plugins\clwb\aspect --output_groups=intellij-resolve-cpp,intellij-info-cpp,intellij-info-generic -- //main:hello-world

Loading: 
Loading: 0 packages loaded
Analyzing: target //main:hello-world (0 packages loaded, 0 targets configured)
[...]
Analyzing: target //main:hello-world (42 packages loaded, 375 targets configured)
INFO: Analyzed target //main:hello-world (43 packages loaded, 567 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] Writing file main/hello-world--2128682281.intellij-info.txt ... (4 actions, 0 running)
Aspect @intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect of //main:hello-world up-to-date:
  bazel-bin/external/local_config_cc/toolchain--412636119.intellij-info.txt
  bazel-bin/external/bazel_tools/tools/cpp/malloc--1081483544.intellij-info.txt
  bazel-bin/main/hello-world--2128682281.intellij-info.txt
INFO: Elapsed time: 65.455s, Critical Path: 0.04s
INFO: 4 processes: 4 internal.
INFO: Build completed successfully, 4 total actions
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 4 total actions
INFO: Build completed successfully, 4 total actions
build invocation result: success
Parsing build outputs...
Total rules: 3, new/changed: 3, removed: 0
Reading IDE info result...
Reading IDE info result...
Updating target map
Loaded 3 aspect files, total size 3kB
Target map size: 3
Prefetching output artifacts...
Prefetching files...
Refreshing files
Computing directory structure...
Initializing project SDKs...
Committing project structure...
Workspace has 0 libraries
Workspace has 2 modules
Updating in-memory state...
0 unique C configurations, 0 C targets
Sync finished

Timing summary:
BlazeInvocation: 66,6s, Prefetching: 0ms, Other: 289ms

grafik

Okay it's trying to use the Visual Studio tools as its compiler, but I'm sure I can get it to use MinGW.. Building works fine with it as-is, CLion just uses a different compiler for the IntelliSense.

grafik

It would be a good step in the right direction to merge the PR that's been sitting there for a month now for Windows support. This issue has been open for 4 years..

maxgerhardt avatar Oct 30 '21 10:10 maxgerhardt

I have rebuilt the plugin after manually applied the changes above (#1204, #1541, #2976), and the sync step works well.

However, the IDE seems not to recognize the include path:

sc1 sc2 sc3

The only way that makes IDE recognize the lib directory is to use relative include path.

Arsenal591 avatar Nov 01 '21 05:11 Arsenal591

@Arsenal591 I had this issue and it was because of this error during sync:

image

Which was specifically caused by this line:

https://github.com/bazelbuild/intellij/blob/f894c76e3f492cf9322a9142b43fc0cf2526b39f/cpp/src/com/google/idea/blaze/cpp/CompilerVersionCheckerImpl.java#L32-L34

The issue was that the path is to gcc but the file is actually gcc.exe (I am using MinGW via --compiler=mingw-gcc), so cppExecutable.exists() returns false.

Commenting that out gets it further, but fails here:

image

which is caused by

image

which is caused by the plugin wrapping the compiler in this shell script:

https://github.com/bazelbuild/intellij/blob/f894c76e3f492cf9322a9142b43fc0cf2526b39f/cpp/src/com/google/idea/blaze/cpp/CompilerWrapperProviderImpl.java#L45-L74

I don't know how to go further.

Bazel is a really hard sell compared to other build systems when it is only usable in one IDE (CLion) and only on one operating system (Linux).

jesseschalken avatar Nov 08 '21 18:11 jesseschalken

I've pinged the internal pull request that @maxgerhardt linked. Hopefully we can get it merged.

philwo avatar Nov 24 '21 19:11 philwo

#2976 is now merged.

AlexeyGy avatar Nov 26 '21 20:11 AlexeyGy

@Arsenal591 I had this issue and it was because of this error during sync:

image

We got a simliar issue when import an Android bazel project. The plugin says unable to access compiler executable "Path\to\android\ndk\toolchain\clang". The executable is actually clang.exe.

kkpattern avatar Jul 18 '22 03:07 kkpattern

@kkpattern I've opened https://github.com/bazelbuild/intellij/pull/3811 with a fix.

jesseschalken avatar Aug 02 '22 11:08 jesseschalken

Thank you for contributing to the IntelliJ repository! This issue has been marked as stale since it has not had any activity in the last 6 months. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-maintainer". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

github-actions[bot] avatar May 05 '23 01:05 github-actions[bot]

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

github-actions[bot] avatar May 19 '23 02:05 github-actions[bot]