Created
February 3, 2013 09:31
-
-
Save arashm/4701056 to your computer and use it in GitHub Desktop.
migrate GEMs from rbenv cache to the newer version of ruby (without internet)
Thanks to Austin Ziegler - http://stackoverflow.com/questions/13649241/copying-gems-from-previous-version-of-ruby-in-rbenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i" | |
if [ ${#} -ne 2 ]; then | |
echo >&2 Usage: $(basename ${0}) old-version new-version | |
exit 1 | |
fi | |
home_path=$(cd ~; pwd -P) | |
old_version=${1} | |
new_version=${2} | |
rbenv shell ${old_version} | |
declare -a old_gem_paths old_gems | |
old_gem_paths=($(gem env gempath | sed -e 's/:/ /')) | |
rbenv shell ${new_version} | |
for ogp in "${old_gem_paths[@]}"; do | |
case "${ogp}" in | |
${home_path}/.gem/ruby*|*/.gem/ruby*) | |
# Skip ~/.gem/ruby. | |
continue | |
;; | |
esac | |
for old_gem in $(ls -L ${ogp}/cache/*.gem); do | |
gem install --local --ignore-dependencies ${old_gem} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment