RVM installed by Ruby not working?

前端 未结 10 1252
不知归路
不知归路 2020-12-04 23:36

I installed RVM using the single instruction mentioned at the RVM website (using git).

Then I installed Ruby version 1.9.2 and 1.8.7 using:

rvm insta         


        
相关标签:
10条回答
  • 2020-12-05 00:17

    Ruby is not in your path. In simple terms, RVM handles the switching of Ruby in your path. Look at the output of the command-line tool

    printenv
    

    You should see something similar to:

    PATH=/Users/myuser/.rvm/gems/jruby-1.5.6/bin
    

    See Tin Man's response, it should get you were you need to go.

    0 讨论(0)
  • 2020-12-05 00:23

    Are you making sure to source /usr/local/lib/rvm? echo 'source /usr/local/lib/rvm' >> ~/.bashrc and relog via SSH/start a new instance of Bash.


    To clarify, since there is some confusion: there are two ways to install RVM: a "per user" install, and a "system wide" install.

    For most day-to-day use, you want to use a "per user" install, which installs RVM into ~/.rvm. System-wide installs are good for servers, where one set of Rubies should be used. The default location for RVM in this case is /usr/local/rvm.

    Based on your question, it appears you've installed RVM as a system-wide install.

    To use RVM, it must be initialized by running a script each time you log in. To do this easily, you include the file in your ~/.bashrc file (or ~/.bash_profile if you're on OS X), so that it is automatically run each time you log in. For a per user install, add the following text to the file:

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
    

    for system wide installs, use this text instead:

    [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
    

    If you do indeed have a system-wide install, you will also need to make sure you are a member of the rvm group; type the following to do so:

    sudo adduser `whoami` rvm
    

    Once you have made the necessary changes, log out of your session and then log back in. Once you have done so, rvm use 1.9.2 should set a bunch of environment variables, which you can see by typing rvm info. If all is well, ruby should execute correctly.

    0 讨论(0)
  • 2020-12-05 00:26

    I faced the same issue. I just executed the command:

    /bin/bash --login
    
    0 讨论(0)
  • 2020-12-05 00:27

    I noticed that source line was correctly in .bash_profile but I kept getting ruby command not found. So, when I checked rvm list, I figured out none ruby was selected:

    rvm list
    
    rvm rubies
    
       ruby-2.4.0 [ x86_64 ]
    
    # Default ruby not set. Try 'rvm alias create default <ruby>'.
    
    # => - current
    # =* - current && default
    #  * - default
    

    then I did the selection through rvm use 2.4.0 and checked again

    rvm list
    
    rvm rubies
    
    => ruby-2.4.0 [ x86_64 ]
    
    # Default ruby not set. Try 'rvm alias create default <ruby>'.
    
    # => - current
    # =* - current && default
    #  * - default
    

    Look the arrow close the installed ruby and the commented subtitles. After that ruby -v finally answered me

    ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
    

    I hope this help. Cheers.

    edit: You can use rvm --default use 2.4.0 to set it as default ruby version

    0 讨论(0)
  • 2020-12-05 00:27

    rvm use 2.6.3 --default can fix it, but when I shut down my Ubuntu, the problem appearance once again!! this link helped me.https://github.com/rvm/rvm/issues/3682

    1. sudo vim .bash_profile
    2. add the following two lines:
    [[ -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    
    
    0 讨论(0)
  • 2020-12-05 00:29

    I installed Ruby on Rails on a Ubuntu 11.10 VM, using "HOW TO INSTALL RUBY ON RAILS IN UBUNTU 11.10".

    After installing it, I was running into the same issue. The only thing that seems to be missing from the tutorial in my opinion, is the following command:

    rvm --default use 1.9.2
    

    Although Ruby is properly installed, RVM seems to redefine in each session Ruby is to be used. The problem was that the default Ruby pointed to the "system ruby", and, in my case, this one pointed to nowhere and made the call rvm info return a result similar to the initial post.

    To solve this issue, one of the follwings commands must be used:

    rvm  --default use 1.9.x
    

    or (valid only for the current session)

    rvm use 1.9.x
    

    Before I could start the server, I also came across "ExecJS and could not find a JavaScript runtime". As proposed in several answers, I solved it by adding the following lines to the Gemfile.

    gem 'execjs'
    
    gem 'therubyracer'
    

    and running bundle install afterwards.

    0 讨论(0)
提交回复
热议问题