Gem installation problem.
- 
@neluser It's not a ruby version issue, it's to do with gem locations. I am still debugging why it can't find the gem anymore, because this used to work before. 
- 
OK, I think I figured this one out. Just leaving my notes here, since I will surely need this few months from now  RubyGemsRubyGems is the package manager and the names of packages is gems. RubyGems is part of ruby since 1.9. The gemCLI lets one install gems.list,info,searchinstallare common subcommands.By default, gem installrequires sudo since into installs into system location/var/lib/gems/2.7.0. It will also install deps of the gem. App canrequirethese gems in code.BundlerBundle(r) allows an app to specify a Gemfile that lists the gems and it's versions. bundle installwill install the gems into the same system wide location.bundle exec commandruns the executable command in context of the bundle. Meaning, it will ensure that the app does not use any gems not listed in the bundle and also ensure that the gems it is using are compatible with the versions in the Gemfile.bundler creates Gemfile.lockwith "resolved" versions. This has to be writable file even at runtime.Gem install- 
gem-GEM_HOMEdefines where gems are installed.GEM_PATHis list of search locations for gems. This is at the kernel level. Default value of these variables can be got fromgem env gemhomeandgem env gempath.GEM_HOMEis implicitly included intoGEM_PATH.
- 
bundler- by default, it's tuned for development and usesgemdefaults underneath. This means everything is installing into system locations.bundlerhas adeploymentmode which is a shortcut for installing intovendor/bundlesubdirectory (--localwill write to<project_root>/.bundle/configand --global will write to~/.bundle/config). When you callbundle install --deploymentfirst time, it stashes this path info into.bundle/configand all subsequent calls follow this "deployment" mode. In deployment mode, gems will only get loaded from the vendor directory and nowhere else. (As an aside,BUNDLE_PATHenv var can be set to tell bundler where to install and locate gems).
 Gem loadingRuby kernel is just loading gems based on LOAD_PATHvariable.bundle execis essentially overloadingrequirecalls. It readsGemfile.lock, patchingLOAD_PATHto have paths of the gems and then calling the original kernelrequire.
- 
- 
OK, next part of notes is how things relate to Redmine package. Current state: - Redmine is installed into /app/code
- gems needed by redmine are installed by calling bundle in deploymentmode. This means gems are installed into/app/code/vendor/bundle. The bundle calls creates a.bundle/configto rememberdeploymentmode.
- We set BUNDLE_PATHenv var to/app/data/vendor/bundle. The intention here is that when the user callscd plugindir && bundle install, the gems needed by the plugin will get installed into/app/data/vendor/bundle. This works as expected. (We set env var because the.bundle/configwon't be found after thecd).
- For gem loading to work, GEM_PATHis set to/app/data/vendor/bundlewith the intention thatbundler execwill use it . But as read in the notes above, the whole point of deployment mode is to only load gems from the path in.bundle/config. This means that gems required by plugins will never be loaded. This is obvious now... we cannot have gems in two locations in deployment mode.
 This used to work because this commit switched to deployment mode without understanding the consequences. The fix: - Install gems needed by redmine into system locations (so developer mode and not deployment mode)
- Set GEM_HOMEas/app/data/vendor/bundle. This waybundle installinside plugin directory will install there.
- Loading also works fine because GEM_HOMEis implicitly added intoGEM_PATH.
 
- Redmine is installed into 
- 
In a plot twist worth of O. Henry novel... I went back to using deploymentmode. There were two reasons:- 
Upstream plugin docs like the redmine up plugins recommend running bundle installat the top level.
- 
Using developmentmode means having to edit a plugin'sGemfileand addsourceline to makebundle installwork.
 I fixed the package to now have the bundle in /run/redmine/vendorinstead. It's just copied over on startup, it greatly simplifies things.
- 
- 
@Neluser When you have the time, can you please try with the latest package? (You can ignore all my notes!) https://docs.cloudron.io/apps/redmine/#installing-plugins is pretty much the same. @girish 
 Hi! The latest version of Redmine is working! 
 A clean install works as it should!
 Updating Redmine from 1.6 to 1.9 also works. The only thing I had to manually delete the "Bundle" folder And after that everything worked as it should.Thank you for your hard work!       
- 
@girish 
 Hi! The latest version of Redmine is working! 
 A clean install works as it should!
 Updating Redmine from 1.6 to 1.9 also works. The only thing I had to manually delete the "Bundle" folder And after that everything worked as it should.Thank you for your hard work!       
 
 
 
 
 
 


