LoginSignup
4
4

More than 3 years have passed since last update.

ruby初心者がgemファイルのインストール失敗をリカバったメモ

Last updated at Posted at 2014-08-29

背景

rubyで動画ファイルを作成日のディレクトリに移動する - Qiitaなる
記事を見つけ、これで子どもたちの撮影したまま整理していないビデオを整理できる!神エントリーじゃんと思った。

しかし、記事で紹介されているffmpeg-video-infoをgemコマンドで入れたら、ビルドエラー

extconf.rb:6:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:6:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:7:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
creating Makefile

make "DESTDIR="
compiling ffmpeg_video_info.c
ffmpeg_video_info.c:20:5: warning: implicit declaration of function 'my_dump_metadata' is invalid in C99 [-Wimplicit-function-declaration]
my_dump_metadata(NULL, ic->metadata, " ", metadata);
^
ffmpeg_video_info.c:79:13: warning: implicit declaration of function 'my_dump_stream_format' is invalid in C99 [-Wimplicit-function-declaration]
my_dump_stream_format(ic, i, index, is_output, stream);
^
ffmpeg_video_info.c:202:15: warning: implicit declaration of function 'get_bit_rate' is invalid in C99 [-Wimplicit-function-declaration]
bitrate = get_bit_rate(enc);
^
ffmpeg_video_info.c:232:6: error: conflicting types for 'my_dump_stream_format'
void my_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output, VALUE res)
^
ffmpeg_video_info.c:79:13: note: previous implicit declaration is here
my_dump_stream_format(ic, i, index, is_output, stream);
^
ffmpeg_video_info.c:289:6: error: conflicting types for 'my_dump_metadata'
void my_dump_metadata(void *ctx, AVDictionary *m, const char *indent, VALUE res)
^
ffmpeg_video_info.c:20:5: note: previous implicit declaration is here
my_dump_metadata(NULL, ic->metadata, " ", metadata);
^
ffmpeg_video_info.c:300:21: warning: implicit declaration of function 'av_strlcpy' is invalid in C99 [-Wimplicit-function-declaration]
av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
^
4 warnings and 2 errors generated.
make: *** [ffmpeg_video_info.o] Error 1

Gemのインストールで失敗したやつをコード修正してインストールするには

CygwinでBerkshelfをインストールする - Qiitaに、エラーになったgemを
修正してインストールする方法が載っていた。

gem fetch ffmpeg-video-info
gem unpack ffmpeg-video-info-0.1.4.gem
cd ffmpeg-video-info-0.1.4

問題箇所を修正する。

ffmpeg-video-infoの場合、プロトタイプ宣言が無かったので、これを追加。
gccは寛大だったが、Mavericksのgccという名のclangは容赦なかったらしい模様。

修正後にgemファイルを作り直して、これをインストール

gem spec --ruby ../ffmpeg-video-info-0.1.4.gem >ffmpeg-video-info-0.1.4.gemspec 
gem build ffmpeg-video-info-0.1.4.gemspec
gem install ./ffmpeg-video-info-0.1.4.gem

まとめ

gemインストールエラー時にファイルを残してくれているから、
そこで何とか出来そうな気もしなくもないが、何せruby初心者なので、
rakeしてエラーが出て諦めて、今回の方法を見つけたので、なんとなく、
次からもこれで対応できそうなので、すこし安心した。

関連記事

4
4
0

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
4
4