Alright so I imploded RVM and switched to rbenv but now I think I'm having all kinds of problems with the gem path. I think some part of my system still thinks gems are supposed to be found with RVM and it's messing everything up. I'm terrible at fixing config issues like this so your help is greatly appreciated.
This is my $PATH:
/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/Users/home/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/home/.rvm/bin
So as you can see .rvm is still in the $PATH, is this my problem? How do I fix it?
Here is my gem env(This was what I got before I manually moved some directories to better match the path, now I get the same error(below)
as when I run ruby or bundle):
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin15.0]
- INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.2/bin
- SPEC CACHE DIRECTORY: /Users/home/.gem/ruby/2.1.0
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- /Users/home/.rbenv/versions/2.1.2/bin
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/home/.rbenv/versions/2.1.2/bin
- /usr/local/Cellar/rbenv/0.4.0/libexec
- /Users/home/.rbenv/shims
- /Users/home/.rbenv/bin
- /Users/home/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/home/.rvm/bin
My current version of ruby is 2.1.2 and it is looking into 2.1.0 still.
Here is my .bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Here is my .profile
eval "$(rbenv init -)"
When I run the ruby or bundle command I get this error:
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I did some tinkering with the path and manually relocated the gem directories, and I think I've done more harm than good. Thanks for the help. If you don't know the answer could someone please comment the best way to completely scrub ruby and the gem path settings so I can get a fresh reinstall? Do I just uninstall rbenv?
My RVM implode script is here -- you can edit is as you like.
https://github.com/sixarm/rvm-implode-systemwide-danger
The script does RVM implode, systemwide, and is dangerous. The script will seek and destroy RVM installations, rvm gems, .rvmrc files, and then search your entire system for lingering files and and references.
Suggestions and pull requests are very welcome. I'm the author.
The entire script is copy/paste below for reference. The link above is probably better because it will have any updates, changes, improvements, etc.
#!/bin/sh
#
# Uninstall RVM (Ruby Version Manager) systemwide:
# THIS IS DANGEROUS.
#
# This script tries to eliminate RVM everywhere on the system,
# by doing these steps:
#
# * Run `rvm implode`
# * Delete all known RVM-related files everywhere on the system.
# * Delete all users' home directory `.rvm` directories and `.rvmrc` files.
# * Uninstall all known RVM gems.
# * Search the system for potential lingering items and print them.
#
# ## Use at your own risk
#
# This script is not advanced:
#
# * it does not do any error checking
# * it does not ensure anything worked
# * it does not guarantee success
#
# If it doesn't work for you, please let us know and we'll improve it.
#
# We welcome feedback, patches, and pull requests.
#
# ## Warnings
#
# Some of the script lines may report missing directories.
#
# For example, a Mac system typically has a /Users/ directory,
# whereas a Linux system typically has a /home/ directory.
# You can delete the lines that you don't need, if you like.
#
# If rvm implode gives errors like this loop:
#
# line 72: /usr/local/rvm/scripts/rvm: No such file or directory
#
# then the rvm setup is bonked and we can delete the rvm script
# by hand then run this script again; rvm implode won't work,
# but the rest of the script will do a decent job of deleting
# any lingering rvm files and reporting any remainders.
#
# Command: rvm-implode-systemwide-danger
# Version: 2.0.0
# Created: 2011-08-22
# Updated: 2015-01-25
# License: GPL
# Contact: Joel Parker Henderson (joel#joelparkerhenderson.com)
##
set -euf
out () { printf %s\\n "$*" ; }
out "rvm implode"
rvm implode
out "remove rvm files from system-wide areas"
sudo rm -rf /usr/local/bin/rvm
sudo rm -rf /usr/local/rvm
sudo rm -rf /etc/rvmrc
sudo rm -rf /etc/profile.d/rvm.sh
out "remove rvm files from all likely user areas"
sudo rm -rf /home/*/.rvm
sudo rm -rf /home/*/.rvmrc
sudo rm -rf /Users/*/.rvm
sudo rm -rf /Users/*/.rvmrc
sudo rm -rf $HOME/.rvm
sudo rm -rf $HOME/.rvmrc
sudo rm -rf $(dirname $HOME)/*/.rvm
sudo rm -rf $(dirname $HOME)/*/.rvmrc
out "uninstall rvm gem as current user and with sudo"
gem uninstall -a -q rvm
sudo gem uninstall -a -q rvm
out "delete rvm group"
sudo /usr/sbin/groupdel rvm
out "try to find any remaining .rvmrc files, in case you want to delete them"
sudo find -L / -name .rvmrc
out "try to find rvm text in configuration files, in case you want to edit thme"
sudo find -L / -type f | grep "\(bash_login\|bash_profile\|bashrc\|profile\|zshenv\|zshrc\|zlogin\|zlogout\|zprofile\)$" | xargs -I{} grep -Iil "rvm" {}
Ensure that you are checking all of your "rc" files. This includes ~/.bashrc and ~/bash_login, if they exist.
Using a tool like grep can help you find them.
grep 'rvm' -l ./.* maybe, to get the filenames that any reference to rvm may be in.
Related
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]
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
Like an idiot, I managed to delete my system ruby install.
I've re-installed xcode, and also installed RVM
Doing this:
$ which ruby
returns this:
/Users/alex/.rvm/bin/ruby
However, Homebrew still seems to be broken:
$ brew
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory
The system ruby on OS X is symlinked to the Ruby.framework. Since you reinstalled Xcode, it should be installed, but you need to restore the symlinks.
First, check that this file exists and works.
$ /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
If that command works, you should be able to setup the sym links again
cd /usr/bin
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/erb /usr/bin/erb
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/gem /usr/bin/gem
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/irb /usr/bin/irb
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rake /usr/bin/rake
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdoc /usr/bin/rdoc
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ri /usr/bin/ri
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/testrb /usr/bin/testrb
This should get you started, hopefully I haven't forgotten any of the binaries that need linked. There are other suggestions to reinstall ruby here: https://superuser.com/questions/171433/is-it-possible-to-reinstall-fix-mac-os-xs-system-ruby-without-doing-a-complete
Another method in a gist: https://gist.github.com/1418384
brew is hardcoded to use the system ruby. You could try change brew's shebang (the first line) to /usr/bin/env ruby, but it's not guaranteed to work with anything but the system Ruby (I'm not sure it's fully compatible with Ruby 1.9).
Or you could reinstall your system Ruby, which should be possibly by reinstalling OS X.
If you don't want to have to reinstall the system ruby, the following should do the trick.
IMPORTANT: replace MY_USER_NAME with the name of your home folder, which is the "short name" of your user in OS X.
sudo ln -s /Users/MY_USER_NAME/.rvm/bin/ruby /usr/bin/ruby
There is a new link for Homebrew install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installation link for homebrew has been moved.
Here is the new one:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
sudo rm -rf /usr/local/Cellar /usr/local/.git
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
I solved by reinstall brew.
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'"
I have executed the commands as prescribed in the instructions at the rvm website but things don't seem to work..
Fetching the code from the git repository runs smoothly but when I try to use
rvm notes
Error:
/usr/local/bin/rvm: line 73: /home/cody/.rvm/scripts/rvm: No such file or directory
flashes in multiple lines and doesn't stop till I hit ctrl+C..
I am running Ubuntu 8.04 and currently I am running ruby 1.9.2..
Sorry, if I am missing out any necessary information. Thanks in advance.
Ack, I didn't mean to post this as a comment on the question. Anyway, if I had to guess, I'd say you installed rvm using sudo or as root. If that is the case, remove it and reinstall without sudo:
sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh \
/usr/local/rvm /usr/local/bin/rvm
sudo /usr/sbin/groupdel rvm # this might fail, it's not that important
Open new terminal window/tab and make sure rvm is removed:
env | grep rvm
The output should be empty, sometimes it's needed to relogin, after it's empty you can continue:
curl -sSL https://get.rvm.io | bash -s stable
It works perfectly fine installed for the local user.
Ok, for anyone who tried to install RVM using sudo and is now pulling
their hair out trying to get it to install in $HOME/.rvm, here's what
did it for me:
When you installed RVM using sudo, it created a file /etc/rvmrc, which contains the following:
umask g+w
export rvm_path="/usr/local/rvm"
This makes all future attempts at installation (even when not run as sudo)
install into /usr/local/rvm, which is NOT what you want for a single
user installation. So remove /etc/rvmrc and then you can run
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
and it will install properly into $HOME/.rvm
DId you add this line to your ~/.bashrc?
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
I have executed the commands as prescribed in the instructions at the rvm website.
WHICH commands? There are several pages containing instructions to install RVM depending on whether you want a single-user "sandbox" or are installing system-wide for a multi-user system as the administrator.
Because you have RVM in /usr/local, I think you tried to do a system-wide install but didn't get it right. For 99% of us, that is the wrong installation method, and instead you should use the single-user installation, which is simple and puts everything in ~/.rvm.
Either way, be sure to read the entire instructions. And, if doing a single-user install, finish the install with the "Post Install" modifications to ~/.bashrc or ~/.bash_profile for a single-user, then start a new terminal session.
When using the single-user install NEVER use sudo to install gems to a RVM-managed Ruby, even though the instructions for a gem might say to.
Look at the section "Troubleshooting your install" here. Since you are on Ubuntu, you probably need to make further mods to you .bashrc
in .bashrc have you changed the
[ -z "$PS1" ] && return
to
if [[ -n "$PS1" ]]; then
and added this to the end of the file:
fi
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I just had a similar problem.
It turned out that many files in ~/.rvm/scripts/ and ~/.rvm/src/rvm/scripts/ which obviously should be executable did not have execute permissions. Running a script on both directories to set all files to executable solved that immediate problem.
I have got same problem after installation. Then I restarted terminal and it started working poperly.