Rvm | Running User Scripts

RVM | Running user scripts

rvm default do /path/to/ruby/script

Executable Ruby Scripts Using the Current Local User RVM Install?

If you do which ruby, you'll find that RVM's ruby does not lie at /usr/bin/ruby. Instead use:

#!/usr/bin/env ruby

This will tell it to look up which ruby to use in the current environment (essentially the $PATH).

You could also execute your script via ruby itself: ruby myscript.rb

Ruby RVM under another user from Bash script

You should use wrappers:

rvm wrapper ruby-1.9.3-p125 ext_1.9.3 bundle

This will create $rvm_path/bin/ext_1.9.3_bundle, so now you can use:

/full/path/to/rvm/bin/ext_1.9.3_bundle exec unicorn_rails -E production -D

replace /full/path/to/rvm with output from echo $rvm_path

RVM is not a function error when running in ruby script and irb

Try this trick:

%x{bash -c 'source "$HOME/.rvm/scripts/rvm"; rvm use @myapp'}

However, you really can use rvm as you've specified because even if you've set up the rvm you then lost your session because your terminal will be closed. Try to setup your environment with session gem, and control bash session with it.

require 'session'

@myapp = 'ruby-1.8.7-p374'

bash = Session::Bash.new

stdout, stderr = bash.execute 'source "$HOME/.rvm/scripts/rvm"'

stdout, stderr = bash.execute "rvm use #{@myapp}"
puts stdout

# => Using /home/malo/.rvm/gems/ruby-1.8.7-p374

ruby in linux: permanently source .rvm/scripts/rvm?

You need to add your

  source .rvm/scripts/rvm

into your $HOME/.bashrc file; read the advanced bash scripting guide for more.

Installing RVM as multi-user from a shell script

You have sudo on the wrong half of the command.

You need it on the bash half not the curl half.

You want a sudo-ed shell not a sudo-ed download.

curl -L https://get.rvm.io | sudo bash -s stable

RVM Command: source ~/.rvm/scripts/rvm

Put this in your ~/.profile or ~/.bashrc:

# This loads RVM into a shell session.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

So you don't have to manually type it for every session.

Installing RVM and gems on OSX from a single shell script

I found a solution after reading through another stack overflow post.

A comment to one of the answers suggested makeing sure the script runs with bash and not sh. That was my problem. After changing the top line of my script (which wasn't included in my example) from #!/bin/sh to #!/usr/bin/env bash, everything worked as expected.



Related Topics



Leave a reply



Submit