Last active
October 22, 2018 19:37
Star
You must be signed in to star a gist
Workaround for ubygems.rb / -rubygems parameter feature abruptly removed from Ruby. See https://bugs.ruby-lang.org/issues/14322
This file contains 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 | |
# Copyright:: 2018 Daniel Barrows | |
# License:: zlib/libpng | |
# https://gist.github.com/daniel-barrows/ca8359b76ad9bb84b37593a9f7b695fc | |
# | |
# Workaround for feature abruptly removed from Ruby. | |
# See https://bugs.ruby-lang.org/issues/14322 | |
# Leave warn variable empty to not output the deprecation warning. | |
warn=true | |
if ruby -e exit 2>&1 \ | |
| grep 'cannot load such file -- ubygems (LoadError)' >/dev/null; then | |
which sudo >/dev/null 2>&1 && sudo=sudo | |
ruby_lib_dir="$( ruby -e 'exit 0' 2>&1 | grep 'cannot load such file' \ | |
| sed 's,/rubygems/core_ext.\+,,' )" | |
if ! [ -z "$warn" ]; then | |
warning_msg="warn 'WARNING: -rubygems flag is deprecated. Use -rrubygems.'" | |
fi | |
printf "#!/usr/bin/env ruby\n%s\nrequire 'rubygems'\n" "$warning_msg" \ | |
| $sudo tee "$ruby_lib_dir/ubygems.rb" > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment