简体   繁体   中英

RVM installed ruby not found after restart of shell Ubuntu 16

I've installed RVM and ruby and at first it seemed to work, but whenever I open a new shell tab or window only rvm can be found, not ruby.

Running rvm -v gives me a nice little output:

rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

but running ruby -v , gem -v or rails -v gives me an error telling me to apt-get install ruby/rails .

I've installed rvm through the following commands:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

I installed ruby like so:

rvm install 2.3.1
rvm use 2.3.1 --default

Rails was installed with the command:

gem install rails

What I've tried:

I've checked my .bashrc .bash_profile and my .profile and it's set up nicely with the following:

.bashrc and .profile :

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

.bash_profile :

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

What kinda works:

Running the line source ~/.rvm/scripts/rvm allows ruby , gem , and rails to be found again, but you have to repeat this is every new tab or window.

How can I fix so that rvm installed modules will work automatically?

Turns out everything is set up nicely and correct. If you have this issue it's an issue with your shell settings. You need to set your profile to login shell .

How to set this in the standard terminal on Ubuntu's standard GUI

(GNOME terminal Unity)

Access your settings by going to the menu and pic Terminal > Preferences .

In the window that pops up, select Profiles in the tab menu. Pick if you want to create a new profile or edit the existing default one. In the window that comes up (it's the same regardless of your pic) go to the tab Command and enable Run command as a login shell .

Restart your terminal and you should find that your rvm commands are now working.

What about adding to your .profile or .bashrc

echo "source $HOME/.rvm/scripts/rvm" >> ~/.profile

EDIT

You need to call source from either .profile or .bashrc NOT .bash_profile

jperez@asus-kubuntu16:~$ grep bash_profile .profile                                                                                                                 
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
jperez@asus-kubuntu16:~$

In Deepin Terminal run: sudo nano ~/.config/deepin/deepin-terminal/config.conf

and change run_as_login_shell=false to true

> sudo apt-get update
> sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
> sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
> gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
> \curl -sSL https://get.rvm.io | bash -s stable
> source ~/.rvm/scripts/rvm
> rvm install 2.3.1
> rvm use 2.3.1 --default
> ruby -v

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM