Plugin with custom gems

(Leo) #1

I’ve some custom gems in my plugin. it works fine on local machine. but on prod while following your app.yml format for installing private plugins, it fails with following error.

I, [2017-02-09T17:13:20.015101 #13] INFO – : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake assets:precompile
ERROR: While executing gem … (Errno::EACCES)
Permission denied @ dir_s_mkdir - /var/www/discourse/plugins/my-plugin/gems
I, [2017-02-09T17:13:26.998142 #13] INFO – : Your home directory is not set properly:

  • /root is not writable

Bundler will use /tmp/bundler/home/discourse as your home directory temporarily
gem install macaddr -v 1.0.0 -i /var/www/discourse/plugins/my-plugin/gems/2.3.3 --no-document --ignore-dependencies

You are specifying the gem macaddr in /var/www/discourse/plugins/my-plugin/plugin.rb, however it does not exist!

Any help?

Install Plugins in Discourse
(Mittineague) #2

I think the way ti go about it is to not have the plugin try to install a gem, but to put the gem install instructions in the readme “how to install” as a required dependency.

(Leo) #3

thanks for your response. But there must be some automated way, as there are lot of plugins out there with custom gems. Event at local, I didn’t have to manually install these gems. I guess there are some permission issues, it tries to create my-plugins/gems folder but fails. May be I should pre create this folder :confused:

(Rafael dos Santos Silva) #4

Add your gem dependencies (all the dependency tree) to your plugin.rb file:

Specifying the gem dependecies for plugin - gem does not exist
Anyone care to pick up the Autobot plugin?
(cpradio) #5

Have a link to your plugin.rb?

Here is an example of one installing a gem.

(Leo) #6

It is a private repo, but here is how i’m adding gems in plugin.rb

gem ‘macaddr’, ‘1.0.0’, {require: false}
gem ‘uuid’, ‘2.3.7’, {require: false}
gem ‘gyoku’, ‘1.2.0’, {require: false}
gem ‘akami’, ‘1.2.0’, {require: false}
gem ‘httpi’, ‘2.3.0’, {require: false}
gem ‘wasabi’, ‘3.4.0’, {require: false}
gem ‘nori’, ‘2.4.0’, {require: false}
gem ‘savon’, ‘2.11.0’, {require: false}

enable_site_setting :user_status

require ‘savon’

(Leo) #7

I’m following the exact format, but it fails on sudo ./launcher rebuild app

(Joe Buhlig) #8

I’ve done this a few times with success. But never with the require: false. Have you tried it without that piece?

(Leo) #9

yeah, i’ve tried it without require: false too, but same error. Are your plugins private and do you follow same steps as @techAPJ mentioned for private repos?

(Jay Pfaffman) #10

That’s a real thing? I remember a post about sync to Dropbox but I thought it was a pipe dream.

(Joe Buhlig) #11

They’re not private. That could very likely be the issue on your end, though. I’ve never had an issue with it so I’m shooting blind.

(Rafael dos Santos Silva) #12

Yes I use it everyday.

The gem is not on rubygems? Not sure what to do in this case…

(Leo) #13

Sorry for the confusion. The gems are ofc on rubygems. I was referring to my plugin, it is on private repo. And i’m following the guide by @techAPJ to add private plugins to discourse.