When I try to deploy my application with capistrano it stucks after the command:
~/.rvm/bin/rvm default do ruby --version
This is how the console print looks like:
root#srv:/var/www/project# cap staging deploy
(in /var/www/project)
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
system
Nothing happens after this. It worked fine for a long time but since I've started bundle install (or maybe someone else changed anyhting) the deployment doesn't work anymore. Here's an excerpt of the log file:
INFO ---------------------------------------------------------------------------
INFO START 2021-02-11 13:39:04 +0100 cap staging deploy
INFO ---------------------------------------------------------------------------
DEBUG [08de3cd7] Running ~/.rvm/bin/rvm version as deploy#x.xxx.xx.xx
DEBUG [08de3cd7] Command: ~/.rvm/bin/rvm version
DEBUG [08de3cd7] rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
DEBUG [08de3cd7]
DEBUG [08de3cd7] Finished in 0.773 seconds with exit status 0 (successful).
DEBUG [17018c10] Running ~/.rvm/bin/rvm current as deploy#x.xxx.xx.xx
DEBUG [17018c10] Command: ~/.rvm/bin/rvm current
DEBUG [17018c10] system
DEBUG [17018c10]
DEBUG [17018c10] Finished in 0.303 seconds with exit status 0 (successful).
DEBUG [41115234] Running ~/.rvm/bin/rvm default do ruby --version as deploy#x.xxx.xx.xx
DEBUG [41115234] Command: ~/.rvm/bin/rvm default do ruby --version
As you can see I am using rvm 1.29.12 with ruby 2.5.1p5. Maybe someone had the same problem or can give me a hint what to do. I have been searching for a solution since hours...
Please try to check your setup first using the below command and check what the error is
cap staging deploy:check
Related
I have a rails 5 app. I was trying to hunt down a memory leak and it opened up a can of worms. One of the worms is rvm and deploy. I do not have
rvm_ruby_string
set anywhere in the project. If I go to the directory of the project, and do either
bundle exec ruby --version
or
ruby --version
both result in
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
However, if I do
cap staging deploy
you can see it somehow picks up the wrong version:
DEBUG [778e15cb] Running /usr/bin/env which passenger as deploy#xxxx
DEBUG [778e15cb] Command: /usr/bin/env which passenger
DEBUG [778e15cb] /usr/bin/passenger
DEBUG [778e15cb] Finished in 0.710 seconds with exit status 0 (successful).
DEBUG [0da5c891] Running [ -d ~/.rvm ] as xxx
DEBUG [0da5c891] Command: [ -d ~/.rvm ]
DEBUG [0da5c891] Finished in 0.101 seconds with exit status 0 (successful).
DEBUG [f2734c3e] Running ~/.rvm/bin/rvm version as
xxx
DEBUG [f2734c3e] Command: ~/.rvm/bin/rvm version
DEBUG [f2734c3e] rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski,
Wayne E.
Seguin [https://rvm.io/]
DEBUG [f2734c3e] Finished in 0.268 seconds with exit status 0 (successful).
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin
[https://rvm.io/]
DEBUG [a2e3d82a] Running ~/.rvm/bin/rvm current as xx
DEBUG [a2e3d82a] Command: ~/.rvm/bin/rvm current
DEBUG [a2e3d82a] ruby-2.5.0
Now if I simply try to mimic what capistrano says it's doing, by copying and pasting the following to the command line:
~/.rvm/bin/rvm current
I get
ruby-2.3.1
So, I'm stumped. Where is Capistrano pulling the rvm var from?
You are probably running cap staging deploy as a different user then when you ran ruby --version.
Based on the capistrano output, you are using deploy user to deploy. If this is the case, you need to install ruby 2.3.1 as deploy user, and set 2.3.1 to "default and current".
You can test this by running ruby --version as both deploy user and the other user you used to run it the first time.
I'm trying to install Sunspot in a small Rails app, exactly following the gem setup instructions, but every time I run into RSolr::Error::Http: RSolr::Error::Http - 404 Not Found errors when I try to index data. I can reproduce this with a fresh app; here are the exact steps I follow:
Create a fresh Rails 4.2.5 app:
$ rails new test_sunspot
$ cd test_sunspot/
$ spring stop # spring can cause `generate` commands to hang
$ rails g model Thing title:string
$ rake db:migrate
$ rails c
> Thing.create!(title: "Cats")
> Thing.create!(title: "Pizza")
> exit
Add a Sunspot index to the model:
class Thing < ActiveRecord::Base
searchable do
text :title
end
end
Add Sunspot to Gemfile:
...
gem 'sunspot_rails', '2.2.2'
gem 'sunspot_solr', '2.2.2'
...
Install, start, and reindex Sunspot:
$ bundle install
$ rails g sunspot_rails:install # default sunspot.yml is not changed
$ ps aux | grep solr # confirm that no Solr services are running
$ bundle exec rake sunspot:solr:start # generates solr/ dir; no errors
$ bundle exec rake sunspot:solr:reindex
This reindex command yields the following output. When I go into the Rails console and tried to create a new Thing object, it triggers the same error (because Sunspot attempts to update the index):
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error: Not Found
URI: http://localhost:8982/solr/development/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Thing</query></delete>"
Backtrace: /Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
# ...lots of backtrace omitted...
/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'
/Users/topher/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
/Users/topher/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
(See full trace by running task with --trace)
The output of ps aux | grep solr (after starting Solr): Note that the PID mentioned in solr/pids/development/sunspot-solr-development.pid is 62449, which matches the third line:
topher 62617 0.0 0.0 2432772 520 s002 R+ 3:00PM 0:00.00 grep solr
topher 62484 0.0 1.3 3274624 105756 ?? S 2:57PM 0:03.65 /usr/bin/java -server -Xss256k -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_solr-2.2.2/solr/server/logs/solr_gc.log -DSTOP.PORT=7982 -DSTOP.KEY=solrrocks -Djetty.port=8982 -Dsolr.solr.home=/Users/topher/Sites/john_kole/test_sunspot/solr -Dsolr.install.dir=/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_solr-2.2.2/solr -Duser.timezone=UTC -Djava.net.preferIPv4Stack=true -jar start.jar
topher 62449 0.0 0.0 2444632 1304 ?? Ss 2:57PM 0:00.04 bash ./solr start -f -p 8982 -s /Users/topher/Sites/john_kole/test_sunspot/solr
Other details:
I'm on Mac OSX Yosemite
I've uninstalled and reinstalled the relevant gems, tried downgrading to Sunspot 1.3.0, and even ran gem pristine --all, with no change in outcome
EDIT: I have read through the other similar tickets on Sunspot/Solr 404 Not Found errors. It looks like the solutions in those cases amounted to "resetting" the Solr config and aren't relevant to a fresh (dev environment) project: no prior Solr instances are running before I run rake sunspot:solr:start; this is a completely fresh Rails project so the solr/ directory was just newly generated anyway; this is in development, not production; and adding solr_home: solr to sunspot.yml or updating path: /solr/default have no effect on the 404 outcome.
Questions:
Any idea why this is happening?
Could this breakage be due to something mis-installed in my OSX environment? What should I look at?
Can you get Sunspot working properly on a fresh install of current Rails, following these same steps?
Thanks in advance!
Remove the sunspot_solr gem and the install solr on your machine by the following commands
brew install solr
if it doesn't work run brew update first to fetch the latest solr links
brew will install all missing dependencies automatically.
To start solr:
solr start
TL;DR: You have done everything right, but the user installing the gems is not the same as the one running solr (aka permissions issue)
I tried to reproduce your case and succeeded, which felt very wrong. The issue is that installing the gem sunspot_solr ships an embedded Java webserver Jetty. I managed to trace the cause of the problem to the fact that this webserver is not run as the person who installed it.
This can be verified by installing gems per:
$ touch Gemfile # to mark it as edited
$ bundle install --path vendor/bundle # to install as user who runs the server later
instead of the usual
$ gem install ... bundle install
as another (possibly root) user.
Now you can succeed performing all your steps as mentioned in your post.
When I used linux everything deploy work, but when I deploy from mac os, I have:
> cap production deploy
DEBUG [1330f96c] Running /usr/bin/env [ -d ~/.rvm ] on IP Adress
DEBUG [1330f96c] Command: [ -d ~/.rvm ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
user_name#ip_adress's password:
When I wrote password, I get
> DEBUG [de2b7c18] Finished in 4.376 seconds with exit status 0 (successful).
DEBUG [1ca89b99] Running ~/.rvm/bin/rvm version on ip address
DEBUG [1ca89b99] Command: ~/.rvm/bin/rvm version
DEBUG [1ca89b99] rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1ca89b99]
DEBUG [1ca89b99] Finished in 1.130 seconds with exit status 0 (successful).
rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1c973067] Running ~/.rvm/bin/rvm current on ip address
DEBUG [1c973067] Command: ~/.rvm/bin/rvm current
DEBUG [1c973067] ruby-2.2.0
DEBUG [1c973067]
DEBUG [1c973067] Finished in 2.110 seconds with exit status 0 (successful).
ruby-2.2.0
DEBUG [848d3c3e] Running ~/.rvm/bin/rvm default do ruby --version on ip address
DEBUG [848d3c3e] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [848d3c3e] ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
DEBUG [848d3c3e]
DEBUG [848d3c3e] Finished in 1.050 seconds with exit status 0 (successful).
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
INFO [8dbfa807] Running /usr/bin/env mkdir -p /tmp/project/ on ip address
DEBUG [8dbfa807] Command: /usr/bin/env mkdir -p /tmp/project/
INFO [8dbfa807] Finished in 0.381 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/project/git-ssh.sh 0.0%
INFO Uploading /tmp/project/git-ssh.sh 100.0%
INFO [0f9c9d2a] Running /usr/bin/env chmod +x /tmp/project/git-ssh.sh on ip address
DEBUG [0f9c9d2a] Command: /usr/bin/env chmod +x /tmp/project/git-ssh.sh
INFO [0f9c9d2a] Finished in 1.417 seconds with exit status 0 (successful).
INFO [5dfc2373] Running /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git on ip address
DEBUG [5dfc2373] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/project/git-ssh.sh /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git )
DEBUG [5dfc2373] Enter passphrase for key '/home/nick_name/.ssh/id_rsa':
I install gem HighLine.
Please help me with this problem?
You could try using a key with no password, or make sure that if your user password and the key's passphrase are different that you are using the correct one. The first prompt is for your user account, user_name#ip_adress, and the second is for the passphrase assigned to /home/nick_name/.ssh/id_rsa.
I'm trying to use capistrano 3.0 to fully manage my deploy, from bundle install to precompile. However, I keep running into a problem where "RAILS_ENV=production rake assets:precompile" can't seem to find the gems that bundler installed. Here's the output from capistrano:
DEBUG [8d404b6a] Finished in 1.289 seconds with exit status 0 (successful).
INFO [9eb1acdc] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test on 50.112.106.148
DEBUG [9eb1acdc] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test
DEBUG [9eb1acdc] Your bundle is complete!
DEBUG [9eb1acdc] Gems in the groups development and test were not installed.
DEBUG [9eb1acdc] It was installed into /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global
INFO [9eb1acdc] Finished in 2.892 seconds with exit status 0 (successful).
DEBUG [0de28eb8] Running if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi on 50.112.106.148
DEBUG [0de28eb8] Command: if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi
DEBUG [0de28eb8] Finished in 1.506 seconds with exit status 0 (successful).
INFO [cb071501] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile on 50.112.106.148
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
DEBUG [cb071501] /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [cb071501] :
DEBUG [cb071501] Could not find hashr-0.0.22 in any of the sources
DEBUG [cb071501] (
Here is my staging.rb (I'm using "cap staging deploy"):
set :stage, :staging
set :rails_env, "production"
set :user, "ec2-user"
role :app, %w{50.112.106.148}
role :web, %w{50.112.106.148}
role :db, %w{50.112.106.148}
server '50.112.106.148', user: 'ec2-user', roles: %w{web app}
And here is my deploy.rb:
set :application, 'FingertipRails'
set :repo_url, 'git#github.com:dresources/FingertipRails.git'
set :branch, "master"
set :rvm_type, :user
set :bundle_cmd, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle"
set :bundle_dir, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
set :bundle_flags, '--deployment'
Any ideas?
Thank you
EDIT
Here is the output of rvm info on the server:
ruby-2.0.0-p247:
system:
uname: "Linux ip-10-226-137-104 3.4.62-53.42.amzn1.x86_64 #1 SMP Fri Sep 20 07:23:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
system: "amazon/2013.09/x86_64"
bash: "/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.23.8 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "1 month 10 days 44 minutes 13 seconds ago"
path: "/home/ec2-user/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p247"
date: "2013-06-27"
platform: "x86_64-linux"
patchlevel: "2013-06-27 revision 41674"
full_version: "ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]"
homes:
gem: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
binaries:
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
irb: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/irb"
gem: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/gem"
rake: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/rake"
environment:
PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin:/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin"
GEM_HOME: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
GEM_PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
MY_RUBY_HOME: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
IRBRC: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/.irbrc"
RUBYOPT: ""
gemset: ""
In your Capistrano task, try adding the bundle_cmd variable you've set in your config so that rake assets:precompile runs with bundle exec. Without seeing what other variables you have in your deploy.rb, you'll want to get this line:
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
... to look more like this:
cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 bundle exec rake assets:precompile )
I'm deploying to a VPS using capistrano, based on the guide at RailsCasts.
http://railscasts.com/episodes/335-deploying-to-a-vps?view=asciicast
It's failing on the deploy:cold command, with a conflict with Ruby. I actually can't see what the problem is, as when I shell into the same user the Ruby version looks correct.
$ cap shell
cap> which ruby
[establishing connection(s) to 192.xxx.xxx.xxx]
** [out :: 192.xxx.xxx.xxx] /home/deployer/.rbenv/shims/ruby
cap> ruby -v
** [out :: 192.xxx.xxx.xxx ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
This is the error:
command finished in 655ms
* 2013-07-01 16:40:39 executing `bundle:install'
* executing "cd /home/deployer/rails/assay/releases/20130701144038 && bundle install -- gemfile /home/deployer/rails/assay/releases/20130701144038/Gemfile --path /home/deployer/rails/assay/shared/bundle --deployment --quiet --without development test"
servers: ["192.xxx.xxx.xxx"]
[192.xxx.xxx.xxx] executing command
** [out :: 192.xxx.xxx.xxx] rbenv: version `1.9.3' is not installed
command finished in 662ms
*** [deploy:update_code] rolling back
My question is: how can I debug this? When I read the deploy.rb file I can't see where it even references the Ruby version. Pretty frustrating, I am about ready to ftp the repo up, which is not ideal obviously.
Well I finally got to the bottom of the issue - a mismatch between ruby versions use by Capistrano and what was actually on the server.
To debug Capistrano run it like this:
cap deploy:cold -d
That was you can step through the commands and access the temporary directories on the remote server before they are deleted.
I just had similar issue, the reason was .ruby-version file pointing at 1.9.3 (file was generated by rails-composer), while there was 1.9.3-p392 installed via rbenv on remote machine.
Debug info of capistrano can be shown by tail -f log/capistrano.log.