Last active
September 30, 2019 13:11
-
-
Save Glutexo/9a95dceae23c09f31805a0058abbf2ba to your computer and use it in GitHub Desktop.
Update pyenv shims
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
#!/usr/bin/env ruby | |
# Updates path to Python executables in ~/.pyenv/shims. `brew upgrade` breaks | |
# them. Set the correct versions in the EXPECTED and REPLACED variables below | |
# and run in ~/.pyenv/shims. WARNING! It replaces the files, not making any | |
# backups. Use at your own risk! | |
EXPECTED = <<~EOS.chomp | |
exec "/usr/local/Cellar/pyenv/1.2.13/libexec/pyenv" exec "$program" "$@" | |
EOS | |
REPLACED = <<~EOS.chomp | |
exec "/usr/local/Cellar/pyenv/1.2.13_1/libexec/pyenv" exec "$program" "$@" | |
EOS | |
Dir.entries('.').each do |entry| | |
next if %w(. ..).include?(entry) | |
lines = [] | |
File.open(entry, 'r') do |file| | |
file.each_line do |line| | |
chomped_line = line.chomp | |
lines << (chomped_line == EXPECTED ? REPLACED : chomped_line) | |
end | |
end | |
File.write("#{entry}", lines.join("\n")) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment