LoginSignup
3
1

More than 5 years have passed since last update.

FedoraにRailsを入れた時に躓いたメモ

Last updated at Posted at 2017-10-14

FedoraにRailsをインストールしようとしたらちょっと躓いたのでメモ

環境

Fedora26
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Rails 5.1.4

Rubyインストール

su -
dnf install ruby

ここは普通に問題なし。
余談ですがfedoraではyumの後継としてdnfってのがあるようですね。

Railsインストール(take1)

[root@localhost ~]# gem install -N rails
Fetching: i18n-0.8.6.gem (100%)
Successfully installed i18n-0.8.6
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.3.gem (100%)
Successfully installed tzinfo-1.2.3
Fetching: minitest-5.10.3.gem (100%)
Successfully installed minitest-5.10.3
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: activesupport-5.1.4.gem (100%)
Successfully installed activesupport-5.1.4
Fetching: rack-2.0.3.gem (100%)
Successfully installed rack-2.0.3
Fetching: rack-test-0.7.0.gem (100%)
Successfully installed rack-test-0.7.0
Fetching: mini_portile2-2.3.0.gem (100%)
Successfully installed mini_portile2-2.3.0
Fetching: nokogiri-1.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/gems/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby -r ./siteconf20171014-2850-5yzwpu.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/nokogiri-1.8.1 for inspection.
Results logged to /usr/local/lib64/gems/ruby/nokogiri-1.8.1/gem_make.out

エラーが出ました。
出力されたログを確認。

/usr/local/lib64/gems/ruby/nokogiri-1.8.1/gem_make.out
current directory: /usr/local/share/gems/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby -r ./siteconf20171014-2850-5yzwpu.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

rubyのヘッダーファイルがない模様。
なのでruby-develをインストール
dnf install ruby-devel

Railsインストール(take2)

[root@localhost ~]# gem install -N rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/gems/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby -r ./siteconf20171014-2904-13v3c3.rb extconf.rb
checking if the C compiler accepts ... *** 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:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)
    --help
    --clean
/usr/share/ruby/mkmf.rb:457: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:572:in `block in try_compile'
    from /usr/share/ruby/mkmf.rb:523:in `with_werror'
    from /usr/share/ruby/mkmf.rb:572:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /usr/share/ruby/mkmf.rb:630:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:407: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/nokogiri-1.8.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/gems/gems/nokogiri-1.8.1 for inspection.
Results logged to /usr/local/lib64/gems/ruby/nokogiri-1.8.1/gem_make.out

再度エラー。
ログファイル確認、今度は↓を見てみる。
/usr/local/lib64/gems/ruby/nokogiri-1.8.1/mkmf.log

/usr/local/lib64/gems/ruby/nokogiri-1.8.1/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: エラー: /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 */

また足りないファイルがある模様、
調べたところ下記パッケージが必要みたい。
dnf install redhat-rpm-config

Railsインストール(take3)

[root@localhost ~]# gem install -N railsBuilding native extensions.  This could take a while...
Successfully installed nokogiri-1.8.1
Fetching: crass-1.0.2.gem (100%)
Successfully installed crass-1.0.2
…
Fetching: rails-5.1.4.gem (100%)
Successfully installed rails-5.1.4
30 gems installed

無事インストール完了しました。

3
1
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
3
1