I did go through the suggesstions in following posts
So I tried 2 ways
Specifying in plugin.rb file
My plugin depends upon “mini_magick” for image resizing, so I specified it in plugin.rb
gem ‘mini_magick’, ‘~> 4.8’
But I get the following error
I, [2017-07-09T03:54:49.899941 #13] INFO – : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake db:migrate
ERROR: While executing gem … (Gem::Requirement::BadRequirementError)
Illformed requirement [“/root”]
I, [2017-07-09T03:54:54.692893 #13] INFO – : /root is not writable.
Bundler will use `/tmp/bundler/home/discourse’ as your home directory temporarily.
gem install mini_magick -v ~> 4.8 -i /var/www/discourse/plugins/discussbook-plugin/gems/2.4.1 --no-document --ignore-dependencies
You are specifying the gem mini_magick in /var/www/discourse/plugins/discussbook-plugin/plugin.rb, however it does not exist!
Specifying in yml file
As it was not working, I tried to add the gem install command in yml file custom commands
exec: gem install mini_magick -v 4.8.0
I get the following log(success) when it was being rebuilt
I, [2017-07-08T18:50:43.302333 #13] INFO – : Beginning of custom commands
I, [2017-07-08T18:50:43.302751 #13] INFO – : > gem install mini_magick -v 4.8.0
I, [2017-07-08T18:50:44.034391 #13] INFO – : Successfully installed mini_magick-4.8.0
1 gem installed
But when I try to require it in the route, I got the following error in error log
I can run the plugin locally… But in the server, the docker rebuild causes this issue.
Are you suggesting that I should enter inside docker, and change the permissions of folder to writable?
I will try that out, but if it would have been possible from plugin itself, it would be great.
Hi @sam, thanks for answer.
I tried this many times in different configurations, but it failed. Then I came to know real cause, though I do not know the solution
When I install the discourse-backups-to-dropbox plugin from github (plugin that you shared), the docker builds properly. But if I put it discourse-backups-to-dropbox in private repository like bitbucket, it throws the error. The error logs for the plugin are same as shared in first post ie
E -u discourse bundle exec rake db:migrate
ERROR: While executing gem … (Errno::EACCES)
Permission denied @ dir_s_mkdir - /var/www/discourse/plugins/discourse-backups-to-dropbox/gems
I, [2017-07-10T18:18:41.229582 #15] INFO – : /root is not writable.
Bundler will use `/tmp/bundler/home/discourse’ as your home directory temporarily.
gem install public_suffix -v 2.0.5 -i /var/www/discourse/plugins/discourse-backups-to-dropbox/gems/2.4.1 --no-document --ignore-dependencies
You are specifying the gem public_suffix in /var/www/discourse/plugins/discourse-backups-to-dropbox/plugin.rb, however it does not exist!
I, [2017-07-10T18:18:41.230126 #15] INFO – : Terminating async processes
So I guess the problem lies in the my private repo configuration. But if the plugin(without any gem) gets installed properly from bitbucket, I do not know why would installing plugin with gem throw error. It should not matter whether the plugin is in open repository like github or in private repo like bitbucket.
My private repo config
exec: cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development
That is one hell of a scary advice.
I advise to figure out which user needs write permissions, and then chown it to that user, keeping the permissions at 0755.
I know this is an old issue, and that the solution has been found, but I encountered a similar problem and what I did to resolve it was:
Use a specific version, not “~>”, as Sam says above
Version numbers should be “1.4.0” not just “1.4”, because while discourse installs “gemname-1.4.0” correctly, it looks for the declared “gemname-1.4” and fails.
Leaving this here in case it helps someone else who encounters this problem.