Error about ruby & rvm default version - ruby

on a CentOS 6.5 server, I installed ruby through rvm and set the ruby-2.0.0-p451 as default.
$ rvm --default ruby-2.0.0-p451
However, when I'm running script from Crontab
I got an error like
`require': no such file to load -- rubygems (LoadError)
so I checked ruby -v test.rb, it tells me that I'm using ruby 1.8.5 (2006-08-25) [x86_64-linux] not the default ruby-2.0.0-p451. And I also checked with /usr/bin/ruby.
$ /usr/bin/ruby -v
ruby 1.8.5 (2006-08-25) [x86_64-linux]
My question is how to use ruby-2.0.0-p451.
Thanks

It looks like, your path variable is not set correctly. It is generally defined in your ~/.profile, it should contain something like these 2 lines:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads R

I just simply changed the /usr/bin/ruby as a link to solve the problem as below:
mv /usr/bin/ruby /usr/bin/_ruby
ln -s /usr/local/rvm/rubies/ruby-2.0.0-p451/bin/ruby

Related

iTerm2 Setup as Login Shell, RVM Still Gives Error

I have been trying to install Ruby-2.6.1 on my Macbook Pro for a couple of days now, and I have followed many posts and blog posts to try to get the setup correct, but I am not successful. I always get the following when trying to set the default Ruby with RVM:
picklemac:~ jblanchard$ rvm use default ruby-2.6.1
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use /bin/bash --login as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
I have followed the link, but with no success. I have iTerm2 setup as a login shell:
In .bashrc I have the following:
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
And in .bash_profile I have the following:
# rvm
# export PATH="/Users/jblanchard/.rvm/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
As I said, I have read and tried a number of things to get iTerm2 and my Mac setup properly, including How to make zsh run as a login shell on Mac OS X (in iTerm)?. Also, because I am trying to upgrade from Ruby 2.3 I have read a number of posts on just how to do that - again with no success.
What am I doing wrong?
Additional Info
I am able to successfully list the installations using rvm list:
picklemac:~ jblanchard$ rvm list
ruby-2.6.0 [ x86_64 ]
=* ruby-2.6.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
This is interesting, because RVM indicates Ruby-2.6.1 is the default, but when I use ruby -v the return is:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
I was able to successfully make the change to Ruby-2.6.1. First, I uncommented the export line in .bash_profile:
# rvm
export PATH="/Users/jblanchard/.rvm/bin:$PATH" #UNCOMMENTED
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
After stopping and starting iTerm2 I issued the command to use Ruby-2.6.1 and received a warning, but then:
picklemac:~ jblanchard$ rvm use default ruby-2.6.1
Warning! PATH is not properly set up, /Users/jblanchard/.rvm/gems/ruby-2.6.1/bin is not at first place.
Usually this is caused by shell initialization files. Search for PATH=... entries.
You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
To fix it temporarily in this shell session run: rvm use ruby-2.6.1
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
Using /Users/jblanchard/.rvm/gems/ruby-2.6.1
The change to Ruby-2.6.1 was made. It appears I do need to run rvm get stable --auto-dotfiles to fix the warning, which I would prefer to silencing it. Now, when running ruby -v the return is:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

RVM PATH is not properly set up

I've recently run into the following error from rvm when trying to upgrade my ruby version.
Warning! PATH is not properly set up, '/home/sam/.rvm/gems/ruby-2.2.1/bin' is not at first place,
My echo $PATH is as follows:
/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1#global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin
My .bashrc has the following lines in it
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
And .bash_profile has:
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
And my rvm info is as follows
Warning! PATH is not properly set up, '/home/sam/.rvm/gems/ruby-2.2.1/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.2.1'.
ruby-2.2.1:
system:
uname: "Linux bitey0asus 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"
system: "ubuntu/14.04/x86_64"
bash: "/bin/bash => GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "10 minutes 55 seconds ago"
path: "/home/sam/.rvm"
ruby:
interpreter: "ruby"
version: "2.2.1p85"
date: "2015-02-26"
platform: "x86_64-linux"
patchlevel: "2015-02-26 revision 49769"
full_version: "ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]"
homes:
gem: "/home/sam/.rvm/gems/ruby-2.2.1"
ruby: "/home/sam/.rvm/rubies/ruby-2.2.1"
binaries:
ruby: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/ruby"
irb: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/irb"
gem: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/gem"
rake: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/rake"
environment:
PATH: "/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1#global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin"
GEM_HOME: "/home/sam/.rvm/gems/ruby-2.2.1"
GEM_PATH: "/home/sam/.rvm/gems/ruby-2.2.1:/home/sam/.rvm/gems/ruby-2.2.1#global"
MY_RUBY_HOME: "/home/sam/.rvm/rubies/ruby-2.2.1"
IRBRC: "/home/sam/.rvm/rubies/ruby-2.2.1/.irbrc"
RUBYOPT: ""
gemset: ""
I found a solution to a similar problem here. But apparently not close enough (the proposed solution had no effect).
Anyway if anyone has any ideas, I'd appreciate it. I'm a little clueless on the ins and outs of rvm so I'm a bit in the dark here. Thanks in advance
Edit:
I tried reversing the order of the two rvm lines in my .bashrc but this did not help the error, nor did it change the order shown by echo $PATH.
Your PATH does not start with /home/sam/.rvm/gems/ruby-2.2.1/bin because you have a line prepending the Heroku toolbelt path.
You can check this is true by running this in your terminal:
PATH=/home/sam/.rvm/gems/ruby-2.2.1/bin:$PATH rvm info
It shouldn't complain.
The problem comes from Heroku toolbelt modifiying your env in ways rvm doesn't care for.
As per this post, the fix is to change your .bashrc like so:
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
You can remove the rvm line from .bash_profile
To solve it I just changed in my .profile file:
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
to
PATH="$PATH:$HOME/bin:$HOME/.local/bin"

RVM / ZSH - Always shows "Upgraded http://rubygems.org/ to HTTPS" when gem installing

I'm curious why it keeps showing this message any not doing anything about it. Is m RVM is setup incorrectly?
I'm using zsh and have [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* in my .zprofile
check this files:
~/.gemrc
/etc/gemrc
it has nothing to do with rvm

How to load rvm with correct gemset then execute a rake task

Writing a script that cds into another dir, loads the correct rvm rvmrc file, then allows me to execute a rake task.
I have the below script working on my computer, but when others pull it down to their machine they get the following error "Ruby rvmrc is not installed".
Bundler.with_clean_env do
Dir.chdir("../some_dir") do
puts `source ~/.rvm/scripts/rvm && rvm --with-rubies rvmrc exec -- rake some_task`
end
end
I have the most up to date version of rvm (so do they) and I'm on mt.lion
I have tried creating a bash function like so...
function foo {
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" && rvm use #my_gemset
}
Or, replacing this line
rvm --with-rubies rvmrc exec
with things like...
rvm rvmrc load
rvm use <gemset>
rvm env --path -- ree-1.8.7#some_gemset
But none of it has worked. Thanks for the help
this should work:
~/.rvm/bin/rvm rvmrc trust ../some_dir
~/.rvm/bin/rvm in ../some_dir do rake some_task

RVM system-wide install script url broken -- what is replacement?

My RVM system-wide installation scripts are broken, both in the form of Linode StackScripts and Chef-solo Recipes.
Per the instructions on the RVM website, my scripts execute the following commands as root to install RVM on a system-wide basis:
echo "Installing RVM system-wide" >> $logfile
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
cat >> /etc/profile <<'EOF'
# Load RVM if it is installed,
# first try to load user install
# then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
. "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
. "/usr/local/rvm/scripts/rvm"
fi
EOF
source /etc/profile
The key piece above is the url http://bit.ly/rvm-install-system-wide. As of today, 3/24/2011, this url no longer in service. It results in a GitHub 404 error.
The following url on the RVM website used to contain the instructions for the system-wide install: http://rvm.beginrescueend.com/deployment/system-wide/. However, that url now redirects to the RVM homepage.
In the interests of getting RVM system-wide installation scripts to work again, what are the new instructions?
Here is my fix to install the last working version before he major change:
bash <( curl -L https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide ) --version '1.3.0'
This is working for me now in production. Good luck!
UPDATE
Also, if you are using the chef cookbook from https://github.com/fnichol/chef-rvm or something similar, you can use the following options:
:rvm => {
:system_installer_url => "https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide",
:version => "1.3.0"
}
Just received the following answer from the lead developer, wayneeseguin, on #rvm:
[12:53] "the author" merged it into the ain installer
[12:53] so you should be doing
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
# http://rvm.beginrescueend.com/rvm/install/
[12:53] the code has just changed and the documentation hasn't caught up
[12:53] for both root and user installs
It is true that RVM 1.5.1 will successfully install into /usr/local/bin just by installing as root. However, for some reason, all the existing Chef and Puppet provisioning scripts that are in use today do not appear to survive this version bump. This is unfortunate, as Wayne E. Seguin has made clear that RVM below version 1.5.0 will not be supported.
That said, we need our systems to work today. In order to continue to use RVM 1.3.0, which the existing scripts support, you need to replace the following line:
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
With the following line (found by phlipper):
bash -c "bash <( curl -L https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide ) --version '1.3.0'"

Resources