Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

post_install hook fails #15

Open
manuelmeurer opened this issue Dec 8, 2014 · 8 comments
Open

post_install hook fails #15

manuelmeurer opened this issue Dec 8, 2014 · 8 comments

Comments

@manuelmeurer
Copy link

When I run bundle install with the sdoc gem in my Gemfile, I get this error:

...
post_install hook at
/home/chief/.rbenv/plugins/rbenv-gem-rehash/rubygems_plugin.rb:1 failed for
sdoc-0.4.1

I guess it's because the gem executes git when checking for executables: https://github.com/voloko/sdoc/blob/087940a7220b523a3a3758479552fcf81329b320/sdoc.gemspec#L37

Replacing this line with a simple array of the executables would probably fix this, but is there any other way to make this work properly?

@manuelmeurer manuelmeurer changed the title post_install hook failes post_install hook fails Dec 8, 2014
@manuelmeurer
Copy link
Author

The same thing just happened for passenger-enterprise-server (not a public gem)

post_install hook at /Users/manuel/.rbenv/plugins/rbenv-gem-rehash/rubygems_plugin.rb:1 failed for passenger-enterprise-server-3.0.17

@skydan
Copy link

skydan commented Dec 21, 2014

post_install hook at /usr/local/Cellar/rbenv-gem-rehash/1.0.0/rubygems_plugin.rb:1 failed for jammit-0.6.6

@mcmire
Copy link

mcmire commented Sep 22, 2015

This has started to happen for me more often lately than before. I would imagine that rbenv rehash is actually failing in some way. I think it might be related to rbenv/rbenv#759. I have Bundler set to install gems in parallel, so after reading that issue I'm wondering if that's related somehow.

@kinsomicrote
Copy link

This happened to me minutes ago post_install hook at /home/kinsomicrote/.rbenv/plugins/rbenv-gem-rehash/rubygems_plugin.rb:1 failed for spree_cmd-3.0.5.beta
Any solution?

@LunarDevelopment
Copy link

I've also getting this issue but the chances of it getting solved after being open for over a year are slim I'm guessing..

@igorshtopor
Copy link

Had same for private repo. Will update if find out any details

@NicoBuch
Copy link

NicoBuch commented May 9, 2016

Try deleting rbenv-shim:

rm ~/.rbenv/shims/.rbenv-shim

@marcinhlybin
Copy link

If you ever stumble across this error here is a quick explanation what is happening and how to fix it.

After installing executables rbenv is rehashing shims by running rbenv rehash (~/.rbenv/libexec/rbenv-rehash). By default bundle install is using --jobs option set to the number of available processors.

Because bundle is installing gems in parallel, rbenv rehash may run in the same time for two gems leading to a race condition. Normally it wouldn't be a problem because rbenv will never run twice due to the lock file it creates in ~/.rbenv/shims/.rbenv-shim. Unfortunately the code for doing so looks like this:

set -o noclobber
{ echo > "$PROTOTYPE_SHIM_PATH"
} 2>| /dev/null ||
{ if [ -w "$SHIM_PATH" ]; then
    echo "rbenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
  else
    echo "rbenv: cannot rehash: $SHIM_PATH isn't writable"
  fi
  exit 1
} >&2
set +o noclobber

The noclobber option means that bash will not let you redirect to the existing file with >. If the file exists it will go straight to the if conditional to decide which message to display AND THEN it will exit with exit code 1.

Post install hook will interpret it as an error while installing a gem.

THE SOLUTION

You either:

  1. run bundle with -j1 which is slower but will not lead to a race condition because it will only use one thread.
  2. in the code listed above in ~/.rbenv/shims/.rbenv-shim change exit 1 to exit 0. Not ideal but it works. For CI you can do it easily with sed by running:
sed -i.bak 's/exit 1/exit 0/g' ~/.rbenv/libexec/rbenv-rehash

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants