RVM system wide install problems - ruby

I installed RVM system wide on Fedora 14, and I pretty much followed the guide to the letter. When I tried it out though:
$ type rvm | head -n1
rvm is /usr/local/bin/rvm
Most commands appear to work fine, but changing Rubies doesn't work properly. I have to keep logging off and back in for it to switch, and that doesn't seem to work every time.
Here's exactly what I did:
bash < <( curl -L http://bit.ly/rvm-install-system-wide ) as root
add my own user to the rvm group
add
[[ -s "/usr/local/lib/rvm" ]] && source "/usr/local/lib/rvm"
to the very end of ~/.bash_profile.
Log off and back in.
If I understood correctly, this is exactly what should be done. I made sure .bashrc doesn't contain a return statement.
I figure this has something to do with the environment variables that RVM sets up. Any thoughts?

Well, I found the answer.
The problem was that I was not running bash as a login shell. This basically means it doesn't execute my ~/.bash_profile.
Embarrassing thing is, on the very, very last point on the troubleshooting guide is written:
If you are using GNOME on Red Hat, CentOS or Fedora ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.
Looks like I didn't actually read the whole thing, but Wayne does need to put "Make sure you're running the shell as a login shell" on the guide itself, not just on the troubleshooting section.

Related

Zshell starting with an error (showed in Powerline9k-theme)

Recently I installed Zshell instead of Bash. During this, then I saw that my $PATH was 7 miles long, - so I decided to try and clean it up a bit. When I uninstalled rvm (by running rvm implode followed by rm -rf ~/.rvm) then when I restarted my terminal, I now see an error:
If I just press ENTER, then the error remains. But if I do any other command, then it disappears (ls, echo, source ~/.zshrc - you name it).
If I reboot iTerm (or start a new tab), - then the error re-appears.
The error is not being showed, - so if I activate another theme, then I can't see if there is an error.
My gut feeling tells me, that it has something to do with my path, but I'm not sure. My path is waaay shorter than before RVM was installed.
If i rename my ~/.zshrc-file, then the Powerline9k-theme gets deactivated, so I can't see if the error actually still appears or not. But I have tried it... Then a theme-less zshell just start up.
Any idea how to fix it or how to debug it?
EDIT
I just realized that it could actually have been a left-over-error, from back when I was running bash, - so I added that tag as well.
If the visual blemish disappears as soon as you execute any command as you say so, just place an echo -n at the end of your .zshrc as a quick and easy fix, if you are not up to the task of debugging and potentially causing more problems on your machine.
The issue isn't worth your time ;)
Edit: Apparently the above didn't work. See comments.
If you are interested in debugging, a good starting point would be to place set -xe (print every line that is executing and abort on any line that exits nonzero) at the beginning (after the shebang line, or as flags in the shebang) of each configuration script that is executed when you start a new interactive shell.
Also consider set -xeuo pipefail to additionally catch and abort on usage of unset shell variables and commands that return nonzero inside pipes (e.g. set -e will not abort on false | true because the overall line exited with status 0, but -o pipefail will abort on such a line). It is worth noting that these flags are bash features, but since zsh is a feature superset of bash, they work in zsh too.
Have look at their documentation on github, relevant fragment is here.
Solution:
In your ~/.zshrc find variable called POWERLEVEL9K_LEFT_PROMPT_ELEMENTS and remove rbenv.
Explanation:
The default value of POWERLEVEL9K_LEFT_PROMPT_ELEMENTS is (context dir rbenv vcs), and it is likely that rbenv is the segment producing the error - after you uninstalled rvm that segment can't execute.
Uninstall all apps that use the path and reinstall. It's the only way. Instead of rm, you use should create an alias that has a trash can.

dmenu top bar in xmonad runs some items (Chromium), but not ranger or others

I have a "stock" xmonad install on Arch.
No changes to my xmonad.hs yet
I have installed dmenu.
It runs by alt-p, the default, and displays and filters as expected.
Chromium runs, but other items, like ranger, alsamixer or other tasks do not.
I am not finding anything anywhere about anyone having to do anything to get these items to run, nor anyone having any issues with doing so.
Surely, then, there is something wrong in my install.
my dmenu_run is as follows:
#!/bin/sh
dmenu_path | dmenu "$#" | ${SHELL:-"/bin/sh"} &
I would normally run terminology with bash or zsh. I have tried to alter the SHELL to /bin/bash, but to no avail.
Is there any other place I must look or items I should alter?
Such a shame as I am really liking xmonad so far, and want to get dmenu working before I start exploring xmonad.hs...
Thanks in advance
UPDATE: I have found the following
here over at Archwiki that involves changing dmenu_run and adding a .demenu_term in one's home. It seems to work, but still wonder if there was a more orthadox mechanism.
ranger and alsamixer are applications which run inside a terminal. Imagine (or try) to run ls via dmenu, where should the directory listing be printed to without a terminal?
You look for functionality which is provided either by prompt imported from XMonad.Prompt.Shell by using a convinient keybinding like
((modm .|. shiftMask, xK_c), prompt ("xterm" ++ " -e") greenXPConfig)
(described in the linked documentation) or shellPrompt where you execute
xterm -e alsamixer
or any other command, e.g.
feh path/to/image/you/want/to/open/now.jpg
instead of opening a terminal, running above with tailing & and exiting the terminal.

the correct Ruby version when opening a terminal

Each time I open a terminal my Ruby version is wrong. I am obliged to execute by hand the following command:
source /usr/local/rvm/scripts/rvm
I read that RVM doesn't modify .bashrc or .bash_profile but I note that my .bashrc has at the end:
PATH=$PATH:$HOME/.rvm/bin
Not only I didn't insert this myself but the path to rvm is wrong !
I changed by:
PATH=$PATH:/usr/local/rvm/bin
I reopened a terminal but the Ruby version is always wrong !
rvm does modify your .bash_profile / .bashrc -- that's one of its weaknesses. In particular, it adds (is supposed to add) this line to load rvm as a shell function:
# Load RVM into a shell session as a function
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I had a similar issue with the wrong ruby version running even after I changed the global default in rvm--ensuring this line was at the end of my .bash_profile fixed it. In any case, that line's supposed to be there for rvm to work properly.
You can make an .rvmrc file in the root directory of your application.
It runs whatever is inside on opening the root direct, so I think you can just copy this
PATH=$PATH:/usr/local/rvm/bin
and things should be good. You'll get a warning, but it's safe to ignore (or has been in my experience). I think you might be better off going with this, which I've found helpful to keep rubies/gemsets straight across applications.
#.rvmrc
rvm [ruby]#[gemset] #for example rvm 2.0.0-p247#my_gemset
Why gemsets/rubies get switched/reset in the first place, I really don't know and it is annoying, but this seems to fix it.
read more here
Depending on your setup it could not be loading for several reasons.
For instance, when you open a shell (depending on the OS distribution) bash files are read in various orders, although here is what the standard looks like: ( I believe Ubuntu is slightly different so you might want to check if thats your distro).
# for interactive login shells (when you login to a terminal)
/etc/profile
/home/<user>/.bash_profile
/home/<user>/.bash_login # if there is no .bash_profile
/home/<user>/.profile # if there is no .bash_login
# for interactive non-login shells (i.e. opening up a new tab)
/etc/bash.bashrc
/home/<user>/.bashrc
What happens when you directly source your .bashrc? Does it then find rvm? If so, then its just a matter of making sure your .bash_profile sources .bashrc aka:
# in .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
If this isn't the cause you could dive into the rvm documentation or switch to rbenv which IMHO is a much simpler solution.
RVM should handle this automatically but this code is wrong.
PATH=$PATH:/usr/local/rvm/bin
RVM's path should be first. Your bash is acting as you wish actually. It uses the 'system wide' ruby first because you tell your shell to do so. Change this to:
PATH=/usr/local/rvm/bin:$PATH
then source ~/.bashrc and it will work as you wish, calling rvm ruby when you login.

RVM not being found (Mac 10.7.3)

I've done a lot of searching and there seem to be similar issues, but none that have helped me solve this problem. I'm fairly new to Ruby, Rails, and -ix systems so that doesn't help much, either. :(
I was able to get RVM up and running along with the latest versions (1.9.3-p125 of Ruby and 3.2 of Rails). However, when I exit terminal and come back in the system defaults are being used. When I tried to change versions I received a "command not found". I then tried just typing "rvm" and got:
-bash: rvm: command not found
I followed some other tutorial advice and modified my ~/.bashrc file to look like this:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
but I'm still getting the exact same "command not found" even after exiting Terminal.
Any thoughts on how to get RVM working properly? Everyone says use it, but it sure isn't simple...
Thanks a lot!
Greg
I followed some other tutorial advice and modified my ~/.bashrc file
Usually I modify .profile file on Mac OS X, and .bashrc on Linux. Try to modify .profile
Please check How to fix Terminal not loading ~/.bashrc on OS X Lion to know why Terminal doesn't load .bashrc file.
If you modify your .bashrc you either need to immediately source it or create a new shell to see the changes take effect.
The standard rvm procedure is to source the rvm script that is created. The installation documentation covers most use cases.
If your rvm command is missing, it's possible that your .bashrc is not working as you expect. Is your PATH being modified as you've requested? If not you might have another issue.

"RVM is not a function" error

RVM is installed on my machine (running Mac OSX 10.6.8), correctly and it runs fine. The odd thing is that to run it, I have to use source ~/.rvm/scripts/rvm for every new session. I tried making a symlink from it to /opt/local/bin/rvm, but when it runs it does nothing. I also tried creating a symlink from ~/.rvm/bin/rvm to /opt/local/bin/rvm, and when I run rvm in the Terminal it displays the help page, as expected. But when I try rvm use some_ruby_version it always displays "RVM is not a function, selecting rubies with 'rvm use ...' will not work.". How can I fix this?
My goal is to get it to the the point that I don't have to type the source command every session, and for some reason ~/.profile does not execute.
You have to source the RVM script into the current session because it makes changes to the shell environment - and it is absolutely impossible for that to be done from a child process. Your efforts at running RVM as an external command cannot succeed.
To actually fix this you have two choices:
Configure your terminal emulator to start a login shell, rather than a non-login shell, so that your .profile is loaded.
Modify .bashrc to source RVM instead, which works for non-login shells as well.
To do the second you can just add to ~/.bashrc:
if test -f ~/.rvm/scripts/rvm; then
[ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
fi
If you are using zsh as shell instead bash, you have to:
1.
vi ~/.zshrc
2.
Like Matt said, add:
if test -f ~/.rvm/scripts/rvm; then
[ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
fi
3. Restart Terminall
4. Done!
rvm use 1.9.3
Wil work
I didn't understand what ~/.profile does correctly; I needed to change ~/.bash_profile instead. Problem solved!
Well, with mountain lion (10.8.3) what worked for me was editing /etc/profile
and adding the line mentioned before at the bottom of the file:
if test -f ~/.rvm/scripts/rvm; then
[ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
fi
I had the same issue. I found the .profile file was not getting updated, so i added the same command that was added into .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I don't know if this is the right way, but it worked...
You shouldn't need to edit anything as others suggest. Just go into your terminal's settings and select the "Run command as login shell". This will cause .profile to run on the next terminal instance. Reopen your terminal and you should be able to use rvm use 1.9.3 (or whatever version you installed).
More info found on rvm.io (which is also a great place for answers)
https://rvm.io/integration/gnome-terminal
You have to make some settings.
Open terminal and run this command.
source ~/.rvm/scripts/rvm
and then go to edit > Title and command and check Run command as login shell
and you are done. Now you don't need to specify source everytime.
What was screwing me up was assuming my path was correct since I was using one I can run manually.
Apparently there are different executables or scripts that can be used and are located in different places.
I thought that the path Mina should use was this:
/usr/local/rvm/bin/rvm
When in reality it was this:
/usr/local/rvm/scripts/rvm
I had this issue when I became root. I tried many of the solutions above. What finally worked was exiting from root and being a regular user. Which is what I needed anyway.
None of these solutions seemed to redeem my problem which was on Ubuntu 12.04 LTS.
What I did is the following:
rvm get stable --auto-dotfiles as outlined in the RVM documentation here
Added source ~/.profile as the first line of: ~/.bash_profile
I will not all of these steps were documented as errors from the RVM command line:
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 a example.
and
WARNING: You have '~/.profile' file, you might want to load it,
to do that add the following line to '/home/user_name/.bash_profile':
source ~/.profile

Resources