Skip to content

Instantly share code, notes, and snippets.

@Glutexo
Last active September 30, 2019 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glutexo/9a95dceae23c09f31805a0058abbf2ba to your computer and use it in GitHub Desktop.
Save Glutexo/9a95dceae23c09f31805a0058abbf2ba to your computer and use it in GitHub Desktop.
Update pyenv shims
#!/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