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

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

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

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

Ruby on Rails

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

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

解決済

1回答

186閲覧

Capistranoで、最新のものがデプロイされない

harukiti

総合スコア4

Ruby

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

Ruby on Rails

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

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2023/11/18 16:59

Capistranoでのデプロイについてご質問です。

https://qiita.com/d0ne1s/items/2dd0ec73db1b0f473509#puma%E3%82%92%E8%B5%B7%E5%8B%95
上記を参考に、ローカルのファイル一式をサーバー(さくらのVPS,CentOS7)にデプロイしようと、「bundle exec cap production deploy」を叩いたところです。
参考記事でいうと「pumaを起動」の前です。

そのときのGemfileはこんな感じです。

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } リスト ruby '3.2.2' リスト # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3' # Use mysql as the database for Active Record リスト # Use Puma as the app server gem 'puma', '~> 4.1' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 4.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' リスト # Use Active Storage variant # gem 'image_processing', '~> 1.2' リスト # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false リスト group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end リスト group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end リスト # Windows does not include zoneinfo files, so bundle the tzinfo-data gem リスト リスト gem 'capistrano', '~> 3.14' gem 'capistrano-rbenv' gem 'capistrano-rails', '1.6.0' gem 'capistrano-puma', '0.2.3', require: false

デプロイされているかをサーバー内で確認したところ、

ls -l drwxrwxr-x 12 harumaki harumaki 4096 Nov 19 01:26 20231118162617

一見問題なさそうなのですが、Gemfileの中身を見ると少し違うのです。。。
(おそらく、過去に編集していた内容が反映されているのだと思います)

source "https://rubygems.org" ruby "3.2.2" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.1.0" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" # Use sqlite3 as the database for Active Record gem "sqlite3", "~> 1.4" # Use the Puma web server [https://github.com/puma/puma] gem "puma", ">= 5.0" # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] gem "importmap-rails" # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] gem "turbo-rails" # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] gem "stimulus-rails" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" # Use Redis adapter to run Action Cable in production # gem "redis", ">= 4.0.1" # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] # gem "kredis" # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem "tzinfo-data", platforms: %i[ windows jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ] end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] # gem "rack-mini-profiler" # Speed up commands on slow machines / big apps [https://github.com/rails/spring] # gem "spring" end group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem "capybara" gem "selenium-webdriver" end

これはどのようにすれば最新のもの(ローカルの最新ファイル)をデプロイできるようになるのでしょうか。
修正して「bundle install」をしてみたり、Gemfile.lockを一回消してみたりしましたが、初心者のため分からず。。。

お手数をおかけしますが、解決方法をご教示いただけますと幸いです。
よろしくお願いいたします。

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

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

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

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

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

guest

回答1

0

自己解決

すみません、解決しました。
ローカル→サーバー
にデプロイされると、すっかり勘違いしていました。
「CapistranoはGithubにアクセスしてソースコードを取得する」という情報を見て、deploy.rbを確認したところ「set :branch」の指定先を間違えていました。
変更したところ、無事に最新ファイルをデプロイできました。

投稿2023/11/18 17:16

harukiti

総合スコア4

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問