質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

2089閲覧

AWSのEC2でのRubyのバージョンエラー

backroll

総合スコア3

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/05/31 02:45

編集2020/05/31 03:29

AWSのEC2で勉強のためのアプリを本番デプロイして運用しております。
そこで今回、本番環境のRubyのバージョンを「2.3.4 -> 2.6.0」にバージョンアップする作業を行っております。
ローカルのMacの開発環境では「2.3.4 -> 2.6.0」へのバージョンアップは上手くできました。

次に、本番環境のAWSのEC2環境のバージョンアップを実行し完了しました。

しかし、最後のCapistranoの自動デプロイで以下のようなエラーが発生し上手く実行できません。

00:22 bundler:install 01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/アプリ名/shared/bundle --jobs 4 --without d… 01 Your Ruby version is 2.3.4, but your Gemfile specified 2.6.0
DEBUG [3fff27b2] Command: cd /var/www/アプリ名/releases/20200531022958 && ( export S3_ACCESS_KEY="アクセスキー" S3_SECRET_KEY="シークレットキー" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.3.4" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/アプリ名/shared/bundle --jobs 4 --without development test --deployment --quiet ) DEBUG [3fff27b2] Your Ruby version is 2.3.4, but your Gemfile specified 2.6.0

本番環境のEC2のサーバーにsshでログインしてバージョンを確認すると以下のように表示されバージョンアップは正常に実行されているように思います。

ruby -v #=> 2.6.0

ちなみに、以下のファイルにも次のように記載してあります。

.ruby-version 2.6.0
.Gemfile ruby '2.6.0'

何卒、アドバイスなどよろしくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

おそらく、rbenv でinstallしたrubyと素で入れたrubyがあるのでしょう。
ec2ユーザーでloginしたときとdeployしたときの 環境変数PATHが違っているのだと思います。

deployが実行する起動scliptの中でPATHを設定しなおしましょう。
ruby -v #=> 2.6.0 した状態で which ruby した結果の PATH が上位に来るように編集してください。

素で入っているrubyをuninstallする手もあります

投稿2020/05/31 03:57

winterboum

総合スコア23347

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

backroll

2020/05/31 04:17 編集

ありがとうございます!ただ、そのように修正すると今度は以下のようなエラーが発生します。 00:20 bundler:install 01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/アプリ名/shared/bundle --jobs 4 --without d… 01 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 01 01 current directory: 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/ovirt-engine-sdk-4.4.0/ext/ovirtsdk4c 01 /home/ec2-admin-user/.rbenv/versions/2.6.0/bin/ruby -I 01 /home/ec2-admin-user/.rbenv/versions/2.6.0/lib/ruby/2.6.0 -r 01 ./siteconf20200531-26660-bm6pja.rb extconf.rb 01 checking for xml2-config... yes 01 checking for curl-config... no 01 *** extconf.rb failed *** 01 Could not create Makefile due to some reason, probably lack of necessary 01 libraries and/or headers. Check the mkmf.log file for more details. You may 01 need configuration options. 01 01 Provided configuration options: 01 --with-opt-dir 01 --without-opt-dir 01 --with-opt-include 01 --without-opt-include=${opt-dir}/include 01 --with-opt-lib 01 --without-opt-lib=${opt-dir}/lib 01 --with-make-prog 01 --without-make-prog 01 --srcdir=. 01 --curdir 01 --ruby=/home/ec2-admin-user/.rbenv/versions/2.6.0/bin/$(RUBY_BASE_NAME) 01 --with-libcurl-config 01 --without-libcurl-config 01 --with-pkg-config 01 --without-pkg-config 01 extconf.rb:40:in `<main>': The "libcurl" package isn't available. (RuntimeError) 01 01 To see why this extension failed to compile, please check the mkmf.log which can 01 be found here: 01 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ovirt-engine-sdk-4.4.0/mkmf.l… 01 01 extconf failed, exit code 1 01 01 Gem files will remain installed in 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/ovirt-engine-sdk-4.4.0 for 01 inspection. 01 Results logged to 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ovirt-engine-sdk-4.4.0/gem_ma… 01 01 An error occurred while installing ovirt-engine-sdk (4.4.0), and Bundler cannot 01 continue. 01 Make sure that `gem install ovirt-engine-sdk -v '4.4.0' --source 01 'https://rubygems.org/'` succeeds before bundling. 01 01 In Gemfile: 01 fog was resolved to 2.0.0, which depends on 01 fog-ovirt was resolved to 1.2.4, which depends on 01 ovirt-engine-sdk ローカル環境では発生しないです。
backroll

2020/05/31 04:44

gem install ovirt-engine-sdk -v '4.4.0' エラーの通りに本番環境で上記のコマンドを実行しても以下のようなエラーになります。 00:21 bundler:install 01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/アプリ名/shared/bundle --jobs 4 --without d… 01 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 01 01 current directory: 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/sassc-2.3.0/ext 01 /home/ec2-admin-user/.rbenv/versions/2.6.0/bin/ruby -I 01 /home/ec2-admin-user/.rbenv/versions/2.6.0/lib/ruby/2.6.0 -r 01 ./siteconf20200531-31576-1d1qhr9.rb extconf.rb 01 creating Makefile 01 01 current directory: 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/sassc-2.3.0/ext 01 make "DESTDIR=" clean 01 01 current directory: 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/sassc-2.3.0/ext 01 make "DESTDIR=" 01 compiling ./libsass/src/ast.cpp 01 compiling ./libsass/src/ast2c.cpp 01 compiling ./libsass/src/ast_fwd_decl.cpp 01 compiling ./libsass/src/ast_sel_cmp.cpp 01 compiling ./libsass/src/ast_sel_super.cpp 01 compiling ./libsass/src/ast_sel_unify.cpp 01 compiling ./libsass/src/ast_sel_weave.cpp 01 compiling ./libsass/src/ast_selectors.cpp 01 compiling ./libsass/src/ast_supports.cpp 01 compiling ./libsass/src/ast_values.cpp 01 compiling ./libsass/src/backtrace.cpp 01 compiling ./libsass/src/base64vlq.cpp 01 compiling ./libsass/src/bind.cpp 01 compiling ./libsass/src/c2ast.cpp 01 compiling ./libsass/src/c99func.c 01 compiling ./libsass/src/cencode.c 01 compiling ./libsass/src/check_nesting.cpp 01 compiling ./libsass/src/color_maps.cpp 01 compiling ./libsass/src/constants.cpp 01 compiling ./libsass/src/context.cpp 01 compiling ./libsass/src/cssize.cpp 01 compiling ./libsass/src/emitter.cpp 01 compiling ./libsass/src/environment.cpp 01 compiling ./libsass/src/error_handling.cpp 01 compiling ./libsass/src/eval.cpp 01 compiling ./libsass/src/eval_selectors.cpp 01 compiling ./libsass/src/expand.cpp 01 compiling ./libsass/src/extender.cpp 01 compiling ./libsass/src/extension.cpp 01 compiling ./libsass/src/file.cpp 01 compiling ./libsass/src/fn_colors.cpp 01 compiling ./libsass/src/fn_lists.cpp 01 compiling ./libsass/src/fn_maps.cpp 01 compiling ./libsass/src/fn_miscs.cpp 01 compiling ./libsass/src/fn_numbers.cpp 01 compiling ./libsass/src/fn_selectors.cpp 01 compiling ./libsass/src/fn_strings.cpp 01 compiling ./libsass/src/fn_utils.cpp 01 compiling ./libsass/src/inspect.cpp 01 compiling ./libsass/src/json.cpp 01 compiling ./libsass/src/lexer.cpp 01 compiling ./libsass/src/listize.cpp 01 compiling ./libsass/src/memory/SharedPtr.cpp 01 compiling ./libsass/src/operators.cpp 01 compiling ./libsass/src/output.cpp 01 compiling ./libsass/src/parser.cpp 01 virtual memory exhausted: メモリを確保できません 01 make: *** [parser.o] エラー 1 01 01 make failed, exit code 2 01 01 Gem files will remain installed in 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/gems/sassc-2.3.0 for inspection. 01 Results logged to 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/sassc-2.3.0/gem_make.out 01 01 An error occurred while installing sassc (2.3.0), and Bundler cannot continue. 01 Make sure that `gem install sassc -v '2.3.0' --source 'https://rubygems.org/'` 01 succeeds before bundling. 01 01 In Gemfile: 01 sass-rails was resolved to 6.0.0, which depends on 01 sassc-rails was resolved to 2.1.2, which depends on 01 sassc 次は、gem install sassc -v '2.3.0' --source 'https://rubygems.org/'を実行するように言われてますが、 本番環境で既にgem install sassc -v '2.3.0' --source 'https://rubygems.org/'は実行済です。 何故でしょうか?
winterboum

2020/05/31 05:30

To see why this extension failed to compile, please check the mkmf.log which can be found here: 01 01 /var/www/アプリ名/shared/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ovirt-engine-sdk-4.4.0/mkmf.l… とあります。まずそのlogを見てみましょう。 最後の方に何をすべきか書かれていることが多いです
backroll

2020/05/31 05:43

ありがとうございます! virtual memory exhausted: メモリを確保できません 上記のメッセージが出ておりました。 ちなみに、EC2のインスタンスはt2.smallです。 どのようにするのが、ベストでしょうか?
winterboum

2020/05/31 05:48

それmakeのlogでは?mkmf.logでもそうですか?
backroll

2020/05/31 05:54 編集

すみません、mkmf.logには以下のように書いてありました。 ...skipping... 184K ./.rbenv/versions/2.6.0/bin 311M ./.rbenv/versions/2.6.0 499M ./.rbenv/versions 40K ./.rbenv/shims 8.0K ./.rbenv/test/libexec find_executable: checking for xml2-config... -------------------- yes -------------------- find_executable: checking for curl-config... -------------------- yes -------------------- ...skipping... find_executable: checking for xml2-config... -------------------- yes -------------------- find_executable: checking for curl-config... -------------------- yes --------------------
winterboum

2020/05/31 06:26

エラーのところが重要
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問