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
Undefined Method 'Email' for Nil:Nilclass in Exibe the Mail of Table Father
Regular Expression to Match Only the First File in a Rar File Set
Testing HTML5 File Upload with Capybara/Selenium Webdriver - Ruby
How to Build a Docker Image for a Ruby Project Without Build Tools
Errno::Enoent No Such File or Directory Rails 4
Ruby: Length of a Line of a File in Bytes
How to Count Duplicates Hash Itens in Ruby 1.8.5 ( Sketchup Ruby API )
Flatten a Ruby Array Without Using Built-In 'Flatten' Method
How to Create an Association Between Two Rails Models
Failing to Enable User-Env-Compile on Heroku
Can a Ruby Module Be Described as a Singleton Class
How to Emit Yaml in Ruby Expanding Aliases
How to Check If a Resource Exists in an Aws S3Bucket
How to Test Order-Conscious Equality of Hashes
Enforce File Upload Size on Heroku
Error: Error Installing JSON: Error: Failed to Build Gem Native Extension