# Plugin with custom gems

**URL:** https://meta.discourse.org/t/plugin-with-custom-gems/57190
**Category:** Development
**Created:** [9 Febbraio 2017, 5:45pm UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190 "2017-02-09T17:45:17Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [9 Febbraio 2017, 5:45pm UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/1 "2017-02-09T17:45:17Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [9 Febbraio 2017, 6:35pm UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/2 "2017-02-09T18:35:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [10 Febbraio 2017, 1:32am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/3 "2017-02-10T01:32:22Z")

</div>

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 😕

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [10 Febbraio 2017, 2:06am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/4 "2017-02-10T02:06:41Z")

</div>

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>

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [10 Febbraio 2017, 2:07am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/5 "2017-02-10T02:07:12Z")

</div>

Have a link to your plugin.rb?

Here is an example of one installing a gem.

> <https://github.com/discourse/discourse-linkedin-auth/blob/main/plugin.rb>

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [10 Febbraio 2017, 3:06am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/6 "2017-02-10T03:06:23Z")

</div>

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’

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [10 Febbraio 2017, 3:08am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/7 "2017-02-10T03:08:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [10 Febbraio 2017, 3:27am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/8 "2017-02-10T03:27:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [10 Febbraio 2017, 3:35am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/9 "2017-02-10T03:35:59Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [10 Febbraio 2017, 3:41am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/10 "2017-02-10T03:41:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [10 Febbraio 2017, 3:43am UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/11 "2017-02-10T03:43:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [10 Febbraio 2017, 12:19pm UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/12 "2017-02-10T12:19:13Z")

</div>

> [@pfaffman](#):
>
> That’s a real thing? I remember a post about sync to Dropbox but I thought it was a pipe dream.

Yes I use it everyday.

> [@leo.proctor](#):
>
> It is a private repo,

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

---

<div class="post-metadata">

### Author: ![leo.proctor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leo.proctor/32/216158_2.png) [@leo.proctor](https://meta.discourse.org/u/leo.proctor)
#### Post date: [10 Febbraio 2017, 1:48pm UTC](https://meta.discourse.org/t/plugin-with-custom-gems/57190/13 "2017-02-10T13:48:02Z")

</div>

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.
