使用 mina 在 aws 中部署 rails 应用程序时找不到捆绑命令
Bundle command not found while deploying rails app in aws using mina
在使用 mina 部署我的 rails 应用程序时,我遇到了类似 bash: line 82: bundle: command not found
的错误。我用谷歌搜索但找不到任何解决方案。我该如何解决这个问题?
这是我的deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
set :user, 'ubuntu'
set :domain, 'www.fuitter.com'
set :deploy_to, '/usr/share/nginx/html/fuitter'
set :repository, 'git@bitbucket.org:mc_cannibal/fuitter2.git'
set :branch, 'master'
set :forward_agent, true
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']
task :environment do
ruby_version = File.read('.ruby-version').strip
raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
queue %{
source /etc/profile.d/rvm.sh
rvm use #{ruby_version} || exit 1
}
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
# Add the repository server to .ssh/known_hosts
if repository
repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'
queue! %[
if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
fi
]
end
# Create database.yml for Postgres if it doesn't exist
path_database_yml = "#{deploy_to}/#{shared_path}/config/database.yml"
database_yml = %[production:
database: fuitter
adapter: postgresql
pool: 5
timeout: 5000]
queue! %[ test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml} ]
# Create secrets.yml if it doesn't exist
path_secrets_yml = "#{deploy_to}/#{shared_path}/config/secrets.yml"
secret =
secrets_yml = %[production:
secret_key_base:
#{`rake secret`.strip}]
queue! %[ test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml} ]
queue! %[chmod g+rx,u+rwx,o-rwx "#{deploy_to}/#{shared_path}/config"]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
#queue "service #{user} restart"
end
end
end
我应该在版本控制中推送 deploy.rb 文件吗?
PS 我安装了 rvm。
好的,我已经修好了。我放错了 rvm 路径。在 运行 which rvm
之后,我复制了那个路径并粘贴到这里。
task :environment do
ruby_version = File.read('.ruby-version').strip
raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
queue %{
source path/to/rvm
rvm use #{ruby_version} || exit 1
}
end
您可以使用此配置调用 rvm
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
# invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
invoke :'rvm:use', 'ruby-x.x.x'
end
在使用 mina 部署我的 rails 应用程序时,我遇到了类似 bash: line 82: bundle: command not found
的错误。我用谷歌搜索但找不到任何解决方案。我该如何解决这个问题?
这是我的deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
set :user, 'ubuntu'
set :domain, 'www.fuitter.com'
set :deploy_to, '/usr/share/nginx/html/fuitter'
set :repository, 'git@bitbucket.org:mc_cannibal/fuitter2.git'
set :branch, 'master'
set :forward_agent, true
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']
task :environment do
ruby_version = File.read('.ruby-version').strip
raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
queue %{
source /etc/profile.d/rvm.sh
rvm use #{ruby_version} || exit 1
}
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
# Add the repository server to .ssh/known_hosts
if repository
repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'
queue! %[
if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
fi
]
end
# Create database.yml for Postgres if it doesn't exist
path_database_yml = "#{deploy_to}/#{shared_path}/config/database.yml"
database_yml = %[production:
database: fuitter
adapter: postgresql
pool: 5
timeout: 5000]
queue! %[ test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml} ]
# Create secrets.yml if it doesn't exist
path_secrets_yml = "#{deploy_to}/#{shared_path}/config/secrets.yml"
secret =
secrets_yml = %[production:
secret_key_base:
#{`rake secret`.strip}]
queue! %[ test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml} ]
queue! %[chmod g+rx,u+rwx,o-rwx "#{deploy_to}/#{shared_path}/config"]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
#queue "service #{user} restart"
end
end
end
我应该在版本控制中推送 deploy.rb 文件吗? PS 我安装了 rvm。
好的,我已经修好了。我放错了 rvm 路径。在 运行 which rvm
之后,我复制了那个路径并粘贴到这里。
task :environment do
ruby_version = File.read('.ruby-version').strip
raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
queue %{
source path/to/rvm
rvm use #{ruby_version} || exit 1
}
end
您可以使用此配置调用 rvm
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
# invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
invoke :'rvm:use', 'ruby-x.x.x'
end