Chef hangs with bundle install - amazon-ec2

when I deploy with chef to an EC2 box it works fine at the first deploy, but every subsequent deploy hangs here
* execute[bundle install --deployment] action run
the relevant chef code is
execute "bundle install --deployment" do
cwd "#{app_path}/current"
end
At this point all the gems are obviously installed (due to the fact that the 1st deploy succeeds).
the command chef runs is
/opt/chef/embedded/bin/ruby /opt/chef/embedded/bin/bundle install --deployment
Which runs fine when I execute it directly on the box:
Your bundle is complete!
Any ideas?

Related

Chef Client skip bundle install on air gapped server

I am trying to install chef recipes on air-gapped server
I bundled gems listed in all recipes and prepared vendor/cache archive. Copying it into the server and running /opt/chef/embedded/bin/bunlde install --local successfully installed 233 gems but when i run chef-client -j boot.json it finds all gems and doesn't download but still run bundle install step and tries to access rubygems.org and fails
Running chef-client in debug mode doesn't reveal any gem name, its trying to download so i don't know what's missing.
Is there anyway i can skip this step or know which gem is missing ?
Part of the run after loading the cookbooks is to install the gems required in the cookbook metadata.rb.
The client prepare a Gemfile and launch a bundle install to check if the necessary gems are installed and up to date, that's the behavior of bundler and why it tries to connect to rubygems.org.
As said in the comments, vendoring all the gems on each server is far from being efficient, you'd better have an internal gem repository and point your cient to it.
That's nearly what you did, get all gems from your recipes, install them on an internal machine and run gem server.
That can be tedious, and there's other approaches allowing to mirror rubygem internally more easily described here

Ruby bundle exec silently fails to run gem

I have Ruby 2.1.5p273 and RubyGems v2.4.6 on CentOS 7.1 x86_64. When I run bundle exec bin/awesome_app I get no error on the screen, and my app doesn't run. However, with --verbose turned on, I see this:
$ bundle --verbose exec bin/recall_app
ERROR: "bundle install" was called with arguments ["exec", "bin/recall_app"]
Usage: "bundle install [OPTIONS]"
However, I've already ran bundle install in the directory of the gem. I'm not sure what else I would need to do.
As per your request: To run a Sinatra app with bundler the command is bundle exec ruby your_main_app_file.rb.
Here are the official Docs

Does Gitlab omnibus package install ruby & git?

I'm trying to install Gitlab with omnibus package for Debian 7. Gitlab is running but it's very slow. Tail logs showed me, that unicorn process timeouts because get requests for assets timing out.
I read somewhere that I have to perform bundle exec rake assets:precompile RAILS_ENV=production but bundle command not found. Also, git command not found. Does omnibus package install ruby and git or I should do it manually? I couldn't find ruby or git in usr/bin or somewhere else.
The syntax bundle exec rake some_task is available for the normal GitLab installation, where you install all components manually.
With GitLab omnibus you can use gitlab-rake some_task. It will automatically use the GitLab's internal ruby installation, internal bundle etc.

referencing a ruby gem from git breaks aws beanstalk deployment

I have set up my aws environment succesfully. However i am having one probelem. In my Gemfile i have the following line:
gem 'activeadmin', :github => 'gregbell/active_admin'
When i do a git aws.push i can see the following error in the aws logs:
/usr/local/share/ruby/gems/2.0/gems/bundler-1.3.5/lib/bundler/source/git.rb:177:in `rescue in load_spec_files': git://github.com/gregbell/active_admin.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
I was able to fix that problem by creating this file: .ebextensions/ruby.config
option_settings:
- option_name: BUNDLE_DISABLE_SHARED_GEMS
value: "1"
- option_name: BUNDLE_PATH
value: "vendor/bundle"
packages:
yum:
git: []
This packages everything into vendor/bundle and my app starts correctyl.
However I have two problems with this approach:
It takes very long to deploy because it needs to install all gems every time
I am not longer able to execute commands when I ssh into the EC2 instance. For example I have to start an rpush deamon. Locally this works with bundle exec rpush development but on EC2 this results in:
bundle exec rpush
/usr/local/share/ruby/gems/2.0/gems/bundler-1.3.5/lib/bundler.rb:284: warning: Insecure world writable dir /var/app/current/vendor/bundle/bin in PATH, mode 040777
git://github.com/gregbell/active_admin.git (at master) is not checked out. Please run bundle install
Is there an other way for installing the gems correctly and at the same time using the system gems? Or if that is not possible, how can I start rpush when the gems are bundled?
Update your Gemfile.lock (bundle install&& bundle update) in your local env. and push a commit with Gemfile and Gemfile.lock. Deploy to AWS again.
Can you check if using gem 'activeadmin', 'git://github.com:gregbell/active_admin' in your Gemfile works for you?
You can also get faster deployments utilizing vendor/cache by following the instructions given here:
http://blogs.aws.amazon.com/application-management/post/Tx2XVRWSS4E971S/Locally-Packaging-Gem-Dependencies-for-Ruby-Applications-in-Elastic-Beanstalk
What solved my problem: I modified the bundle install script and added the --deployment flag

Running bundle w/ no command

What command is being run when you call bundle? Is it just calling bundle install under the hood?
Just running bundle calls the bundle script with it's last parameter-set.
Suppose, in your project, you initially did bundle install and then changed your Gemfile. To update the gems, you need not repeat bundle install again (though, you still can), you can simply run:
bundle
Similarly, if you initially used bundle install --binstubs (with binstubs flag), using bundle later in the project, will trigger the former command again.
Good luck. :)

Resources