RVM error with deploying Rails app via Capistrano - ruby-on-rails-3

History:
Read into Deploying Rails3 app to a
Mediatemple DV server.
Installed RVM on the server, ruby, and essential gems.
Site works fine if I FTP it up.
All good.
I then decided to do a proper deployment and setup for GIT/cap deploy as per "Agile Web Development with Rails".
Attempted deploy with cap, but had errors with gems not available to the production site.
Read around and realised I should probably go for a system wide RVM install.
Removed all gems and RVM.
Installed RVM system wide.
Error on cap deploy "bash: /home/foo/.rvm/bin/rvm-shell: No such file or directory", which makes sense - there is no .rvm/ in the home directory.
Thinking something was hanging over from initially installing RVM to use as a user, I removed the user, deleting the home directory, and recreated the user with permissions.
Same error on cap deploy "bash: /home/foo/.rvm/bin/rvm-shell: No such file or directory"
The situation now is:
For foo, .bashrc contains the last line:
[[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm'
When I issue:
type rvm | head -1
the response is "rvm is a function".
/etc/rvmrc contains
if [[ ! -s "$HOME/.rvm/scripts/rvm" ]]; then
umask g+w
export rvm_selfcontained=0
export rvm_prefix="/usr/local/"
fi
Running out of ideas here, and hoping for some suggestions.

Next time try to add this in your capistrano:
set :rvm_type, :system

It seems like rvm-shell is not in your rvm install directory. Run this command
rvm get head
Then you'll get it right in your rvm bin directory.

I just wanted to add to #imonyse's comment.
the head branch of rvm might be a tad too unstable for some deploys. I know our deprecated SLES boxes have a tendency to choke on it. It might be advisable to get the most recent stable version.
rvm get stable
Also don't do this on a really old server running production code as it may have undesired consequences.

Related

RubyMine, Vagrant, RVM

I'm on OS X host where I have RubyMine (7) and last Vagrant installed. I've prepared shell script for provision my vagrant box with RVM, ruby (2.1.2), bundle my project, run all tests, manually start server. Everything seems fine.
Now I want to make RubyMine works with RVM ruby from vagrant guest (run server, specs with debugging). I've added remote ruby SDK, point them to RVM ruby binary (http://prntscr.com/5i6g1f). But when I try to start development server, I've receive message that no rails installed in SDK. But it is installed via bundle, I can run server manually from guest.
Please, advice me how can I tell RubyMine where to find gems inside Vagrant with RVM?
Thanks :)
When using RVM, the path to remote SDK should not point to the binary but rather to the ruby gems directory.
In your case, for instance, the correct path should be:
/home/vagrant/.rvm/gems/ruby-2.1.2
Note that it should point to the DIRECTORY not the executable!
To find the directory simply run:
$ rvm gemdir
Then copy and paste the result.
change the path to ruby
from: /path/to/rvm/rubies/ruby-version/bin/ruby
to: /path/to/rvm/wrappers/ruby-version/ruby
Same problem if any rbenv user face then type "which ruby" without quotes in terminal it will point to the shims folder of rbenv but select versions folder and select irb instead of ruby as rubymine need irb (ruby interpreter) instead of ruby binary.

RVM is not a function in Raspbian RVM Installation

I'm looking for a solution to the "RVM is not a function" issue when installing RVM on Raspbian using LXTerminal. The following thread discusses workarounds for this issue:
rvm installation not working: "RVM is not a function"
One solution would be to start the terminal in "login mode" by doing /bin/bash --login, but this does not help on Raspbian because it uses LXTerminal. Other people have suggested putting the following line at the end of your .bash_rc file:
source ~/.rvm/scripts/rvm
...which seems to work. Just wondering if (a) the above workaround is legit and will not screw anything up and (b) if anybody has found a more elegant solution for RVM on Raspbian.
It looks like the best solution is to run it with:
lxterminal -e "bash -li"
It will make the terminal use an login and interactive shell.
I tried this but when in the root application directory for a ruby on rails application it stopped working, I added this 'source /usr/local/rvm/scripts/rvm' to my .bashrc file which worked in the /home/user/ folder and the root ruby on rails application folder

Gem installation error for non-root user

I did RVM single user installation on my CentOS server as root user, so rvm location is /usr/local.. However, now we have to use individual user accounts.
So now if I try to install a new gem, for instance -
gem install linecache19 -v '0.5.12'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/rvm/gems/ruby-1.9.2-p320#cams directory.
sudo gem install linecache19 -v '0.5.12'
/usr/local/rvm/rubies/ruby-1.9.2-p320/bin/gem:12:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p320/bin/gem:12
Point to note: I thought of re-installing the rubies and rvm with individual user account and do away with root installation. But I already have some apps running on the server as staging, so want to avoid this.
How can I solve these problems?
You obviously missed to read RVM installation documentation and overall RVM docs.
For part 1. you need to run rvmsudo rvm get stable and add your users to rvm group.
For part 2. do not use sudo it looses all environment settings - which leads to the error you see, either add your users to rvm group or run with rvmsudo.

git://github.com/ryanb/nested_form.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

I have deployed my application on linux server with passenger and apache, I have done bundle install run successfully still i get
( git://github.com/ryanb/nested_form.git (at master) is not checked out. Please run bundle install (Bundler::GitError) ) error while i try to run my application
FYI, i am using rails 3.2.3 and ruby 1.9.3
This works fine on my development machine
Any Idea ?
I have currently solved the issue by running below
bundle pack
bundle install --path vendor/cache
This solves my problem, but it stores whole gems in the vendor directory
But still if anybody have better solution then please let me know
I had the same problem, I always installed my gems as system-wide gems (including the ones from github).
$ sudo bundle install
When I ran rails, I got the same error:
$ rails s
http://github.com/Sija/garb.git (at master) is not checked out. Please run `bundle install`
So when I ran:
$ bundle install
This installed the gems from github locally, but otherwise used all the other system-wide gems.
Then when I ran rails again, it worked.
Are you running bundle install as root? If yes, try running bundle install without "sudo", anyway this seems to be a permissions problem (as Google suggests [google => (at master) is not checked out. Please run bundle install (Bundler::GitError)])1

Need help setting up passenger with RVM

I'm trying to setup passenger with rvm. I keep getting this error
Your RVM wrapper scripts are too old.
Please update them first by running
'rvm update --head && rvm reload &&
rvm repair all'.
I did that still same problem
GNU C++ compiler... found at /usr/bin/g++
Curl development headers with SSL support... found
OpenSSL development headers... found
Zlib development headers... found
Ruby development headers... found
OpenSSL support for Ruby... found
RubyGems... found
Your RVM wrapper scripts are too old.
Please update them first by running 'rvm update
--head && rvm reload && rvm repair all'.
I'm using Fedora 14, Ruby 1.9.2, Rails 3.0.7
RVM is installed for multiuser
I also get this error when I do 'passenger start'
Cannot execute
'/home/antarr/.passenger/standalone/3.0.7-x86_64-ruby1.9.2-linux-gcc4.5.1-1002/support/helper-scripts/prespawn
http://0.0.0.0:3000': Permission
denied (13)
I was having the same issue but found that using the rvmsudo command worked. Instead of
sudo passenger-install-apache2-module
try using:
rvmsudo passenger-install-apache2-module
It looks like Passenger 3.0.7 is confused by newer versions of rvm, but it seems like the instructions are incorrect and it's causing trouble. If the GEM_HOME environment variable is not set you get this error.
The correct instructions should be to use your particular version first:
rvm use 1.9.2
Although I got the same error as you, after that it worked for me.
If none of the above solutions work for you and you're getting the GEM_HOME warning
delete everything in .rvmrc
rvm get head && rvm reload && rvm repair all
gem install passenger
passenger-install-apache2-module
copy/paste the end message into your apache.conf
I am still having the same issue with passenger 3.0.19 if I tried to install on gemsets other than default and global. This is soooo troublesome. I have tried many suggestions and even rvm implode, then have everything brand new. but still hitting the brick wall. my forehead almost flatten. Hope not to lose my head!
Luckily, I found myself a fix. I found out that in i am in rvm multiuser envrioment and the issue arised if I switch to user gemset using command: "rvm user gemsets" which basically will create and use .rvm folder in user's home folder. e.g.: /home/.rvm instead of /ur/local/rvm folder. Since I do not know how to switch back and could not find any documention on how to, I did the following steps:
remove .rvm folder in the user home folder,
rm -rf ~username/.rvm
added back the user to rvm group (in multi enviroment, every new user need to be added to rvm group)
sudo usermod -a -G rvm username
re-login.
Now, as long as I am using shared rvm gemset folder, phusion passenger wont complaint.
Hope that helps someone.
I fixed the Permission Denied issue with:
chmod a+x /Users/tvd/.passenger/standalone/3.0.7-x86_64-ruby1.9.2-macosx-10.6/support/helper-scripts/*
Found it in comment section on the phusion.nl blog:
Goto Comment on Phusion Blog