SVX日記

2004|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|09|10|11|12|
2024|01|02|03|04|05|06|07|08|09|10|11|

2016-09-08(Thu) RubyGems環境をなんとかする

  個人的にCUI好きなのだが、GUIが必要な時もある。そんな時はcursesだ。リモートコンソール上でセミGUIが使える。作るのもラクだし、動作も軽快。てなわけで、これまで、これやら、これやら、これやらを作って、実用に供している。

  んが、いつしかRubyの標準添付ライブラリにcursesが含まれなくなってしまった。Fedoraのrubygem-xxxシリーズでの提供もない。別途、RubyGemsで入れろ、ということらしい。むぅ。

  ところが、たまにしかやらないし、ちょくちょくディストリの仕様側が変わるので、いつも試行錯誤になってしまう。そこで、現時点において、うまいことRubyGemsの環境を構築できた方法を「考え方つきで」メモしておくことにした。目的は「gem install curses」を成功させること。今回はFedora24で実行している。

  うおりゃ。

[root@xxx ~]# gem install curses
-bash: gem: command not found

  gemが入ってない。

[root@xxx ~]# dnf install rubygems

  うおりゃ。

[root@xxx ~]# gem install curses
……沈黙

  proxyの設定がない。

[root@xxx ~]# export http_proxy=http://proxy.example.com:8080/
[root@xxx ~]# export https_proxy=http://proxy.example.com:8080/

  うおりゃ。

[root@xxx ~]# gem install curses
Fetching: curses-1.0.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing curses:
	ERROR: Failed to build gem native extension.
 
    current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
/usr/bin/ruby -r ./siteconf20160909-3344-15aufht.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h ★
 
extconf failed, exit code 1
 
Gem files will remain installed in /usr/local/share/gems/gems/curses-1.0.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/curses-1.0.2/gem_make.out

  ruby.hがない。

[root@xxx ~]# dnf install ruby-devel

  うおりゃ。

[root@xxx ~]# gem install curses
Building native extensions.  This could take a while...
ERROR:  Error installing curses:
	ERROR: Failed to build gem native extension.
 
    current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
/usr/bin/ruby -r ./siteconf20160909-3373-17xujbr.rb extconf.rb
checking for tgetent() in -ltinfo... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
 
Provided configuration options:
<略>
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first. ★
	from /usr/share/ruby/mkmf.rb:541:in `try_link0'
<略>
	from extconf.rb:29:in `<main>'
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log
 
extconf failed, exit code 1
 
Gem files will remain installed in /usr/local/share/gems/gems/curses-1.0.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/curses-1.0.2/gem_make.out

  development tools、要するにgccが入ってない。

[root@xxx ~]# dnf install gcc

  うおりゃ。

[root@xxx ~]# gem install curses
Building native extensions.  This could take a while...
ERROR:  Error installing curses:
	ERROR: Failed to build gem native extension.
 
    current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
/usr/bin/ruby -r ./siteconf20160909-3509-162u4n0.rb extconf.rb
checking for tgetent() in -ltinfo... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
 
Provided configuration options:
<略>
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /usr/share/ruby/mkmf.rb:541:in `try_link0'
<略>
	from extconf.rb:29:in `<main>'
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log ★
 
extconf failed, exit code 1
 
Gem files will remain installed in /usr/local/share/gems/gems/curses-1.0.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/curses-1.0.2/gem_make.out

  ログを見てみる。

[root@xxx ~]# cat /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log
"gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I.    -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -mtune=generic -fPIC conftest.c  -L. -L/usr/lib64 -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector -rdynamic -Wl,-export-dynamic  -m64   -lruby  -lpthread -ldl -lcrypt -lm   -lc"
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory ★
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

  /usr/lib/rpm/redhat/redhat-hardened-cc1がない。どのパッケージに入っているかわからないので調べる。

[root@xxx ~]# dnf provides /usr/lib/rpm/redhat/redhat-hardened-cc1
redhat-rpm-config-40-2.fc24.noarch : Red Hat specific rpm configuration files ★
Repo        : fedora
 
redhat-rpm-config-41-2.fc24.noarch : Red Hat specific rpm configuration files ★
Repo        : updates

  redhat-rpm-configパッケージということなので入れる。

[root@xxx ~]# dnf install redhat-rpm-config

  うおりゃ。

[root@xxx ~]# gem install curses
Building native extensions.  This could take a while...
ERROR:  Error installing curses:
	ERROR: Failed to build gem native extension.
 
    current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
/usr/bin/ruby -r ./siteconf20160909-3658-cnj5ie.rb extconf.rb
checking for tgetent() in -ltinfo... no
checking for tgetent() in -ltermcap... no
checking for ncurses.h... no
checking for ncurses/curses.h... no
checking for ncursesw/curses.h... no
checking for curses_colr/curses.h... no
checking for curses.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
 
Provided configuration options:
<略>
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log ★
 
extconf failed, exit code 1
 
Gem files will remain installed in /usr/local/share/gems/gems/curses-1.0.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/curses-1.0.2/gem_make.out

  ログを見てみる。

[root@xxx ~]# cat /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log
 :
 :
have_header: checking for curses.h... -------------------- no
 
"gcc -E -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I.    -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -mtune=generic -fPIC  conftest.c -o conftest.i"
conftest.c:3:20: fatal error: curses.h: No such file or directory
 #include <curses.h>
                    ^
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <curses.h>
/* end */
 
--------------------

  curses.hがない。これはcursesの開発パッケージに入っている。

[root@xxx ~]# dnf install ncurses-devel

  うおりゃ。

[root@xxx ~]# gem install curses
Building native extensions.  This could take a while...
ERROR:  Error installing curses:
	ERROR: Failed to build gem native extension.
 
    current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
/usr/bin/ruby -r ./siteconf20160909-4359-1h9o77p.rb extconf.rb
checking for tgetent() in -ltinfo... yes
checking for ncurses.h... yes
checking for initscr() in -lncursesw... yes
header: ncurses.h
library: ncursesw
<略>
checking for function curses_version in ncurses.h... yes
checking for variable curses_version in ncurses.h... no
creating Makefile
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /usr/local/lib64/gems/ruby/curses-1.0.2/mkmf.log
 
current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
make "DESTDIR=" clean
sh: make: command not found ★
 
current directory: /usr/local/share/gems/gems/curses-1.0.2/ext/curses
make "DESTDIR="
sh: make: command not found ★
 
make failed, exit code 127
 
Gem files will remain installed in /usr/local/share/gems/gems/curses-1.0.2 for inspection.
Results logged to /usr/local/lib64/gems/ruby/curses-1.0.2/gem_make.out

  makeが入っていない。

[root@xxx ~]# dnf install make

  うおりゃ。

[root@xxx ~]# gem install curses
Building native extensions.  This could take a while...
Successfully installed curses-1.0.2
Parsing documentation for curses-1.0.2
Installing ri documentation for curses-1.0.2
Done installing documentation for curses after 1 seconds
1 gem installed

  というわけで「gem install curses」に成功ッ!

  画像の説明

  cccdct復活!