rbenv-default-gems
rbenv-default-gems copied to clipboard
Install after the fact
For some reason, rbenv-default-gems
didn't run at some point, and so my gems aren't installed. I tried to install them by running the install script by itself. Here's the output in zsh:
☰ bash install/default-gems.bash
rbenv: rbenv-default-gems plugin requires ruby-build 20130129 or later
I've got the latest Rbenv and Ruby-build repos. I'm not sure if the script was intended to be used this way, but it'd be nice to have just in case.
@kevinSuttle agreed! Same here… I was so disappointed when I didn’t get my sweet gems installed automagically. Clearly there’s some room to improvements on this plugin.
Note: I installed using homebrew (even though it isn’t the recommended way of doing it), because I personally prefer installing such things that way whenever it is possible.
I also install via Homebrew. I just like the convenience of automation.
didn't work for me either (also installed it via homebrew)
I installed straight from github but experienced the same error trying to call it directly. My ruby-build is version 20140408 which is higher that required.
Having a look at the code it might be split up and another method besides the "after_install" event could be created to allow direct access to the install_default_gems() function. Also the status check should be moved out of the install_default_gems() function.
Then the install_default_gems() function would be able to stand on its own so it cold be called any time you want to update your gems from the list of default gems for your currently selected ruby.
Totally agree. How do I update my existing rubies when I modify ~/default-gems?
I made this change:
diff --git a/etc/rbenv.d/install/default-gems.bash b/etc/rbenv.d/install/default-gems.bash
index a8a9a6a..540fadf 100644
--- a/etc/rbenv.d/install/default-gems.bash
+++ b/etc/rbenv.d/install/default-gems.bash
@@ -1,9 +1,3 @@
-if declare -Ff after_install >/dev/null; then
- after_install install_default_gems
-else
- echo "rbenv: rbenv-default-gems plugin requires ruby-build 20130129 or later" >&2
-fi
-
install_default_gems() {
# Only install default gems after successfully installing Ruby.
[ "$STATUS" = "0" ] || return 0
@@ -34,10 +28,16 @@ install_default_gems() {
# Invoke `gem install` in the just-installed Ruby. Point its
# stdin to /dev/null or else it'll read from our default-gems
# file.
- RBENV_VERSION="$VERSION_NAME" rbenv-exec gem install "$gem_name" "${args[@]}" < /dev/null || {
+ RBENV_VERSION="$VERSION_NAME" rbenv exec gem install "$gem_name" "${args[@]}" < /dev/null || {
echo "rbenv: error installing gem \`$gem_name'"
} >&2
done < "${RBENV_ROOT}/default-gems"
fi
}
+
+if declare -Ff after_install >/dev/null; then
+ after_install install_default_gems
+else
+ VERSION_NAME="$(rbenv version-name)" RBENV_ROOT="$(rbenv root)" STATUS=0 install_default_gems
+fi
And ran
bash .rbenv/plugins/rbenv-default-gems/etc/rbenv.d/install/default-gems.bash
Worked great! Gems are installed, and rbenv-install continues working as before.
It shouldn't be too hard to expand this into a proper 'rbenv install default-gems' command.
FWIW, I'm now running chruby with https://github.com/bronson/chruby-default-gems
That includes a command to install gems after the fact. :)