ualbertalib / discovery

Discovery is the University of Alberta Libraries' catalogue interface, built using Blacklight
http://search.library.ualberta.ca
12 stars 3 forks source link

Problem installing gems on VM. #9

Closed ghost closed 9 years ago

ghost commented 10 years ago

If our workflow is to set up a dev environment on a golden image VM, then log in, modify code and push back to GitHub, then we'll need to install gems on the VM and have them work. Currently, if you install a gem on the VM, gem list will show the gem, and it will appear in the vendor directory, but neither require nor require_relative will find it. This doesn't seem to be a consistent problem. I installed both the "ebsco-discovery-service-api" and "addressable" gems, and only addressable had the problem. This sounds similar to a problem @weiweishi and @nmacgreg were having with DMPOnline. / @pgwillia

ghost commented 10 years ago

From @weiweishi :

Bundler allows using shared(rubygems) and vendored(bundler) gems, by default bundler/capistrano is configured with:

set :bundle_flags, "--deployment --quiet" which forces vendored gems only,

you can switch back to shared gems with explicit:

set :bundle_flags, "--system --quiet" to still install in vendor but use shared gems too:

set :bundle_flags, "--path #{shared_path}/bundles --quiet" if the deployment was already ran with --deployment(the default) then it could help to run the deploy once with:

set :bundle_flags, "--no-deployment"

ghost commented 10 years ago

In addition to using capistrano to manage both shared and bundled gems, another solution might be to tell bundler to install all gems in vendor, even if they already exist in system:

bundle install vendor/bundle --disable-shared-gems

http://bundler.io/v0.9/bundle_install.html

pgwillia commented 10 years ago

With DMP Builder our workflow was to 'bundle install --path vendor" for the deployment branch.

On Mon, Jul 21, 2014 at 3:43 PM, redlibrarian notifications@github.com wrote:

In addition to using capistrano to manage both shared and bundled gems, another solution might be to tell bundler to install all gems in vendor, even if they already exist in system:

bundle install vendor/bundle --disable-shared-gems

http://bundler.io/v0.9/bundle_install.html

— Reply to this email directly or view it on GitHub https://github.com/ualbertalib/discovery/issues/9#issuecomment-49670223.

ghost commented 10 years ago

Yes, I tried that too. The new gem still isn't visible. My work around is to redeploy - but that's not sustainable. I'll see what I can find out.

ghost commented 10 years ago

Something strange is happening with gem paths. I haven't even figured out a good test case yet, but something weird's going on.

ghost commented 10 years ago

Trying to document the problem I'm seeing.

-- added "factory_girl" (test,development) to gemfile -- ran "bundle install" (by default this should install all gems) -- factory_girl appears in vendor/ruby -- "require factory_girl" fails in irb with a file-not-found error (not a "false") -- in rails console, vendor/ruby/factory_girl is present in the gem load path -- but "require factory_girl" fails (in rails c) with a "false" -- also, "gem list --local" doesn't show factory_girl

One workaround I've seen is to run bundle --deployment, which will put everything into vendor/bundle. This didn't work.

Tried running "bundle --system" and this did in fact install factory_girl to the system (gem list --local confirms).

My understanding of the bundler works was that a vanilla "bundle install" installed to system, while bundle --deployment installed gems to vendor/bundle once. Once you've done that does it change the gem load path? Interestingly, rails console still returns "false" when I try to require factory_girl, but irb returns "true" - so the gem load path in Rails (but not in Ruby) is unable to find the gem, even both irb and rails can see the path to the gem (irb using the system path and rails using the vendor path). Weird. If Rails can see the gem in the load path, why can't it load it?

ghost commented 9 years ago

I don't think this happening anymore. As it is we're deploying through ansible, and new gems do get installed. Closing.