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

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

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

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

AWS(Amazon Web Services)

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

Q&A

解決済

1回答

5949閲覧

gemがインストールできない

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby on Rails 5

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

AWS(Amazon Web Services)

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

0グッド

0クリップ

投稿2020/01/11 01:58

編集2020/01/11 05:43

gemのインストールでエラーが発生してしまいます。
すみませんがアドバイスお願いします。

背景:RailsをAWSにデプロイ
参考:AWS(EC2)にRailsのWebアプリをデプロイする方法(Githubからクローン)

$ gem install bundler $ bundle init $ vim Gemfile (railsのバージョンを記載。gem "rails", '5.0.1')

次にvendor/bundle にgemを試みるとエラーとなります。

$ bundle install --path vendor/bundle --jobs=4 [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor/bundle'`, and stop using this flag Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`. Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Bundler could not find compatible versions for gem "bundler": In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on bundler (< 2.0, >= 1.3.0) Current Bundler version: bundler (2.1.2) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running `gem install bundler`? Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails (= 5.0.1)', in any of the sources.

試しに2.1.4をインストールするとアップデートを勧められ、

$ gem install bundler:2.1.4 $ bundle install --path vendor/bundle --jobs=4 [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor/bundle'`, and stop using this flag Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Bundler could not find compatible versions for gem "bundler": In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on bundler (< 2.0, >= 1.3.0) Current Bundler version: bundler (2.1.4) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running `gem install bundler`? Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails (= 5.0.1)', in any of the sources.

「gem install bundler」を実行してから改めて「bundle install --path vendor/bundle --jobs=4」を実行すると「--path」の代わりに「bundle config set path 'vendor/bundle'」と言われるので使ってみると、

$ bundle config set path 'vendor/bundle' Your application has set path to "vendor/bundle". This will override the global value you are currently setting $ bundle config Settings are listed in order of priority. The top value will be used. path Set for your local app (/var/www/projects/.bundle/config): "vendor/bundle" Set for the current user (/home/test_user/.bundle/config): "vendor/bundle" jobs Set for your local app (/var/www/projects/.bundle/config): 4

bundle insallで毎回vendor/bundleにインストールされるようなので、次に進みます。

次にrailsのバージョンを見ると「bundle install」でgem executablesをインストールしろと言われます。

$ bundle exec rails -v bundler: command not found: rails Install missing gem executables with `bundle install`

「gem executables」とはいったい何のことでしょうか?ググりましたが分かりませんでした。

追記;
「gem install rails」でrailsをインストールしようとするとRubyが古いと言われたので、2.5.1を入れたらrailsがインストールできました。
ただし今度は「$ bundle install --path vendor/bundle」を試みると、bundleは2.5.0しか使えない、とでました。

$ rbenv global 2.5.0
$ rbenv rehash
で使用rubyを2.5.0に設定しようとしても2.5.1から変わらず、仕方なく2.5.1をアンインストールして「rbenv global 2.5.0」で2.5.0に設定して「$ bundle install --path vendor/bundle」を試みたら、
rbenv: version `ruby-2.5.1' is not installed (set by /var/www/projects/***/.ruby-version)と言われる始末です。
vendor/bundle にgemをインストールする方法はないものでしょうか。。。

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

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

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

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

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

退会済みユーザー

退会済みユーザー

2020/01/11 02:54

ご指摘ありがとうございます。リンク修正しました。
guest

回答1

0

ベストアンサー

bundler (< 2.0, >= 1.3.0)

をインストールしろということでは?2.1.4じゃなくて。

「gem executables」とはいったい何のことでしょうか?

execute は「実行する」、executables は「実行可能なもの」という意味です。
つまり、

bundler: command not found: rails

Install missing gem executables with bundle install

railsコマンドが無いので、railsをインストールしろという意味です。

投稿2020/01/11 03:02

otn

総合スコア84505

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

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

退会済みユーザー

退会済みユーザー

2020/01/11 05:41

回答ありがとうございます。 railsコマンドがないので、gemをインストールしろ、ということかと思ってました。 railsはインストールできたのですが、次の問題が出てきてしまいました。 詳細は上に追記しましたので、よろしければ見ていただけると幸いです。
otn

2020/01/11 05:56 編集

> railsコマンドがないので、gemをインストールしろ、ということかと思ってました。 railsという名前の実行可能ファイル(=コマンド)を持つ gem、 つまり railsというgem をインストールしろということです。 > で使用rubyを2.5.0に設定しようとしても2.5.1から変わらず、仕方なく2.5.1をアンインストールして 原因を突き止めず、適当な対応をしてはいけません。 そのディレクトリでlocalで2.5.1を設定したのに忘れているのでは?
退会済みユーザー

退会済みユーザー

2020/01/12 23:08

アドバイスありがとうございます。 ご忠告通り、2.5.1のままで解決方法を探しました。 $ bundle install --path vendor/bundle rbenv: bundle: command not found The `bundle' command exists in these Ruby versions: 2.3.1 2.4.4 2.5.0 bundleがないと出たので、 $ gem install bundler でインストール。 次に再度試すと別のエラーメッセージが。 $ bundle install --path vendor/bundle Traceback (most recent call last): 2: from /home/test_user/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>' 1: from /home/test_user/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `a ctivate_bin_path' /home/test_user/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe ': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) ググってみると「Gemfile.lockに記載されているBUNDLE_WITHのバージョンと、bundlerのバージョンが異なるため」とあったので、Gemfile.lockの「BUNDLED WITH」部分を使用バージョンに書き換えると、コマンド($ bundle install --path vendor/bundle)が実行できました。 参考:https://www.yokoyan.net/entry/2019/01/11/181500 ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問