jvolkman / intellij-protobuf-editor

Protocol Buffers for IntelliJ-based IDEs
Apache License 2.0
122 stars 15 forks source link

Cannot resolve option 'go_package' #33

Closed akhan-vertiv closed 4 years ago

akhan-vertiv commented 4 years ago

The text go_package in the line appears in red in the editor. Previously it did not. Not sure when it started happening. I am using 2.1 version.

option go_package = "somepackage" 

When I hover over, I see the text: Cannot resolve option 'go_package' how can I resolve?

jvolkman commented 4 years ago

These options come from the file google/protobuf/descriptor.proto which must be in the protobuf import paths. The plugin ships with a copy of this file that it adds by default to the import path (see the third item in the image below). If you configured the paths yourself, you may have inadvertently removed it. But you don't need to use the copy that ships with the plugin. If you have the protobuf compiler installed you can add its location to your import path as well.

image

akhan-vertiv commented 4 years ago

Yup you are right. I did inadvertently remove that path. Putting that back in solved the problem. Thank you!!

raqbit commented 3 years ago

Hi there, I'm having the same issue: image

And I have the plugin settings set to automatic: image

When I untick the automatic setting, the descriptor path turns red: image

So this to me looks like it can't find the descriptor file bundled with the plugin.

jvolkman commented 3 years ago

@Raqbit I would expect the built-in to be listed when "configure automatically" is selected. Can you open a new issue and also include what editor you're using?

milaniez commented 3 years ago

Please kindly reopen this!

After upgrading from 2021.1 to 2021.2, this issue appeared for me even though my settings are correct.

here is how my both my setting and the error look like: Screenshot from 2021-07-29 23-45-29 (1)

rieshy commented 3 years ago

For me, it helped to uncheck the "Configure automatically" and remove "google/protobuf/" from the default Descriptor Path. Was: google/protobuf/descriptor.proto Now: descriptor.proto

jvolkman commented 3 years ago

FYI: JetBrains actually maintains and releases this plugin now (see the README on the front page). They're bundling it with certain products, and the latest versions in the marketplace are built by them. The main repository is over at https://github.com/JetBrains/intellij-plugins/tree/master/protobuf now.

milaniez commented 3 years ago

For me, it helped to uncheck the "Configure automatically" and remove "google/protobuf/" from the default Descriptor Path. Was: google/protobuf/descriptor.proto Now: descriptor.proto

This one didn't work for me unfortunately.

FYI: JetBrains actually maintains and releases this plugin now (see the README on the front page). They're bundling it with certain products, and the latest versions in the marketplace are built by them. The main repository is over at https://github.com/JetBrains/intellij-plugins/tree/master/protobuf now.

I already have this plugin installed.

jvolkman commented 3 years ago

I already have this plugin installed.

If you're using 2021.2, you're using the plugin from the JetBrains repo. They took over the Marketplace entry. The version in this repository was never updated to support 2021.2.

Darrenzzy commented 3 years ago

yes https://github.com/jvolkman/intellij-protobuf-editor/issues/33#issuecomment-889904619

I also encountered this problem after upgrading After upgrading from 2021.1 to 2021.2, this issue appeared for me even though my settings are correct.

here is how my both my setting and the error look like: https://github.com/jvolkman/intellij-protobuf-editor/issues/33#issuecomment-889671163

alextuan1024 commented 3 years ago

If you modify the import path and replace GoLand2021.2 with GoLand2021.1, it would probably work. Eventually, your default import path would look like: jar:///Users/$(whoami)/Library/Application Support/JetBrains/GoLand2021.1/plugins/protobuf-editor.jar!/include

alextuan1024 commented 3 years ago

Or you can just delete the default import path, clone the protocolbuffers/protobuf, add protocolbuffers/protobuf/src to as your import path, it could definitely solve this prolem.

jvolkman commented 3 years ago

It looks like JetBrains is fixing this issue. See https://youtrack.jetbrains.com/issue/IDEA-274732 and https://github.com/JetBrains/intellij-plugins/commit/4845bf0741fd6dc530cb6ec95a9c4b650986cae4

wiqram commented 3 years ago

For me, it helped to uncheck the "Configure automatically" and remove "google/protobuf/" from the default Descriptor Path. Was: google/protobuf/descriptor.proto Now: descriptor.proto

This solved my issue for intellij latest version as of aug 2021

lovromazgon commented 3 years ago

In the meantime before this is fixed by JetBrains, a fix was pointed out by Veniamin Albaev in IDEA-274732 - you should uncheck "Configure automatically" and set the prefix google/protobuf for the default location. This approach also makes sure that files importing google/protobuf/descriptor.proto are linted correctly (e.g. files that define custom file or field options).

Screen Shot 2021-08-05 at 19 10 55
Ghilteras commented 3 years ago

I don't understand why this is closed if this has not been fixed

jvolkman commented 3 years ago

I don't understand why this is closed if this has not been fixed

Well, two reasons: 1) this issue wasn't originally related to the recent JetBrains breakage; people simply started commenting on it 1 year after it had already been closed. 2) JetBrains took over this plugin and all future development and issue tracking has moved over to their sites (see the marketplace page for links)

vaiswalia commented 2 years ago

this will be resolved by just mentioning the import as import "protoname.proto" if its in the same package, else mention package. and at the time of using this imported proto in new proto file, mention the package name for example-

message{ com.package.sources.protoname name = 1; }

HungYann commented 2 years ago

These options come from the file google/protobuf/descriptor.proto which must be in the protobuf import paths. The plugin ships with a copy of this file that it adds by default to the import path (see the third item in the image below). If you configured the paths yourself, you may have inadvertently removed it. But you don't need to use the copy that ships with the plugin. If you have the protobuf compiler installed you can add its location to your import path as well.

image

yeah. this method can help us solve the compile problem and after I do this, the red lines dispeared!

Darrenzzy commented 2 years ago

Happily, I now choose another plug-in to solve this problem, although it doesn't pay as much attention as proto buffer.

With this plug-in [Protobuf Support], you can solve: Cannot resolve option 'go_package'

Other reference proto files can also be automatically identified.