I currently have Ubuntu 16.04 installed on my virtual box. I installed Ruby and Rails by RVM. After that I tried
$ rails
The terminal said
The program `rails` is currently not installed. You can install it by typing:
sudo apt install ruby-railties
I solve this problem by typing
$ source ~/.rvm/scripts/rvm
Credits here
However, once I reboot the virtual machine, everything I did with source will lose and I need to re-enter
$ source ~/.rvm/scripts/rvm
I also have some similar cases I need to do on every reboot.
So is there any solution can make those command be run automatically each time?
If you're using bash, add the line to the end your .bashrc:
.bashrc
source ~/.rvm/scripts/rvm
If you're using zsh, add it to you .zshrc.
Depending of which implementation of cron you're using it's possible to run jobs only after reboots, for example:
#reboot source ~/.rvm/scripts/rvm
Again. before editing your crontab make sure your cron implementation supports #reboot flag.
Another option is to include all your scripts in /etc/rc.local
Related
I followed this tutorial below:
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This worked perfectly for me; however, I have one small problem?
Each time I open a new terminal I have to run this command in order for rails to work:
source ~/.rvm/scripts/rvm
What is the problem and why is rvm not recognized
This is what I see after I open a new terminal and verify rails:
robert#rob:~$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Thanks
I highly recommend you to use the official website to install RVM: https://rvm.io/rvm/install
Your problem is that RVM is not loaded when you open a new terminal, this is why you have to manually add the source at each instance of the Terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).
Take a look at #mpapis comments
I just went about the process of installing ruby and rvm.
This is all very confusing, whilst RVM is working on the terminal I installed it on, it is not working on any other and I am getting the following error:
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
Could there be an issue with my paths, or another version of ruby or RVM that is causing this?
Trying sourcing your bash profile.
source ~/.bashrc
Or
source ~/.bash_profile
Also: . ~/.bash_profile works.
This runs your bash profile in your current context (your current shell process) and sets the environment variables so they remain in this context. This is different from executing the .bash_profile like this: ./.bash_profile which will create a new shell, execute the commands there and thus not affect your current shell process.
If you just finished to install it, to have access in all terminals you need to logout and login again, in order to load the new environmental variables on your .bashrc or .bashprofile
I know the above question is very common question. I have gone through multiple posts on this topic. But I didn't get any resolution.
I have installed rvm locally. We already have the installation files. SO went into the folder and run the install command.
$ ./install
Then I checked ./rvm folder in the Users home folde
$ cd ~/.rvm
folder exists. Hence Installation is successful.
Now I am typing rvm in the command line
$ rvm
I am getting below exception
$ rvm
-sh: rvm: command not found
After reading the multiple articles in stackoverflow on this issue, I learned that I have to add the below lines in .bash_profile as I am using Mac OSX 10.7.3
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Even after I am getting same exception while typing rvm. Is there any thing extra I need to do? or Am I missing some thing? Please help
Steps to try out:
Log out and login to your system.
Open a new terminal and manually run
source $HOME/.rvm/scripts/rvm
then
rvm
Check these work-arounds.
Update:
To avoid running
source $HOME/.rvm/scripts/rvm
every time you open a terminal, include this line into ~/.MacOSX/environment in your Mac (This is similar to ~/.bashrc in GNU/Linux-based systems under $home aka ~ directory).
In my case, i am using Ubuntu Bash in Windows 10 and to fix the problem i used:
source /usr/local/rvm/scripts/rvm
For those that are doing this in 2018 just
add
source $HOME/.rvm/scripts/rvm
to your .bash_profile within your home directory.
you need to enable login shell in terminal emulator preferences, sometimes it is needed to use /usr/bin/bash --login, here is an example https://rvm.io/integration/gnome-terminal/
after enabling login shell you need to close terminal application and open it fresh.
I just had to open a new Terminal session.
After I installed it using:
curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install 2.2
For Ubuntu 18.04, I had to run the command below to solve the issue after rvm was installed using instruction from here.
source /usr/share/rvm/scripts/rvm
This is one of other options available for RVM:
source /etc/profile.d/rvm.sh
I'm new to Ruby on Rails and have just set it up in Ubuntu Linux following instructions I found here. Specifically,
As s.m. said, I uninstalled everything, then I opened another terminal session as a normal user and run:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
then i run source /home/my-desktop-username/.rvm/scripts/rvm as a normal user NOT ROOT
then i run rvm requirements as a normal user. Then I copy the requirements and close the session, open a root session and install the requirements using sudo
Then I close the session and open a normal user session and run rvm install ruby-1.9.3-p125 if you run this command as root, it will say that rvm is not installed and will suggest that you install it using sudo apt-get install rvm Don't do that!
So basically I had two problems, the tutorials that i followed didn't say that i should run
source /home/my-desktop-username/.rvm/scripts/rvm and didn't say that I should not run rvm as root, s.m told me that. Thanks to everyone, especially to s.m
That works well, but I will have to remember to
source .rvm/scripts/rvm
every time I open a terminal to work with Ruby on Rails.
Is there a way to permanently tell Ubuntu to look in .rvm for all the Ruby stuff?
You need to add your
source .rvm/scripts/rvm
into your $HOME/.bashrc file; read the advanced bash scripting guide for more.
I am trying to move to GVim(cream) as my primary editor on Ubuntu. I am using the wonderful rails.vim, however I also am using RVM.
Rvm works fine when doing things in a shell, and the ruby version I would like to use in rails.vim is the version set as default (but not the system version).
When I try to run things like
:Rgenerate migration migration_name
I get:
...
Missing Rails 2.3.8 gem.
...
If I try:
:!rvm use default
I get:
/bin/bash: rvm: command not found
Obviously cream/gvim is not using my .bashrc. What can I do to remedy this and get it working? Thanks.
Try running cream from the command line, if this solves the issue you can point your menu item to a script that opens cream in the context of a bash prompt.
This is because you are sourcing the rvm scripts in your .zshrc file. MacVim does not source the .zshrc file, but will source the .zshenv file.
Add following line to your .vimrc file.
set shell=/bin/sh
You probably have used .bash_profile to add RVM stuff to your bash environment. Alas, ~/.bash_profile won't normally be read by X startup scripts, as stated in Ubuntu Help
Use .profile or .bashrc. The .profile is only sourced by bash if .bash_profile is not there. I would use .bashrc.
rvm is a bash function, which changes bash environment. Seems like it is not supposed to be run from inside vim. You can't change the environment of an already-running program.
Try rvm gem list to make sure the rails gem is actually installed. rails (2.3.8) should be listed. If its not run rvm gem install rails.
I'm a vim user, and rvm + rails.vim works fine for me. Including your :Rgenerate example.
rvm is set on a per shell basis, so if you launch a new window or a new tab and you are using something other than your default interpreter and gemset you need to first
rvm gemset use my_rails238_gemset
and then
vim myshiz
Add this line to your ~/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
And make sure it comes before [ -z "$PS1" ] && return which stops sourcing the rest of the file if bash is not interactive.
And then add this to your ~/.profile:
export BASH_ENV=$HOME/.bashrc
With this line bash will now source $HOME/.bashrc when it is running non-interactively too.
Both GVim and shell scripts that you execute by double clicking should use RVM now.
Note: Only :! (ex: :!ruby, :!echo) commands will use RVM as commands like :ruby and :echo do not run bash and therefore do not source ~/.bashrc.
Running gvim from the command line doesn't work for me (in the sense that it's not acceptable).
When I am using a GUI application, I want to use it like a GUI, without a useless shell lingering in the background.
The 'set shell=' trick that works for Mac users doesn't work for me. Like you, I am using Ubuntu. Even setting the shell to /bin/bash doesn't do it.
The only thing I've gotten to work is this. First of all, install rvm.vim in addition to rails.vim.
Then, when you open gvim/cream, navigate to your project's root folder then type
:Rvm
This will cause rvm.vim to read your .ruby-version (or .rvmrc) file and initialize itself properly.
At this point,
:Rake
:Rgenerate
...and other rails.vim commands should work just fine.
Note that you can also pass arguments to :Rvm just as you would when running rvm from the shell.