kakudaisuke
@kakudaisuke (daisuke kaku)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

EC2 Amazon Linux 2でgem qiita_markdownがインストールできない

解決したいこと

Railsでアプリを作っていて、Amazon Lightsailインスタンス(EC2)にデプロイしています。
Rubyのgem、qiita_markdownをAmazon EC2 Amazon Linux 2で使いたいのですが、bundle installが通りません。
https://github.com/increments/qiita-markdown

インスタンス情報
Amazon Linux 2
2 GB RAM、1 vCPU、60 GB のSSD
Gemfile
gem 'qiita-markdown'

発生している問題・エラー

sudo yum install cmakeをしてbundle installをすると、下記のようになります。

.
.
.
Fetching rugged 1.3.1
Installing rugged 1.3.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rugged-1.3.1/ext/rugged
/home/ec2-user/.rbenv/versions/2.7.2/bin/ruby -I /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20220219-1146-ir5a3f.rb extconf.rb
checking for gmake... yes
checking for cmake... yes
checking for pkg-config... yes
CMake Error at CMakeLists.txt:14 (CMAKE_MINIMUM_REQUIRED):
  CMake 3.5.1 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!
 -- /usr/bin/gmake
*** 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}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/ec2-user/.rbenv/versions/2.7.2/bin/$(RUBY_BASE_NAME)
    --with-sha1dc
    --without-sha1dc
    --use-system-libraries
extconf.rb:23:in `sys': ERROR: '/usr/bin/gmake' failed (RuntimeError)
    from extconf.rb:107:in `block (2 levels) in <main>'
    from extconf.rb:103:in `chdir'
    from extconf.rb:103:in `block in <main>'
    from extconf.rb:100:in `chdir'
    from extconf.rb:100:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rugged-1.3.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rugged-1.3.1 for inspection.
Results logged to /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rugged-1.3.1/gem_make.out

An error occurred while installing rugged (1.3.1), and Bundler cannot continue.
Make sure that `gem install rugged -v '1.3.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  qiita-markdown was resolved to 0.40.0, which depends on
    github-linguist was resolved to 4.8.18, which depends on
      rugged

これが問題なのかなと思っています。

CMake 3.5.1 or higher is required. You are running version 2.8.12.2

$ cmake --version
cmake version 2.8.12.2

自分で試したこと

このコマンドが正しいのかわかりませんが、cmakeをバージョンを指定してインストールしようとしましたが、下記の通りダメでした。

$ sudo yum install cmake 3.5.1
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                              | 3.7 kB  00:00:00
amzn2extra-docker                                                                                                                                                                       | 3.0 kB  00:00:00
amzn2extra-nginx1                                                                                                                                                                       | 3.0 kB  00:00:00
amzn2extra-postgresql12                                                                                                                                                                 | 3.0 kB  00:00:00
epel/x86_64/metalink                                                                                                                                                                    | 6.9 kB  00:00:00
epel-debuginfo/x86_64/metalink                                                                                                                                                          | 6.2 kB  00:00:00
epel-source/x86_64/metalink                                                                                                                                                             | 6.6 kB  00:00:00
epel-testing/x86_64/metalink                                                                                                                                                            | 5.6 kB  00:00:00
epel-testing-debuginfo/x86_64/metalink                                                                                                                                                  | 5.0 kB  00:00:00
epel-testing-source/x86_64/metalink                                                                                                                                                     | 5.5 kB  00:00:00
nodesource                                                                                                                                                                              | 2.5 kB  00:00:00
yarn                                                                                                                                                                                    | 2.9 kB  00:00:00
217 packages excluded due to repository priority protections
パッケージ cmake-2.8.12.2-2.amzn2.0.2.x86_64 はインストール済みか最新バージョンです
パッケージ 3.5.1 は利用できません。
何もしません

ローカル開発環境

ちなみに、ローカル開発環境ではbrew install cmakeをしてうまくいっています。

$ cmake --version
cmake version 3.22.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

お力添えいただけますと幸いです。
よろしくお願いします。

0

1Answer

[ec2-user@ip-... ~]$ sudo amazon-linux-extras install -y epel
Installing epel-release
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
リポジトリーを清掃しています: amzn2-core amzn2extra-docker amzn2extra-epel amzn2extra-nginx1 amzn2extra-postgresql12 epel epel-debuginfo
                            : epel-source epel-testing epel-testing-debuginfo epel-testing-source nodesource yarn
[ec2-user@ip-... minnfra]$ wget https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz
--2022-02-20 08:46:44--  https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz
cmake.org (cmake.org) をDNSに問いあわせています... 66.194.253.25
cmake.org (cmake.org)|66.194.253.25|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 8388552 (8.0M) [application/x-gzip]
`cmake-3.12.3.tar.gz' に保存中
[ec2-user@ip-... minnfra]$ tar xvzf cmake-3.12.3.tar.gz
cmake-3.12.3/Packaging/
cmake-3.12.3/Packaging/CMakeDMGSetup.scpt

[ec2-user@ip-... minnfra]$ cd cmake-3.12.3/
[ec2-user@ip-... cmake-3.12.3]$ ./bootstrap

-- Configuring done
-- Generating done
-- Build files have been written to: /var/www/minnfra/cmake-3.12.3
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
[ec2-user@ip-... cmake-3.12.3]$ gmake
Scanning dependencies of target cmsys
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/ProcessUNIX.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Base64.c.o
[  1%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/EncodingC.c.o

Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo
[ec2-user@ip-... cmake-3.12.3]$ make
[  2%] Built target cmsys
[  4%] Built target cmsysTestsCxx
[  4%] Built target cmsysTestDynload

-- Installing: /usr/local/share/cmake-3.12/completions/cpack
-- Installing: /usr/local/share/cmake-3.12/completions/ctest

[ec2-user@ip-... cmake-3.12.3]$ cd ..
[ec2-user@ip-... minnfra]$ sudo yum remove cmake
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ cmake.x86_64 0:2.8.12.2-2.amzn2.0.2 を 削除
--> 依存性解決を終了しました。
amzn2-core/2/x86_64                                                                                                                                            | 3.7 kB  00:00:00
[ec2-user@ip-... minnfra]$ sudo yum install -y cmake
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
218 packages excluded due to repository priority protections
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ cmake.x86_64 0:2.8.12.2-2.amzn2.0.2 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

======================================================================================================================================================================================
 Package                               アーキテクチャー                       バージョン                                             リポジトリー                                容量
======================================================================================================================================================================================
インストール中:
 cmake                                 x86_64                                 2.8.12.2-2.amzn2.0.2                                   amzn2-core                                 6.9 M

トランザクションの要約
======================================================================================================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 6.9 M
インストール容量: 26 M
Downloading packages:
cmake-2.8.12.2-2.amzn2.0.2.x86_64.rpm                                                                                                                          | 6.9 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : cmake-2.8.12.2-2.amzn2.0.2.x86_64                                                                                                                     1/1
  検証中                  : cmake-2.8.12.2-2.amzn2.0.2.x86_64                                                                                                                     1/1

インストール:
  cmake.x86_64 0:2.8.12.2-2.amzn2.0.2

完了しました!
[ec2-user@ip-... minnfra]$ cmake --version
cmake version 3.12.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[ec2-user@ip-... minnfra]$ bundle install

Bundle complete! 38 Gemfile dependencies, 153 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------

bundle install通りました。

0Like

Your answer might help someone💌