Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Cygwin | gemのエイリアスを一括生成

概要

Cygwin環境でgemのエイリアスを一括生成

詳細

Cygwin環境でgemを利用しようとするとLoadエラーが発生します。
下記のようにエイリアスをつけると利用が可能になるため、
.bash_profile等に設定することでエラーを回避できます。

alias gem='C:/Ruby193/bin/gem'

C:/Ruby193がRubyのインストールフォルダだった場合に、
aliasのコマンドを一括生成するワンライナーは以下です。

ruby -e "Dir.glob(\"C:/Ruby193/bin/*.bat\").each {|f|p \"alias #{File.basename(f).gsub('.bat', '')}='#{f}'\"}" | tr -d '"'

出力

alias autospec='C:/Ruby193/bin/autospec.bat'
alias berks='C:/Ruby193/bin/berks.bat'
# 中略
alias xlsopcodes='C:/Ruby193/bin/xlsopcodes.bat'