Rails 4 在部署 capistrano 后未检测到应用程序
Rails 4 doesn't detect application after capistrano deployment
我目前正在尝试使用 Capistrano 3 部署 Rails 4 应用程序。一切顺利,但我遇到了一个问题,是的!我无法在我的应用程序中 运行 任何 rails 命令。
这是我的相关 capistrano 插件:
gem 'capistrano-rails'
gem 'capistrano-unicorn-nginx'
gem 'capistrano-rbenv'
gem 'capistrano-secrets-yml'
gem 'capistrano-rails-console'
所以当我 运行 a cap production rails:console
它给我这个输出:
[b2458a1e] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.1 ] as user@x.x.x.x
DEBUG [b2458a1e] Command: [ -d ~/.rbenv/versions/2.1.1 ]
DEBUG [b2458a1e] Finished in 0.528 seconds with exit status 0 (successful).
INFO [2d552562] Running ~/.rbenv/bin/rbenv exec bundle exec rails console production as user@x.x.x.x
DEBUG [2d552562] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec bundle exec rails console production )
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/rails_app/.rbenv/versions/2.1.1/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/ frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--rc=RC]
有什么想法吗?
更新 13/03 - 添加 deploy.rb
# config valid only for current version of Capistrano
lock '3.3.5'
set :application, 'my_app'
set :repo_url, 'git@github.com:foo/my_app.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :branch, 'master'
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/var/www/my_app'
# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :rbenv_ruby, '2.1.1'
我认为问题在于您在 Rails 应用程序的已部署副本中缺少 bin/rails
。这是我会做的:
- 确保
bin
目录的内容已添加、提交并推送到 git 存储库。这将包括 bin/rails
和 bin/rake
.
- 从您的
deploy.rb
. 中 Capistrano 的 :linked_dirs
设置中删除 bin
- 重新部署。
我目前正在尝试使用 Capistrano 3 部署 Rails 4 应用程序。一切顺利,但我遇到了一个问题,是的!我无法在我的应用程序中 运行 任何 rails 命令。
这是我的相关 capistrano 插件:
gem 'capistrano-rails'
gem 'capistrano-unicorn-nginx'
gem 'capistrano-rbenv'
gem 'capistrano-secrets-yml'
gem 'capistrano-rails-console'
所以当我 运行 a cap production rails:console
它给我这个输出:
[b2458a1e] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.1 ] as user@x.x.x.x
DEBUG [b2458a1e] Command: [ -d ~/.rbenv/versions/2.1.1 ]
DEBUG [b2458a1e] Finished in 0.528 seconds with exit status 0 (successful).
INFO [2d552562] Running ~/.rbenv/bin/rbenv exec bundle exec rails console production as user@x.x.x.x
DEBUG [2d552562] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec bundle exec rails console production )
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/rails_app/.rbenv/versions/2.1.1/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/ frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--rc=RC]
有什么想法吗?
更新 13/03 - 添加 deploy.rb
# config valid only for current version of Capistrano
lock '3.3.5'
set :application, 'my_app'
set :repo_url, 'git@github.com:foo/my_app.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :branch, 'master'
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/var/www/my_app'
# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :rbenv_ruby, '2.1.1'
我认为问题在于您在 Rails 应用程序的已部署副本中缺少 bin/rails
。这是我会做的:
- 确保
bin
目录的内容已添加、提交并推送到 git 存储库。这将包括bin/rails
和bin/rake
. - 从您的
deploy.rb
. 中 Capistrano 的 - 重新部署。
:linked_dirs
设置中删除 bin