Plugin with custom gems

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?

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.

2 Likes

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:

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

https://github.com/xfalcox/discourse-backups-to-dropbox/blob/master/plugin.rb#L7-L13

7 Likes

Have a link to your plugin.rb?

Here is an example of one installing a gem.
https://github.com/discourse/discourse-plugin-linkedin-auth/blob/master/plugin.rb

1 Like

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’

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

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

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?

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

1 Like

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.

Yes I use it everyday.

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

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.