RVM & Unicorn deploy - ruby-on-rails-3

My RVM is installed as root.
When I'm trying to start unicorn socket, it prints
user#9001-3:~$ /etc/init.d/unicorn start
Starting myapp app: /usr/bin/env: ruby: No such file or directory
unicorn.
But if I type
user#9001-3:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/unicorn path exists.
My unicorn config: https://gist.github.com/1010519

/etc/init.d/unicorn doesn't know where to find Ruby because it's managed via RVM. Normally, your .bashrc or similar file is executed and sets up the environment; this doesn't happen in init scripts (or likely anything else executed by root).
The solution is to use wrappers. For example, to create a binary called system_ruby that loads up RVM's 1.9.2p180 environment and then executes ruby, execute the following:
rvm wrapper ruby-1.9.2-p180 system ruby
For more information and more details, check out this answer of mine, which addresses a similar problem.

Symlink also works,
which ruby<your version>
ln-s /ruby/path/ruby<your version> /ruby/path/ruby

Type :
which ruby (show the ruby bin path) then type this : ln -s (change_to_ruby_path) /usr/bin/env/ruby (construct the correct access for your system)

I had the same problem and this for me
rvm --default use <version>

Related

system("rvm 2.5.3 do ruby -v") leads to Warning! PATH is not properly set up

Before marking this as duplicate let me explain:
When running rvm 2.5.3 do ruby -v, everything works well:
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17]
e.g. ruby -v gives ruby 2.7.0dev (2019-03-18 trunk 67296) [x86_64-darwin17]
But when running ruby -e "system('rvm 2.5.3 do ruby -v')" I get the big old Warning! PATH is not properly set up message (even though it executes correctly).
Solution was to add set -gx PATH $HOME/.rvm/bin $PATH to my ~/.config/fish/config.fish.
Hope it helps others.

Passenger module fails to install

On Mac OSX 10.8.4, I'm running:
sudo passenger-install-apache2-module
which suggested:
Your RVM wrapper scripts are too old, or some wrapper scripts are missing. Please update/regenerate them first by running:
rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all
If that doesn't seem to work, please run:
rvmsudo rvm wrapper [] --no-prefix --all
I did the first bit, re-ran the passenger-install-apache2-module but got the same problem. Then I did the second part. This gave:
awk: nonterminated character class ^[]=
source line number 1
context is
>>> /^[]=/ <<<
sed: 1: "s#^[]=##
": unbalanced brackets ([])
Unknown ruby interpreter string component: '[]'.
Could not load ruby [].
Any suggestions on where I go from here?
just run passenger-install-apache2-module do not prefix it with sudo.
the command will tell you what to do if it has no write access into required locations.
using sudo losses all environment variables - which basically breaks what rvm set up.
if you would really need root privileges you should use rvmsudo which does preserve all required environment variables.

No .rvm directory after installing rvm

I don't have a ~/.rvm file even after I upgrade my version of RVM using:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
This command produces the following. How can I make sure a .rvm folder is created?
Upgrading the RVM installation in /opt/t/rvm/
chown: rvm: illegal group name
chown: rvm: illegal group name
RVM PATH line found in /Users/ros/.bashrc /Users/roseperrone/.zshrc.
RVM sourcing line found in /Users/ros/.bash_profile /Users/roseperrone/.zprofile.
Upgrade Notes:
* No new notes to display.
# RVM: Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
# In case of any issues run 'rvm requirements' or read 'rvm notes'
Upgrade of RVM in /opt/t/rvm/ is complete.
You don't have a ~/.rvm, because you installed rvm to /opt/t/rvm/.
You may either just live with that and use /opt/t/rvm/ instead of ~/.rvm. Or remove rvm completely and make a new install (which should then default to ~/.rvm).

RVM not changing loaded ruby

I have an .rvmrc file:
rvm use 1.9.3-p286#refinery --create
and changing to that folder yields:
Using /Users/neil/.rvm/gems/ruby-1.9.3-p286 with gemset refinery
$ ~/code/visioneng/ master* ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
$ ~/code/visioneng/ master*
However, this clearly isn't what I asked for. What gives?
check if you do not overwrite PATH in any of your shell scripts/functions/aliases

"uninitialized constant Encoding" using rvm, ruby 1.9.2, bundler and passenger

I am at wit's end here and am turning to you all for some help on this f*#$^ encoding issue.
I am running on a private server with root permissions on Dreamhost. Here is a bit about my environment and versions.
$ `which ruby` -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ `which bundle` -v
Bundler version 1.0.15
$ `which rails` -v
Rails 3.0.9
Aside from this error, my rails app runs fine without issue. However, when I try to change the encoding a string by using the encode method it:
NoMethodError: undefined method `encode' for "foobar":String
encode should be defined but it is not! Encoding is found if I try in irb:
$ irb
ruby-1.9.2-p180 :001 > Encoding
=> Encoding
ruby-1.9.2-p180 :002 > "foobar".encode('utf-8')
=> "foobar"
But if I try using the rails console through bundle exec, Encoding is not found:
$ bundle exec rails c staging
Loading staging environment (Rails 3.0.9)
ruby-1.9.2-p180 :001 > Encoding
NameError: uninitialized constant Encoding
from /[REDACTED]/shared/bundle/ruby/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from (irb):1
ruby-1.9.2-p180 :002 > "foobar".encode('utf-8')
NoMethodError: undefined method `encode' for "foobar":String
Obviously the setup is not loading something correctly but I am not sure where to look to figure it out. What am I missing here?
UPDATE 6/19/2011
As Ryan Bigg pointed out, it is curious that the directory path for the gems is 1.8. However, running bundle exec shows that bundler is using the correct ruby and rails versions:
$ bundle exec which ruby
/path/to/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
$ bundle exec `which ruby` -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ bundle exec which rails
/path/to/shared/bundle/ruby/1.8/bin/rails
$ bundle exec `which rails` -v
Rails 3.0.9
Clearly something is wonky here… I just don't know what.
UPDATE 6/26/2011
Seamus asked for the $LOAD_PATH…
UPDATE 6/26/2011 (later)
Seamus asked for the Gemfile.lock and the pp ENV… In the ENV output, I found that the GEM_PATH was not correct. In my staging.rb environment file, I have:
GEM_HOME = "/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#[REDACTED]"
GEM_PATH = "/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#[REDACTED]:/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#global"
…which is obviously not being honored. Nowhere else in my code is there a mention of GEM_HOME or GEM_PATH
UPDATE 6/27/2011
Seamus asked for the .bundle/config contents…
UPDATED same idea (that GEM_HOME is messed up), but more suggestions
Your GEM_HOME is messed up, possibly because your PATH is messed up. You could try setting the following environment variable in your shell
$ export PATH=[your current path but with rvm's ruby 1.9 at the front]
Then run
$ bundle install
If that doesn't work, try also setting this in your shell
$ export GEM_HOME=[your ruby 1.9 gem home]
and then re-run
$ bundle install
New ideas from this answer: Using RVM, bundler does not install in proper gemset when gems are installed in a different ruby version