I've wasted a few days on this problem and I'm sure it's a simple solution, please help!
When I run $ cap deploy:setup from my user account on my laptop I get the errors I've pasted below. It seems that there's a problem with RVM, but I know that it's installed, and I've pre-installed all the gems my app will need as well. Has anyone else encountered similar errors? Any help would be hugely appreciated!
* executing `deploy:setup'
* executing "mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids"
servers: ["arbiter.nullpointer.ca"]
[arbiter.nullpointer.ca] executing command
** [out :: arbiter.nullpointer.ca]
** [out :: arbiter.nullpointer.ca] $rvm_path (system_wide) does not exist.
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/scripts/rvm: line 154: __rvm_teardown: command not found
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/bin/rvm-shell: line 74: rvm: command not found
*** [err :: arbiter.nullpointer.ca] Error: RVM was unable to use 'default'
command finished
failed: "rvm_path=system_wide /usr/local/rvm/bin/rvm-shell 'default' -c \"mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids\"" on arbiter.nullpointer.ca
I just ran into this problem though my installation was complaining with:
out :: server]
** [out :: server] $rvm_path (/home/nebula/.rvm/) does not exist.
*** [err :: server] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
*** [err :: server] /usr/local/rvm/bin/rvm: line 52: /home/nebula/.rvm//scripts/rvm: No such file or directory
*** [err :: server] Error sourcing RVM!
*** [err :: server] Error: RVM was unable to use 'ruby-1.9.3-p392'
I am using rvm with a system wide install, (standard install to /usr/local/rvm). Adding the following to my Capfile solved the issue:
set :rvm_type, :system
set :rvm_path, "/usr/local/rvm"
The Error shows: RVM was unable to use 'default' gemset. Means RVM can't find a gemset named 'default' to use. Check the following line in your deploy.rb
set :rvm_ruby_string, 'gemset-name-here' => put a valid gemset here
Related
I ma trying to add Whenever gem to my Rails project, I added the gem to the Gemfile
gem "whenever", "~> 0.8.4"
and it was installed without any problems.
Then I added a simple task into the generated schedule.rb file:
set :output, "/home/my_deploy_name/project_name/current/log/cron_log.log"
every 2.minutes do
command "/usr/bin/some_great_command"
runner "MyModel.some_method"
rake "some:great:rake:task"
puts "It's working !!!"
end
and then I added following to the deploy.rb file:
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
namespace :deploy do
desc "Update the crontab file"
task :update_crontab, :roles => :db do
run "cd #{latest_release} && whenever --update-crontab #{application}"
end
end
I've tried to set up latest_release, current_path and release_path, but in all cases always the same output:
*** [err :: IP] sh: 1:
*** [err :: IP] whenever: not found
*** [err :: IP]
...
*** [err :: 54.221.241.111] /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
*** [err :: IP] :
*** [err :: IP] whenever is not part of the bundle. Add it to Gemfile.
*** [err :: IP] (
*** [err :: IP] Gem::LoadError
*** [err :: IP] )
*** [err :: IP] from /home/my_deploy_name/project_name/shared/bundle/ruby/2.0.0/bin/whenever:22:in `<main>'
How to fix this issue?
(I am deploying to Amazon EC2 - ubuntu)
Thanks
"Whenever" I ran into this problem...
Just kidding. Actually this has to do with capistrano, not whenever. You are calling the whenever command in the deploy.rb without the bundle context.
run "cd #{latest_release} && whenever --update-crontab #{application}"
try this:
run "cd #{latest_release} && bundle exec whenever --update-crontab #{application}"
I am in the process of deploying a rails application to a server. There are a few environmental limitations, namely:
No internet access on server
No root access on server
No build tools (GCC, etc)
I almost have the capistrano deployment working, however I get a failure when bundler tries to install the json gem:
** [out :: 192.168.7.115] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
** [out :: 192.168.7.115]
** [out :: 192.168.7.115] /app/ruby/bin/ruby extconf.rb
** [out :: 192.168.7.115] creating Makefile
** [out :: 192.168.7.115]
** [out :: 192.168.7.115] make
** [out :: 192.168.7.115] compiling generator.c
** [out :: 192.168.7.115] make: gcc: Command not found
** [out :: 192.168.7.115] make: *** [generator.o] Error 127
Since there is no internet, I have all of my gems stored in vendor/cache. I wanted to solve this problem by compiling the json gem on a similar machine that does have gcc, but I wasn't able to find a "compiled-looking" gem on the system. Normally, I see a [gemname]-x86_64-linux.gem gemfile that indicates the compilation has already been taken care of. Can't seem to find this for the JSON gem, but if I did, I'm guessing I could just drop it in my vendor/cache folder and call it a day.
Any suggestions? Am I approaching this problem correctly?
I can't recommend this method as it's likely a bad thing on many levels, but it did solve my problem. I ended up copying the shared/bundle folder from the staging server to the production server. Bundler sees that the gems are already installed and doesn't try to reinstall them.
I had a rails app that's was running on heroku, I recently got my VPS and trying to move it to my own server.
So, I deleted my heroku, and added an origin.
I did all the setups for deploy.rb(all looks fine)
but when I run cap deploy:setup, I got:
* 2012-11-24 20:35:21 executing `deploy:setup'
* executing "mkdir -p /var/www/sites/phil88530.com /var/www/sites/phil88530.com/releases /var/www/sites/phil88530.com/shared /var/www/sites/phil88530.com/shared/system /var/www/sites/phil88530.com/shared/log /var/www/sites/phil88530.com/shared/pids"
servers: ["phil88530.com"]
[phil88530.com] executing command
*** [err :: phil88530.com]
*** [err :: phil88530.com] ! Invalid path.
*** [err :: phil88530.com]
*** [err :: phil88530.com] ! Syntax is: git#heroku.com:<app>.git where <app> is your app's name.
command finished in 956ms
I don't want heroku exist anymore, why does it ask for heroku?
And I don't understand the invalid path as well, would be nice if I capistrano can get me more informatinos.
http://phil88530.com/ resolves to heroku... so when capistrano connects to servers: ["phil88530.com"], it's connecting to heroku.
You can either set the server to the IP address of your new VPS, or move the DNS over to the new VPS to correct the problem.
Deploying an app first time with Capistrano, but having problem running the cap deploy:update task on Rails 3.1.3, Capistrano 2.9.0, RVM 1.8.6 and Ubuntu server 10.10. Should not be a permissions issue as far as I can see. Been banging my head against this now for a while, thankful for any directions.
drphil#mumindalen:~/Rails/testapp$ cap deploy:update
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote git#my_server:~/testapp/ HEAD"
git#23.23.23.23.'s password:
command finished in 8892ms
* executing "git clone -q git#my_server:~/testapp/ /home/deploy/testapp/releases/20111211183654 && cd /home/deploy/testapp/releases/20111211183654 && git checkout -q -b deploy f473e207b15d73d2fa9aa32ab1dbeec98471153d && (echo f473e207b15d73d2fa9aa32ab1dbeec98471153d > /home/deploy/testapp/releases/20111211183654/REVISION)"
servers: ["my_server"]
Password:
[my_server] executing command
command finished in 1695ms
* executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* executing `deploy:assets:symlink'
* executing "rm -rf /home/deploy/testapp/releases/20111211183654/public/assets &&\\\n mkdir -p /home/deploy/testapp/releases/20111211183654/public &&\\\n mkdir -p /home/deploy/testapp/shared/assets &&\\\n ln -s /home/deploy/testapp/shared/assets /home/deploy/testapp/releases/20111211183654/public/assets"
servers: ["my_server"]
[my_server] executing command
command finished in 1117ms
* executing "chmod -R g+w /home/deploy/testapp/releases/20111211183654"
servers: ["my_server"]
[my_server] executing command
command finished in 614ms
* executing "rm -rf /home/deploy/testapp/releases/20111211183654/log /home/deploy/testapp/releases/20111211183654/public/system /home/deploy/testapp/releases/20111211183654/tmp/pids &&\\\n mkdir -p /home/deploy/testapp/releases/20111211183654/public &&\\\n mkdir -p /home/deploy/testapp/releases/20111211183654/tmp &&\\\n ln -s /home/deploy/testapp/shared/log /home/deploy/testapp/releases/20111211183654/log &&\\\n ln -s /home/deploy/testapp/shared/system /home/deploy/testapp/releases/20111211183654/public/system &&\\\n ln -s /home/deploy/testapp/shared/pids /home/deploy/testapp/releases/20111211183654/tmp/pids"
servers: ["my_server"]
[my_server] executing command
command finished in 1022ms
* executing "find /home/deploy/testapp/releases/20111211183654/public/images /home/deploy/testapp/releases/20111211183654/public/stylesheets /home/deploy/testapp/releases/20111211183654/pu## Heading ##blic/javascripts -exec touch -t 201112111837.12 {} ';'; true"
servers: ["my_server"]
[my_server] executing command
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/images"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server]
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/stylesheets"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server]
*** [err :: my_server] find:
*** [err :: my_server] "/home/deploy/testapp/releases/20111211183654/public/javascripts"
*** [err :: my_server] : Filen eller katalogen finns inte
*** [err :: my_server]
command finished in 1024ms
triggering after callbacks for `deploy:update_code'
* executing `deploy:assets:precompile'
* executing "cd /home/deploy/testapp/releases/20111211183654 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["my_server"]
[my_server] executing command
*** [err :: my_server] sh:
*** [err :: my_server] rake: not found
*** [err :: my_server]
command finished in 1440ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deploy/testapp/releases/20111211183654; true"
servers: ["my_server"]
[my_server] executing command
command finished in 727ms
failed: "sh -c 'cd /home/deploy/testapp/releases/20111211183654 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on my_server
It was an issue with different versions of RVM on the development box and the server and that I had not set up deploy.rb properly to work with RVM. Been digging around for hours thinking it was some kind of bug. Oh well.
Got it working using this in deploy.rb:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.2-p290'
set :rvm_type, :user
It could't find rake binary.
If you are using RVM, make sure the user which you are deploying as is in rvm group.
Or, most likely (or in combination with the above), you have .bashrc / bashrc / profile environment disabled for non-interactive shells. Thus it doesn't load all configuration (set PATH etc.).
See http://lists.apple.com/archives/macos-x-server/2008/Jun/msg00251.html
Debian (/etc/bashrc):
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
...and so on.
The last line is the problem. It quits processing bashrc for non-interactive shells.
Look for something similar on your system.
UPDATE:
There is an overview of shell scripts that are processed on debian squeeze:
http://www.fam.tuwien.ac.at/~schamane/_/blog:110814_bash_shell_startup_files_in_debian_squeeze
I'm using a system wide Ruby install on my server, and trying to deploy to a RVM gemset (like rvm use 1.9.2#gemset_name)
When I run my Cap file, Cap pukes and says a Ruby is not installed.
However, in reality that Ruby is installed. (The deploying user is part of the rvm group and can rvm use on the command line manually.)
What might I be doing wrong?
Relevant parts of Capfile
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "bundler/capistrano"
require "rvm/capistrano"
require "erb"
set(:rvm_type) { :system }
set(:ruby_version) { '1.9.2' }
set(:rvm_ruby_string) { "#{ruby_version}##{application}" }
set(:rvm_path) { "/usr/local/rvm" }
#set(:rvm_bin_path) { "#{rvm_path}/bin" }
before "deploy:setup", "rvm:debug_gemset"
before "deploy:setup", "bundle:install_gem"
namespace :rvm do
desc "Creates gemset for application"
task :debug_gemset do
disable_rvm_shell do
run "/usr/local/rvm/bin/rvm list rubies" do |ch, stream, data|
if stream == :err
logger.debug "capured output on STDERR: #{data}"
else # stream == :out
logger.debug "capured output on STDOUT: #{data}"
end
end
end
end
end
# We need this so that we can install rvm first!
def disable_rvm_shell(&block)
default_shell = self[:default_shell]
self[:default_shell] = nil
yield
self[:default_shell] = default_shell
end
Cap output
* executing `deploy:setup'
triggering before callbacks for `deploy:setup'
* executing `rvm:debug_gemset'
* executing "/usr/local/rvm/bin/rvm list rubies" # <----- ran outside of rvm-shell
servers: ["XX.XXX.XXX.XXX"]
Password:
[XX.XXX.XXX.XXX] executing command
* capured output on STDOUT:
* capured output on STDOUT: rvm rubies
* capured output on STDOUT:
* ruby-1.8.7-p352 [ x86_64 ]
* capured output on STDOUT:
* ree-1.8.7-2011.03 [ x86_64 ]
* capured output on STDOUT:
* ruby-1.9.2-p290 [ x86_64 ]
*
Ok, awesome: 1.9.2 is installed. (This is to be expected - I installed 1.8.7, REE and 1.9.2 manually!)
But that's not all Capistrano says...
command finished
* executing `bundle:install_gem'
* executing "gem install bundler"
servers: ["XX.XXX.XXX.XXX"]
[XX.XXX.XXX.XXX] executing command
** [out ::XX.XXX.XXX.XXX] WARN: ruby ruby-1.9.2-p290 is not installed.
That last line claims that 1.9.2 not installed?!!
** [out ::XX.XXX.XXX.XXX] To install do: 'rvm install ruby-1.9.2-p290'
*** [err ::XX.XXX.XXX.XXX] ERROR: Gemset 'MY_APP' does not exist, rvm gemset create 'MY_APP' first.
*** [err ::XX.XXX.XXX.XXX] Error: RVM was unable to use '1.9.2#MY_APP'
command finished
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2#MY_APP' -c 'gem install bundler'" on XX.XXX.XXX.XXX
Debugging with cap shell
Jim Gay asks, "what about debugging with cap shell?"
rvm/capinstrano runs commands through rvm-shell, which immediately goes looking for the version and gemset essentially before the command can be executed. (Thus the disable_rvm_shell defined earlier that we used for doing the initial rvm list rubies.
For example:
cap> which rvm
[establishing connection(s) to XX.XXX.XXX.XX]
Password:
** [out :: XX.XXX.XXX.XX] WARN: ruby ruby-1.9.2-p290 is not installed.
** [out :: XX.XXX.XXX.XX] To install do: 'rvm install ruby-1.9.2-p290'
*** [err :: XX.XXX.XXX.XX] ERROR: Gemset 'MY_APP' does not exist, rvm gemset create 'MY_APP' first.
*** [err :: XX.XXX.XXX.XX] Error: RVM was unable to use '1.9.2#MY_APP'
error: failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2#MY_APP' -c 'which rvm'" on XX.XXX.XXX.XX
Conclusion
I'm obviously doing something wrong, but what?
Setting 1.9.2 to be the default Ruby is not an option, as I'm also going to host a 1.8.7 app on this box (ideally). This is why I'm using RVM at the system level to begin with).
I also made sure that the deploy user is in the RVM group, per the RVM documentation.
This WARN about not installed ruby is a misleading msg, it should say could not find ruby#gemset pair. If you would use this command on server:
rvm use 1.9.2#MY_APP
You would see the messages in reverse order - first error that the gemset can not be found, to solve it please go to server and run:
rvm --create use 1.9.2#MY_APP
Which will create a gemset for you, if you need any more help with it please contact IRC channel #rvm on FreeNode servers.
ok, so i just had this bomb with a patch version of ruby different.
server was running: ruby-1.8.7-p371
and the deploy (cap / rvm-capistrano, not sure which exactly) wanted rvm install ruby-1.8.7-p374.
I tried the gemset suggestion in #mpapis which was progress, but it was then that i noticed it asked me to p374.
so if in doubt, install the latest minor version of ruby.