可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I just installed RVM, but can\'t make it work. I have such line at the end of my .profile
file:
[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && . \"$HOME/.rvm/scripts/rvm\"
I tried to run source .profile
and restarting terminal, but still, when I run rvm use 1.9.2
I\'m getting:
RVM is not a function, selecting rubies with \'rvm use ...\' will not work.
My system is Ubuntu 11.10.
回答1:
You are not using an login shell.
The process of enabling the login flag is described here, also some details on what a login shell is can be found here.
Thus, you need to check the option \"Run as login shell\" in the Gnome terminal\'s settings. It is required to open new terminal after this setting the flag.
Sometimes it is required to set the command to /bin/bash --login
.
For remote connections it is important to understand the differene between running interactive ssh
session and executing single commands.
While running ssh server
and then working with the server interactively you are using login shell by default and it\'s all fine, but for ssh server \"command\"
you are not using login shell and it would be required to run it with ssh server \'bash -lc \"command\"\'
.
Any remote invocation can have the same problem as executing single command with ssh
.
回答2:
You need to run the following
$ source ~/.rvm/scripts/rvm
then run this
$ type rvm | head -n 1
and if you get
rvm is a function
the problem is solved.
You also need to run user$ rvm requirements
to see dependency requirements for your operating system
Source: https://rvm.io/rvm/install/
I forget mention that you need to put this code into you ~/.bashrc or ~/.zshrc file and you will not need to write this code again. Cheers!
回答3:
To permanently resolve this just cut/paste following line:
[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\"
From: ~/.bash_profile
file
To: ~/.bashrc
file
Reason this works is that .bashrc
is executed each time you enter terminal, and .bash_profile
each time you login. That is why solution /bin/bash --login
works, but you have to do that each time you enter terminal. This way you are set until your next format, and you will forget all this by then :)
回答4:
I too faced this problem. Finally i executed this line on terminal.
source ~/.rvm/scripts/rvm
Problem is fixed. Because this line will make the RVM instance a function for a particular time.
回答5:
The latest RVM (rvm 1.11.6 (stable)) stopped working on Ubuntu (10.10 - 64 bit - nerdy gnat or whatever) - I kept getting
\"RVM is not a function, selecting rubies with \'rvm use ...\' will not work.\"
Before, I got the message, but \'rvm 1.9.3-p0@rails321\' would work. Now, it wouldn\'t work - you couldn\'t change gemsets at all.
Nothing worked, until I found this - make this the LAST line in /home/your-name/.bashrc
[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\"
回答6:
As you said, the error shown could be the following one.
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.
As said above, just type \'/bin/bash --login\' in your terminal (after restarting your terminal), then type the comand \'rvm use 1.9.3\' (for e.g.) and it will start using the same version.
Just execute the command \'ruby -v\' to confirm that the RVM is using the updated version of Ruby.
回答7:
I had this problem too on a fresh rvm installation, and non of the answers here fixed it. Going into the official rvm site, on the basics section, they have this command:
# from http://rvm.io/rvm/basics
source $(rvm 1.9.3 do rvm env --path)
You should change 1.9.3 for the ruby version that you actually want, and it\'ll make rvm a function regardless of the shell type.
回答8:
Maybe you can try belows:
- Your Terminal ->
- Edit ->
- Profile Preferences ->
- Title and Command ->
- Check the \"Run command as a login shell\"
- Done
回答9:
even though you accepted an answer, i\'d like to suggest another way .. ~/.bashrc is loaded before any shell is opened. Add that line at the end of that, and you don\'t need any of that login shell thing
回答10:
Run bash --login
and then run rvm use 2.0.0
.
回答11:
Open Up the Terminal and then Go to Edit > Profile Preferences and then go to the Tab \"Title and Command\" and Check \"Run Command as Login Shell\".
Boot Up a Bash and Now you can install Gems directly from the terminal without the use of sudo and the error \"RVM is not a function, selecting rubies with \'rvm use ...\' will not work.\" will be eliminated.
Cheers.
回答12:
All the above answers are valid. But when i faced the same issue, the solution was the following:
- Update ZSH. (Tried to update directly din\'t work for some reason. So uninstalled and reinstalled updated version from here)
- Set default shell as zsh (i.e. if you prefer zsh) using
sudo chsh -s $(which zsh) $USER
Ensure that the following code is at the bottom of your .zshrc
after you have installed the latest RVM probably using CURL from official RVM site
[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && . \"$HOME/.rvm/scripts/rvm\"
source ~/.profile
MOST IMPORTANT POINT: Ensure that in your .zshrc
file every export to PATH
is appended with :$PATH
. Which i believe was the root of my problems even after following the above steps.
post this all my problems of RVM Not being a function went away. If it still does not work, give some error trace over here. After a few hours of struggle to solve this issue, i\'m sure i must have seen all related errors.
Hope it helps. Cheers!
回答13:
Procedure for installing Ruby 1.9.3-p125 on Mac OSX 10.8 Mountain Lion
- You\'ve already installed the latest XCode (>= 4.3) and and the command line Objective-C
compiler \"clang\".
- You must run the \"bash\" shell for this procedure to work.
- Go to System Preferences
- Click on \"Users & Groups\"
- Click the lock on the bottom left of the panel and enter your password to unlock it.
- \"Ctrl-Click\" on your user icon in the left pane of the panel and choose \"Advanced Options...\"
- Change the Login Shell to \"/bin/bash\"
- Close the preferences
- Open a terminal window (press command+spacebar and type in \"terminal\")
- Follow the instructions at:
http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
Notes:
To install ruby, you may need to specify the clang compiler:
$ rvm install 1.9.3p125 --with-gcc=clang
If RVM gripes about /usr/local/rvm not found, you need to create a link:
$ ln -s /Users/[your user name]/.rvm /usr/local/rvm
回答14:
source ~/.bash_profile
... should do the trick ..., probably need to logout and login again.
How to reload .bash_profile from the command line?
回答15:
« Official » instructions are there: https://rvm.io/integration/gnome-terminal/
回答16:
I\'d got the same error because I\'d ever installed the old rvm version ruby-rvm with the apt-get command.
I solved the problem by remove the script line to config the old rvm in .bashrc file.
Check the old rvm config script and then run source .profile
回答17:
I had the same error, but none of the solutions on this page seemed to work. For me it was enough to add the rvm
executable to my path:
PATH=$PATH:/usr/local/rvm/bin/
Et voila!
回答18:
I had the same issue and I did this in my .bash_profile and it worked.
source \"$HOME/.rvm/scripts/rvm\"
.
回答19:
For those who comes with same issue and they are using lubuntu like me I followed this link :
You start your terminal with
lxterminal -e \"bash -il\"
Thank to @mpapsis who pointed me to the right direction
回答20:
I fixed it by adding this line to .bash_profile:
[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\" # Load RVM into a shell session *as a function*