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

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

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

Terminalは、Apple社のmacOSに標準で付属しているUNIX端末エミュレータ。UNIXコマンドによってMacの操作および設定を行うことができます。

Ruby

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

2回答

878閲覧

古いバージョンのrubyで書かれたプログラムをherokuでデプロイしたい。

yutann

総合スコア23

terminal

Terminalは、Apple社のmacOSに標準で付属しているUNIX端末エミュレータ。UNIXコマンドによってMacの操作および設定を行うことができます。

Ruby

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2020/08/18 09:05

編集2020/08/18 13:08

解決したいこと

gitリモートリポジトリにあるアプリケーションをクローンして、それをherokuでデプロイすることを通して、herokuの使い方を勉強をしようとしています。

実行したこと

まずアプリケーションをクローンして、そのあとterminalを使ってherokuにログインしました。以下のコードを実行して、heroku上にアプリケーションを作成したところ、自動でthawing-lake-19173と名付けられました。

terminal

1heroku create

これによって、thawing-lake-19173.gitというリポジトリが生成されたようなので、そこにこちらのコードを実行してクローンしたアプリケーションをpushしようとしました。

terminal

1git push heroku master

コードを実行したところ、以下のエラーが発生しました。

terminal

1Enumerating objects: 222, done. 2Counting objects: 100% (222/222), done. 3Delta compression using up to 4 threads 4Compressing objects: 100% (118/118), done. 5Writing objects: 100% (222/222), 77.46 KiB | 25.82 MiB/s, done. 6Total 222 (delta 90), reused 222 (delta 90), pack-reused 0 7remote: Compressing source files... done. 8remote: Building source: 9remote: 10remote: -----> Ruby app detected 11remote: -----> Installing bundler 1.17.3 12remote: -----> Removing BUNDLED WITH version in the Gemfile.lock 13remote: -----> Compiling Ruby/Rails 14remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.3.3.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3. 15remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.3.3.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3. 16remote: 17remote: ! 18remote: ! The Ruby version you are trying to install does not exist on this stack. 19remote: ! 20remote: ! You are trying to install ruby-2.3.3 on heroku-18. 21remote: ! 22remote: ! Ruby ruby-2.3.3 is present on the following stacks: 23remote: ! 24remote: ! - cedar-14 25remote: ! - heroku-16 26remote: ! 27remote: ! Heroku recommends you use the latest supported Ruby version listed here: 28remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes 29remote: ! 30remote: ! For more information on syntax for declaring a Ruby version see: 31remote: ! https://devcenter.heroku.com/articles/ruby-versions 32remote: ! 33remote: ! Push rejected, failed to compile Ruby app. 34remote: 35remote: ! Push failed 36remote: Verifying deploy... 37remote: 38remote: ! Push rejected to thawing-lake-19173. 39remote: 40To https://git.heroku.com/thawing-lake-19173.git 41 ! [remote rejected] master -> master (pre-receive hook declined) 42error: failed to push some refs to 'https://git.heroku.com/thawing-lake-19173.git'

You are trying to install ruby-2.3.3 on heroku-18.

Ruby ruby-2.3.3 is present on the following stacks:
cedar-14
heroku-16

とあるのですが、herokuのstackを18から、あえて古い16に変更することは可能でしょうか?
stackが変更できない場合、それ以外の方法としては何をするのが良いでしょうか。
アプリケーションをpushするのに適した方法を教えていただきたいです。
よろしくお願いします。

追記として、アプリケーション内のGemfileは以下のようになっています。

Gemfile

1source 'https://rubygems.org' 2 3ruby "2.3.3" 4 5gem 'rspec' 6gem 'rspec-rails' 7gem 'rake' 8 9# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10gem 'rails', '~> 4.2.0' 11# Use SCSS for stylesheets 12# gem 'sass-rails', '~> 5.0' 13# Use Uglifier as compressor for JavaScript assets 14# gem 'uglifier', '>= 1.3.0' 15# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 16# gem 'jbuilder', '~> 2.0' 17# bundle exec rake doc:rails generates the API under doc/api. 18# gem 'sdoc', '~> 0.4.0', group: :doc 19 20# Use ActiveModel has_secure_password 21# gem 'bcrypt', '~> 3.1.7' 22 23# Use Unicorn as the app server 24# gem 'unicorn' 25 26# Use Capistrano for deployment 27# gem 'capistrano-rails', group: :development 28 29group :development do 30 # Use sqlite3 as the database for Active Record 31 gem 'sqlite3' 32 # Access an IRB console on exception pages or by using <%= console %> in views 33 gem 'web-console', '~> 2.0' 34end 35 36group :production do 37 # Use postgresql as the database for Active Record 38 gem 'pg', '~> 0.15' 39 # Use easily Heroku with Rails 40 gem 'rails_12factor' 41end 42

