git sources rebuild on each deploy #2078

Closed
lucaspiller opened this Issue Aug 27, 2012 · 1 comment

Projects

None yet

2 participants

@lucaspiller

I'm having a strange problem with bundler when we deploy our app. I believe the cause is git sources being rebuild on each deploy, however I'll go through the issue first in case this isn't it.

Each developer has a shell account on each of the web servers, and deploys as themselves. They all belong to the same group, and permissions are setup to deal with this (an after deploy task in capistrano ensures that the deployed release and shared directory continues to have the correct permissions) - I'm not sure whether this is the best way but it is what we have been doing, and so far has worked out pretty well, I am however open to suggestions otherwise.

Anyway, now this has become an issue, now whenever anybody (apart from the last person to deploy) tries they receive the following:

 ** [out :: <snip>] Errno::EPERM: Operation not permitted - /var/www/<snip>/shared/bundle/ruby/1.9.1/bundler/gems/premailer-023af276c810/bin/premailer
 ** [out :: <snip>] An error occured while installing premailer (1.7.3), and Bundler cannot continue.
 ** [out :: <snip>] Make sure that `gem install premailer -v '1.7.3'` succeeds before bundling.

Running bundler by itself we get this:

$ bundle install --gemfile /var/www/<snip>/current/Gemfile --path /var/www/<snip>/shared/bundle --deployment --verbose --without development test
...
Using premailer (1.7.3) from https://github.com/alexdunae/premailer.git (at master)   * Checking out revision: master
  Successfully built RubyGem
  Name: premailer
  Version: 1.7.3
  File: premailer-1.7.3.gem

Errno::EPERM: Operation not permitted - /var/www/<snip>/shared/bundle/ruby/1.9.1/bundler/gems/premailer-023af276c810/bin/premailer
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:1323:in `chmod'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:1323:in `chmod'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:970:in `block in chmod'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:969:in `each'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:969:in `chmod'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/rubygems/installer.rb:301:in `block in generate_bin'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/rubygems/installer.rb:291:in `each'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/rubygems/installer.rb:291:in `generate_bin'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/source.rb:391:in `generate_bin'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/source.rb:449:in `generate_bin'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/source.rb:568:in `install'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:97:in `with_build_args'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:72:in `install_gem_from_spec'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:56:in `block in run'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/forwardable.rb:201:in `each'
/opt/ruby-1.9.3-p125/lib/ruby/1.9.1/forwardable.rb:201:in `each'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:55:in `run'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:12:in `install'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/cli.rb:220:in `install'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/task.rb:22:in `run'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor.rb:263:in `dispatch'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/base.rb:386:in `start'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/bin/bundle:13:in `<top (required)>'
/usr/bin/bundle:19:in `load'
/usr/bin/bundle:19:in `<main>'
An error occured while installing premailer (1.7.3), and Bundler cannot continue.
Make sure that `gem install premailer -v '1.7.3'` succeeds before bundling.
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:95:in `rescue in install_gem_from_spec'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:68:in `install_gem_from_spec'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:56:in `block in run'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:55:in `run'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/installer.rb:12:in `install'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/cli.rb:220:in `install'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/task.rb:22:in `run'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor.rb:263:in `dispatch'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/vendor/thor/base.rb:386:in `start'
/opt/ruby-1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/bin/bundle:13:in `<top (required)>'
/usr/bin/bundle:19:in `load'
/usr/bin/bundle:19:in `<main>'`

This gem was first installed on the last deploy, and permissions on the file are as follows:

$ ls -la /var/www/<snip>/shared/bundle/ruby/1.9.1/bundler/gems/premailer-023af276c810/bin/premailer
-rwxrwxr-x 1 piotr www-data 144 2012-08-27 13:08 /var/www/<snip>/shared/bundle/ruby/1.9.1/bundler/gems/premailer-023af276c810/bin/premailer

The gem is being rebuild and reinstalled, and as it has binary files these are being chmoded. However, because the file always exists and is owned by another user, this fails and an exception is thrown.

I don't understand why is it trying to reinstall this gem though, it is already installed. Non git source gems seem to be fine, but running bundle install for all git source gems (attempts to) reinstalls them. Am I missing a cache directory somewhere?

@xaviershay
Contributor

Closing as a dup of #1977, see that one for discussion.

@xaviershay xaviershay closed this Aug 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment