bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
764 stars 305 forks source link

Quoting problem in generation of override_repository string #3303

Closed telekid closed 1 year ago

telekid commented 2 years ago

When I click the bazel Sync button in the top right of IntelliJ, it constructs the following Bazel build command:

bazel build --tool_tag=ijwb:IDEA:ultimate --keep_going --build_event_binary_file=/var/folders/hc/k75f6c452y70020vmqcxsz_40000gp/T/intellij-bep-1ec48386-30d2-42bb-baef-4823fba2d542 --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=/Users/jakezerrer/Library/Application Support/JetBrains/IntelliJIdea2021.3/plugins/ijwb/aspect" --output_groups=intellij-resolve-java,intellij-info-generic,intellij-info-java -- //customs_only_booking/src/main/java/com/flexport/customsonlybooking/graphql:java_files

That command fails with the following error:

ERROR: Skipping 'Support/JetBrains/IntelliJIdea2021.3/plugins/ijwb/aspect': no such target '//:Support/JetBrains/IntelliJIdea2021.3/plugins/ijwb/aspect': target 'Support/JetBrains/IntelliJIdea2021.3/plugins/ijwb/aspect' not declared in package '' defined by /Users/jakezerrer/flexport/BUILD

Note the line no such target '//:Support/JetBrains/IntelliJIdea2021.3/plugins/ijwb/aspect'.

Support/... should be /Users/jakezerrer/Library/Application Support/.... The space in Application Support is causing the target string to be either parsed or constructed incorrectly.

Not sure if this is a construction error (which would mean a problem in the intellij plugin) or an argument parsing error (which would be a problem in bazel itself.)

If I simlink ApplicationSupport to Application Support and rerun the command manually without the space, the build succeeds.

Nexproc commented 2 years ago

Same issue here - have a small PR which might help? Just trivially replacing spaces with escaped spaces.

Nexproc commented 2 years ago

Hmm... seems like bazel just treats escaped whitespace as regular whitespace and still splits the command into an invalid target.

Nexproc commented 2 years ago

At the moment I've got the following working for Goland, but it might work for IntelliJ as well:

  1. Create a symlink to Library/Application Support (I use Library/symAppSupport) (use ln -s "My Folder" MySymlinkFolder)
  2. You might need to also chmod 755 on the new symlink folder as well (or whatever your Application Support perms are)
  3. Open Intellij, Help > Edit Custom Properties
  4. add the following line idea.plugins.path=/Users/YOU/Library/YOUR_SYMLINK_FOLDER/Jetbrains/YOUR_INTELLIJ_FOLDER/plugins
  5. Reset IntelliJ

Update this if that doesn't work for you, but my syncs are getting around the issue now.

The gist is that this creates a symlink directory that doesn't have a space in it to get around the "woops, that directory has a space" issue that bazel doesn't handle well.

sgowroji commented 1 year ago

Hello @telekid, Could you please reply if you are still looking support on the above issue. Thanks!

ShreeM01 commented 1 year ago

Hi there! Thank you for raising this issue. We're doing a clean up of old issues and will be closing this one since it seems to have stalled. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.