Disable the RMAGIC option, it causes conflict with different versions of imagemagick. This problem is fixed in redmine 4.1, hopefully they'll backport the fix to the 4.0 branch.
Use the correct redmine version when building redmine plugins
I think we should deprecate redmine3, redmine40 has switched to rails52 which broke a lot of plugins.