Facing an issue while installing some gems in the plugin

@sam

I’m unable to install some gems in the plugin, for e.g. google-protobuf. This gem is dependency for google-cloud-vision gem.

Here’s a plugin trying to install it. https://github.com/fzngagan/gem-issue

Logs
gem install google-protobuf -v 3.13.0 -i /Users/faiz/discenv/discourse/plugins/gem-issue/gems/2.6.3 --no-document --ignore-dependencies --no-user-install
Successfully installed google-protobuf-3.13.0-universal-darwin
1 gem installed
You are specifying the gem google-protobuf in /Users/faiz/discenv/discourse/plugins/gem-issue/plugin.rb, however it does not exist!
Looked for: /Users/faiz/discenv/discourse/plugins/gem-issue/gems/2.6.3/specifications/google-protobuf-3.13.0.gemspec

The reason for this is that the .gemspec file’s name doesn’t match the spec_file's name assumed in the code here.
https://github.com/discourse/discourse/blob/66976baefa52fe503c7fa2c396b15568464619ef/lib/plugin_gem.rb#L19

IMO, this would happen probably only when using platform-specific gems as the platform name gets added to the gem name if its platform dependent. This is described here. Specification Reference - RubyGems Guides

3 Likes

It’s unclear why you mentioned me on this topic? I don’t know much about our custom gem resolution, sorry.

1 Like

I checked the blame and you have the most commits to the file I guess? Happy to be pointed in the right direction here :slight_smile:

I think @sam might be able to help. He wrote the gem importing for plugins.

3 Likes

Sure, thanks for the lead.

@sam did you get a chance to take a look?

@sam could you help @fzngagan on this? I am sponsoring this plugin:

And it will be made available for everybody. It is vital to keep a forum free of images that could potentially harm and will certainly help to not getting strikes from Google Adsense for disallowed content.

1 Like

I guess it looks like there is a bug here, perhaps do a PR to try and fix this quirk?

2 Likes

https://github.com/discourse/discourse/pull/10559

Here’s a very simple PR fixing the issue.

I tried to find a fancy way to tackle this so that the devs don’t have to worry about the platform thing but didn’t find any. Happy to improve upon this if I find a better solution.

Also, a tip for devs, you can simply put the gem in discourse’s gemfile during development and not go insane. Only worry about all of this for deployment.

5 Likes

Thanks for merging @sam.

3 Likes