I'm using zsh in OSX with rvm, but it doesn't load the default ruby at login:
in my .zshrc I have
source $ZSH/oh-my-zsh.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
I've tried to swap those two lines, but still it doesn't work..
(of course in bash it works..)
The issue is that OMZ generated ~/.zshrc with hardcoded PATH, this makes the shell overwrite it every time this file is read.
There is also a bug in ZSH or some mysterious power that makes ZSH read ~/.zshrc after ~/.zprofile - this leads to resetting PATH.
Just comment out the PATH=... line in ~/.zshrc and it should work.
As for the mentioned error - it is supposed to be fixed already, update RVM - rvm get head - and open a new terminal ... if it still appears - open a new issue for RVM.
Related
I just switched to ZSH and are having issues with RVM. I believe it is related to my PATH. One issue that I have is when I start a new tab in iTerm2, the ruby version switches to 1.9.3 even though the default is 2.0.0. Here is my .zshrc file.
export PATH="/Users/okyretina/.rvm/gems/ruby-2.0.0-p353#iou-web/bin:$PATH:$HOME/.rvm/bin:/Users/okyretina/.rvm/gems/ruby-1.9.3-p429#rails-3.2.13/bin:/Users/okyretina/.rvm/gems/ruby-1.9.3-p429#global/bin:/Users/okyretina/.rvm/rubies/ruby-1.9.3-p429/bin:/Users/okyretina/.rvm/bin:/Users/okyretina/bin:/Users/okyretina/xbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/okyretina/phantomjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin"
# load RVM
# insure /usr/local/bin comes before /usr/bin
# PATH="/usr/local/bin:/usr/local/sbin:$PATH"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# This command should be at the end for it loads the oh-my-zsh.sh script
source $ZSH/oh-my-zsh.sh
my export PATH is very long but I'm not sure which one is no longer needed.
run:
rvm get stable --auto-dotfiles
it will reorganize your shell initialization files to load rvm in proper places, make sure to read all the output - it does print information and warnings that are important.
Probably my answer won't help you to solve your particular problem but I will try to help you in finding a solution.
Your $PATH is pretty long and it's hard to make sure that the files have a correct order. In zsh you can set $PATH like this (example taken from my config):
typeset -U path
path=(
/usr/local/{bin,sbin}
/usr/local/git/bin
/usr/local/opt/coreutils/libexec/gnubin
$path
)
As you can see this method much better in terms of readability and it can help you to make sure that the order in $PATH is correct.
Also in your paths you use both "/Users/okyretina/" and $HOME. I think it makes sense to use $HOME in all cases so your paths will look much shorter and it will be easier to read them.
-bash: /etc/profile.d/rvm.sh: No such file or directory
-bash: /Users/janekambani/.bash_profile: line 1: conditional binary operator expected
-bash: /Users/janekambani/.bash_profile: line 1: syntax error near `"$HOME/.rvm/scripts/rvm"'
-bash: /Users/janekambani/.bash_profile: line 1: `[[ -s "$HOME/.rvm/scripts/rvm"]] && . "$HOME/.rvm/scripts/rvm" '
I tried this:
sudo rm -rf /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm /usr/local/bin/rvm $HOME/.rvm $HOME/.rvmrc
but i still kept getting the same error.
im using OS X 10.8
Take a look at the source of /etc/profile.
On 10.8 of Mac OS, installing RVM while using sudo, adds a line to /etc/profile.d/rvm.sh. Even if you remove RVM using rvm implode, that one liner stays in there and will cause that error to show on start up of any terminal.
Use your favorite text editor (nano,vim, etc) to open /etc/profile and comment out these two lines:
source /etc/profile.d/sm.sh
source /etc/profile.d/rvm.sh
Then save the file.
To fix any issues with sourcing RVM use:
rvm get stable --auto-dotfiles #OR:
rvm get head --auto-dotfiles
It will remove existing sourcing lines and add new ones that are meant to work.
This is happening due to a botched installation of RVM (at least the part that tried to install the shell loader was botched). Did you recently try to install RVM?
Something kept trying to insert the RVM load code and it has made a mess.
Here is my suggestion:
Make a backup copy of your .bash_profile.
Open it in a text editor and remove everything but:
export PATH=/Applications/SenchaSDKTools-2.0.0-Developer-Preview:$PATH
export PATH=/Applications/SenchaSDKTools-2.0.0-Developer-Preview/command:$PATH
export PATH=/Applications/SenchaSDKTools-2.0.0-Developer-Preview/jsbuilder:$PATH
Add this line below that:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Save it and open another terminal and see if the error goes away.
I'm having a hard time getting rvm to install on Mint. I tried the instructions at:
https://rvm.beginrescueend.com/rvm/install/
The first step proceeds without incident. However, when I try to run source ~/.bash_profile, I get an error message stating that no such directory exists. I can restart the terminal, but it still says that "The program 'rvm' is currently not installed...."
A .rvm directory in now present in my home directory and the binary is there. I'm suspecting that this means that I need to add something in my .bashrc (or somewhere else) to tell the OS where to look for executables. But I'm still a little new at Linux and am uncertain where exactly it needs to go or what it should be.
The Answer in the same site:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
it works for me.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
Looks like this needs to be tacked onto the end of the .bashrc file if it isn't present.
I am having trouble with using rvm use in zsh. Whenever I do rvm use 1.9.2 or other ruby version, it gives confirmation as Using /home/kxhitiz/.rvm/gems/ruby-1.9.2-p290
But when I do rvm list ruby 1.9.2 is not selected. This works fine in bash. That means I can go to bash and select ruby version I need, and I can come back to zsh to use it.
So that means if I have to change ruby from list of rubies I have installed, I have to go to bash to select it and once selected in bash, I can see it selected in zsh as well.
Any solution would be highly appreciated.
Ok, I did fixed it by adding following line at the end of my ~/.zshrc file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Cheers!
I have installed RVM enroute to updating and running different ruby and rails. After install I received message to update shell's loading files.
1) Place the folowing line at the end of your shell's loading files
(.bashrc or .bash_profile for bash and .zshrc for zsh),
after all PATH/variable settings:
[[ -s "/Users/eric/.rvm/scripts/rvm" ]] && source "/Users/eric/.rvm/scripts/rvm" # This loads RVM into a shell session.
You only need to add this line the first time you install rvm.
I typed [[ -s "/Users/eric/.rvm/scripts/rvm" ]] && source "/Users/eric/.rvm/scripts/rvm"
and hit enter. Does this update my files? Or do I have to open some type of file and cut and paste code?
Since I did not see any notice as stated below from part 2 of the post install, I closed the shell and opened a new one. but the RVM command does not seem to work. Part 2 of the instructions post install was:
2) Ensure that there is no 'return' from inside the ~/.bashrc file,
otherwise rvm may be prevented from working properly.
This means that if you see something like:
'[ -z "$PS1" ] && return'
then you change this line to:
if [[ -n "$PS1" ]] ; then
# ... original content that was below the '&& return' line ...
fi # <= be sure to close the if at the end of the .bashrc.
# This is a good place to source rvm v v v
[[ -s "/Users/eric/.rvm/scripts/rvm" ]] && source "/Users/eric/.rvm/scripts/rvm" # This loads RVM into a shell session.
EOF - This marks the end of the .bashrc file
Be absolutely *sure* to REMOVE the '&& return'.
If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.
Placing all non-interactive (non login) items in the .bashrc,
including the 'source' line above and any environment settings.
Thanks for the help as I am very new and trying to learn RoR but so far have not been able to get past the setup in many of the tutorials I've attempted. It seems many [
1 2 are out of date with new software or I get error messages before I can even attempt to learn the code. If someone knows of a good beginner tutorial that would be great. Thanks again!
The snippet that the installer gives you need to go in a file called the bashrc. The file lives in your home directory: /Users/eric/.bashrc
You need to edit this file and add the line from rvm and then you should be good to go.
As for getting rolling with rails I'd recommend The Pragmatic Programmers book on rails. You can find their books at pragprog.com
If you're on Ubuntu, my tutorial on setting rvm will get you roll all the way up to rails installation:
http://blog.dcxn.com/2011/06/20/setting-up-rvm-on-ubuntu-11-04/