git上のリポジトリのURL

クローンしたアプリケーションのURLはこちらになります。

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

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

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

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

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

gouf

2020/08/18 11:21

学習目的であるのなら Ruby を現行バージョンに上げてみては?; バージョンアップした場合、なにか不具合は見られますか? 資料 (Ruby のリリース情報) : https://www.ruby-lang.org/en/downloads/releases/
yutann

2020/08/18 12:53

お答えいただきありがとうございます。 アプリケーションの中にあるGemfileを追記させていただきました。そのGemfile中のrubyのバージョンを上げてみたところ、依然として"You are trying to install ruby-2.3.3 on heroku-18."と表示されました。どうすればrubyのバージョンを上げられるのでしょうか。 なお、アプリケーション自体は他の方が作られたものなのでどのようにプログラムされているのか今のところ理解できていません…
gouf

2020/08/18 13:03

Ruby のバージョン (Gemfile) を 2.6.6 に変更した場合、なにか変化は見られますか? 加えて、プライベート リポジトリでなければ... リポジトリの情報は公開可能ですか? "秘密" は少ないほうが、回答が得られやすいでしょう
yutann

2020/08/18 13:14

Gemfileの2行目を2.6.6に変更してpushしようとしたところ、同様のエラーが出ました。 リポジトリの情報は追記させていただいたので参考にしていただければと思います。 よろしくお願いします。
gouf

2020/08/18 13:33 編集

すでにデータを数多く登録している... とかでなければ、素直に Heroku 側のアプリケーションを作り直してみるとよいかもしれません 1. git に登録されている heroku と名付けられたリモートの登録を削除 (git remote delete ...) 2. heroku create で改めて Heroku 側環境を新規作成 3. git push heroku master でリポジトリを Heroku に転送 4. heroku open で Web ブラウザ上で動作確認 あとは変更差分を忘れずコミットすれば 無事 データベース関連のエラーが発生するはずです (これは heroku run rake db:migrate する)
yutann

2020/08/18 13:52

3を実行した際に、今までと同じエラーが発生しました。 rubyの2.3.3は今のheroku-18に対応していないようなので、rubyのバージョンをあげるかherokuの方のバージョンを下げるかして調整する必要があると思うのですが、どうすれば良いでしょうか…
gouf

2020/08/18 22:36

前記、Ruby のバージョンを 2.6.6 に変更し、bundle install (+ git での commit) をするのも併せて実行した場合、なにか変化は見られますか?
yutann

2020/08/20 14:57

返信遅れてしまい申し訳ありませんでした。実行した結果、今までのエラーは改善されました。次に、 Precompiling assets failed.というエラーが出ました…
yutann

2020/08/20 15:01

ログ中の以下の部分が問題かと思います。 rake aborted! remote: Sprockets::Railtie::ManifestNeededError: Expected to find a manifest file in `app/assets/config/manifest.js` remote: But did not, please create this file and use it to link any assets that need remote: to be rendered by your app: remote: remote: Example: remote: //= link_tree ../images remote: //= link_directory ../javascripts .js remote: //= link_directory ../stylesheets .css remote: and restart your server
yutann

2020/08/20 15:29

manifest.jsと、さらにgemでuglifierというものを加えたところ、pushすることができました。 ご丁寧に教えていただき本当にありがとうございました!
guest

回答2

0

自己解決

解決に必要だったのは、gemやgitの使い方に関する基本的な知識でした。具体的には、
gemについては、Gemfileに読み込みたいパッケージを書いたあと、保存をして、bundle installによって実際にそのパッケージをインストールする。
gitについては、gemでインストールしたパッケージや変更したファイルの情報をまずgit add .でステージングして、git commitでローカルリポジトリにコミットして、最後git push heroku masterでmaster branchにpushするという流れでした。
以上の基本的なポイントを抑えて試行錯誤したところ解決しました。
同じような問題で困っている方の参考になればと思います。

投稿2020/08/21 02:27

yutann

総合スコア23

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

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

0

解決に必要だったのは、gemやgitの使い方に関する基本的な知識でした。具体的には、
gemについては、Gemfileに読み込みたいパッケージを書いたあと、保存をして、bundle installによって実際にそのパッケージをインストールする。
gitについては、gemでインストールしたパッケージや変更したファイルの情報をまずgit add .でステージングして、git commitでローカルリポジトリにコミットして、最後git push heroku masterでmaster branchにpushするという流れでした。
以上の基本的なポイントを抑えて試行錯誤したところ解決しました。
同じような問題で困っている方の参考になればと思います。

投稿2020/08/21 02:34

yutann

総合スコア23

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問