6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rubyでシステムにコマンドが存在するか確認する方法

Last updated at Posted at 2016-02-18

mkmfライブラリのfind_executableを使う。

$ pry
[1] pry(main)> require 'mkmf'
=> true
[2] pry(main)> find_executable('dfu-util')
checking for dfu-util... yes
=> "/usr/local/bin/dfu-util"
[3] pry(main)> find_executable('kyoko-command')
checking for kyoko-command... no
=> nil

mkmf.log が出力されてしまうので、

module MakeMakefile::Logging
   @logfile = '/dev/null'
end

みたいなことをしたんだけどmkmfのメソッドを単体で使わないほうがいいのかな。

6
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?