i've a problem with the deploying.
i have a ubuntu 11.10 server, i have installed ruby 1.9.2 and rails 3.2.6 with RVM.
i have yet made the pull of my git, it's located in /home/**/idepro.git
i runned the "capify ." command and i modify the deploy.rb file.
i haven't any problem when i run the commands "cap deploy:setup" and "cap deploy:check", but when i run "cap deploy" i have a problem with the enviorment path. The error is:
** [out :: 176.58.****] /usr/bin/env: ruby
** [out :: 176.58.****] : No such file or directory
these are the ror's path:
******#******:~$ which ruby
/home/******/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
and this is the value of $PATH:
******#******:~$ echo $PATH
/home/******/.rvm/gems/ruby-1.9.2-p320/bin:/home/******/.rvm/gems/ruby-1.9.2-p320#global/bin:/home/******/.rvm/rubies/ruby-1.9.2-p320/bin:/home/******/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/******/.rvm/gems/ruby-1.9.2-p320/bin
This is my deploy.rb file:
# RVM bootstrap
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
#require 'rvm/capistrano'
set :rvm_ruby_string, 'ruby1.9.2-p290'
# bundler bootstrap
require 'bundler/capistrano'
# main details
set :application, "176.58.******"
role :web, "176.58.******"
role :app, "176.58.******"
role :db, "176.58.******", :primary => true
ssh_options[:port] = ******
set :user, "******"
set :password, "******"
# server details
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/idealarm2"
set :deploy_via, :remote_cache
set :user, "passenger"
set :use_sudo, false
# repo details
set :scm, :git
set :scm_username, "passenger"
set :repository, "/home/******/idepro.git"
set :branch, "master"
set :git_enable_submodules, 1
# tasks
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
end
#default_environment['PATH']='/home/******/.rvm/gems/ruby-1.9.2-p320/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin/:/usr/bin:/bin'
#default_environment['GEM_PATH']='/home/******/.rvm/gems/ruby-1.9.2-p320:/home/******/.rvm/gems/ruby-1.9.2-p320#global:/usr/lib/ruby/gems/1.$
Could anyone help me with the PATH configuration?
I'm using capistrano with RVM with no issues, having followed the 'Integration via the rvm-capistrano gem' section instructions at https://rvm.io//integration/capistrano/.
Related
Here is my deploy.rb
require "bundler/capistrano"
set :rvm_ruby_string, "ruby-2.0.0-p247"
set :rvm_type, :user
set :application, "myapp"
set :repository, "git#bitbucket.org:user/myapp.git"
set :user, "my-server-username-ssh"
set :branch, "master"
set :deploy_to, "/var/rails_apps/myapp" # I have current, release and shared directory here
set :deploy_via, :copy
set :use_sudo, true
set :rvm_install_with_sudo, true
default_run_options[:pty] = true
set :port, 1234
set :scm, :git
role :web, "myapp.com"
role :app, "myapp.com"
role :db, "myapp.com", :primary => true
role :db, "myapp.com"
after "deploy:update_code","deploy:config_symlink"
set :rvm_type, :system
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
task :config_symlink do
#run "cp #{release_path}/config/database.yml.example #{release_path}/config/database.yml"
end
desc 'Re-establish database.yml'
task :set_database_symlink do
run "rm -fr #{current_path}/config/database.yml && cd #{current_path}/config &&
ln -nfs #{shared_path}/database.yml database.yml"
end
end
before 'deploy', 'rvm:install_ruby'
before 'deploy', 'rvm:create_gemset'
require "rvm/capistrano"
if i run cap deploy:migrate
I am getting error no database found error.
And when i manually run rake db:create in my server I am facing this error
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find multi_json-1.8.0 in any of the sources (Bundler::GemNotFound)
How can i create and migrate my database.
Edit-1
Even i have updated my certificate using
rvm osx-ssl-certs update all
In my gem list i can fine
multi_json (1.8.2)
I already had this gem installed but I need to
bundle update multi_json
Seems like you might have requirements for multiple versions of the multi_json gem. You can try specifying the gem version like:
gem 'multi_json', '1.8.0'
Rerun the bundle command locally and checkin your Gemfile.lock before you deploy.
i cant get capistrano to fully deploy my rails app to my dreamhost VPS..
as far as i can tell its halting at creating the release directory..
$ cap deploy
i get
failed: "sh -c 'cd /home/gasloggr/gasloggr.com/releases/20120824064241 && bundle install --gemfile /home/gasloggr/gasloggr.com/releases/20120824064241/Gemfile --path /home/gasloggr/gasloggr.com/shared/bundle --deployment --quiet --without development test'" on gasloggr.com
for troubleshooting purposes i ran what was in quotes on the server itself and i received..
bash: cd: /home/gasloggr/gasloggr.com/releases/20120824064241: No such file or directory
a quick ls -alh of the releases dir, and guess what... its empty.
My deploy.rb file
require 'bundler/capistrano'
default_run_options[:pty] = false
ssh_options[:forward_agent] = true
set :use_sudo, false
set :user, "gasloggr"
set :application, "gasloggr.com"
set :repository, "git#github.com:gorelative/GasLoggr.git"
set :scm, :git
set :branch, 'master'
set :git_shallow_clone, 1
set :deploy_via, :copy
set :copy_compression, :bz2
set :rails_env, 'production'
set :deploy_to, "/home/gasloggr/#{application}"
role :web, "#{application}" # Your HTTP server, Apache/etc
role :app, "#{application}" # This may be the same as your `Web` server
role :db, "#{application}", :primary => true # This is where Rails migrations will run
# role :db, "your slave db-server here"
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
i have tried removing :deploy_via as well as all of the below:
set :deploy_via, :remote_cache
set :deploy_via, :copy
Please try again following the methods outlined here: http://wiki.dreamhost.com/Capistrano
This specific part may be of the most help, mentioning cap deploy:setup : http://wiki.dreamhost.com/Capistrano#Deployment_with_Capistrano
I'm trying to deploy a Rails app on a VPS using the capistrano gem. I want to deploy it from my local machine to the VPS. I'm not using any repositories like Github or SVN.
So, I've installed the capistrano gem and ran 'bundle'. And added the following lines:
Capfile
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.3-p194#gemset'
deploy.rb
set :user, 'deploy'
set :application, "my_app"
set :scm, :none
set :deploy_via, :copy
set :deploy_to, "/home/#{user}/#{application}"
set :use_sudo, false
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
role :web, '1.2.3.4'
role :app, '1.2.3.4'
role :db, '1.2.3.4', :primary => true
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
However, after running 'cap deploy:setup' on local, I get the following error:
RVM - Capistrano integration was extracted to a separate gem, install: `gem install rvm-capistrano` and remove the `$LOAD_PATH.unshift` line, note also the 'set :rvm_type, :user' is now the default (instead of :system). (RuntimeError)
I'm not sure if I should use the rvm-capistrano gem. I'm a total newbie in deployments, detailed or step by step instructions would really help. Thanks.
Seems like you need to add
gem "rvm/capistrano"
to your Gemfile and then remove the unshift line (comment out)
When I deploy with capistrano I get an error (and rollback) when capistrano attempts to run assets:precompile.
I'm using rails 3.2.1, bundler 1.0.22, capistrano 2.11.2
If I run rake assets:precompile from /webapps/myapp/current it runs successfully.
error:
failed: "sh -c 'cd /webapps/myapp/releases/20120304160347 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'"
deploy.rb
require "bundler/capistrano"
load 'deploy/assets'
set :application, "myapp"
set :domain, '24.17.71.95'
set :repository, "."
set :deploy_via, :copy
set :local_repository, '/home/me/myapp/.git'
set :deploy_to, '/webapps/myapp/'
set :scm, :none #:git
set :user, 'me'
set :password, 'me$pw'
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
default_run_options[:pty] = true
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run
set :branch, 'master'
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
before "deploy:assets:precompile", "bundle:install"
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
As far as I know, the asset precompiling task should be one of the last (or even the last one) tasks that are beeing executed.
So please try to move
load 'deploy/assets'
out of deploy.rb into Capfile (root folder of your Rails app) and paste it as the last line of the file.
See my answer to this Stackoverflow question.
If that fails, try the advice in http://www.simonecarletti.com/blog/2012/02/heroku-and-rails-3-2-assetprecompile-error/
Here is the output of executing of deploy.rb with cap deploy, on ubuntu & rvm:
when executing .../bin/bundle install vendor/gem, the error comes:
* executing "cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
servers: ["12.34.56.78"]
[12.34.56.78] executing command
*** [err :: 12.34.56.78] /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle:18:in `<main>'
command finished in 624ms
failed: "sh -c 'cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems'" on 12.34.56.78
Here is the output of cap invoke COMMAND='which bundle':
** [out :: 12.34.56.78] /usr/local/bin/bundle
Here is the deploy.rb:
set :application, "myapp"
set :repository, "git://github.com/myapp/myapp.git"
set :scm, :git
set :user, "dtt"
set :use_sudo, true
set :scm_passphrase, "phrase"
set :branch, "master"
set :deploy_to, "/vol/www/#{application}"
#set :deploy_via, :remote_cache
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
server "12.34.56.78", :web, :app, :db, :primary => true
#role :web, "your web-server here" # Your HTTP server, Apache/etc
#role :app, "your app-server here" # This may be the same as your `Web` server
#role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :bundle_gems do
run "cd #{deploy_to}/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
end
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
Any suggestions about the error? Thanks.
Get cap to connect and tell you where bundle is installed
cap invoke COMMAND='which bundle'
If the bundle command is not found, your PATH is not set correctly. You might need to PermitUserEnvironment in the sshd running on that host. Then you can set the path manually in the deploy user's .ssh/environment file.
Is bundler installed on the remote machine?
Somewhere in your log it says:
Could not find bundler (>= 0)
The problem may be that you need to create the bundler wrapper. You can do that this way(in your deploy.rb, for example)
require "rvm/capistrano" # http://beginrescueend.com/integration/capistrano/
# rvm-capistrano settings
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
namespace :rvm do
task :create_bundle_wrapper, roles: :app do
run "rvm wrapper #{rvm_ruby_string} bundle bundle"
end
end
after "deploy:create_symlink", "rvm:create_bundle_wrapper"