How do I load rvm automatically? - ruby-on-rails

Every time I load a new terminal I need to run this:
source /usr/share/rvm/scripts/rvm
to load rvm
What do I have to do so that I don't have to run the command every time?

On linux, or mac put it to the .bashrc:
echo "source /usr/share/rvm/scripts/rvm" >> ~/.bashrc
On windows you preuse cygwin, and do the same thing inside its terminal.
In case you are using zsh do it for its config .zshrc:
echo "source /usr/share/rvm/scripts/rvm" >> ~/.zshrc

Related

Have to reset $PATH on Bash on Ubuntu on Windows Linux Subsystem

I am new to Linux Subsystem. I am trying to use a package in miniconda. Now after installing miniconda in order for it to work you need add the path like this:
export PATH=~/miniconda/bin:$PATH
I do this and the conda works. I exit the terminal and when I come back and look at my $PATH (using echo $PATH) I see is reset and I have to do it again. What should do for it to stick?
Set and export the PATH variable in your .bashrc file
vi ~/.bashrc

The command could not be located because '/snap/bin' is not included in the PATH environment variable

when i try to run git-all-secrets i got Dockerfile: command not found
and this is the command include correct information
here is an example of the issue
root#momo22:/home/momo/git-all-secrets# docker run -it abhartiya/tools_gitallsecrets -token=9a8b60a10cf683f238e05 -org=bugcrwod
Command 'docker' is available in '/snap/bin/docker'
The command could not be located because '/snap/bin' is not included in the PATH environment variable.
docker: command not found
root#momo22:/home/momo/git-all-secrets#
Temporary solution:
Run the command export PATH=$PATH:/snap/bin
Permanent solution:
Edit /etc/environment and add /snap/bin in the list then restart your system.
Links
answer for similar error with same fix
More info on /etc/enviroment
you can add the path into .bashrc file
$ echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc
open new terminal or execute this command
$ source ~/.bashrc
To fix this issue do the following:
Open the file /etc/environment.
Add /snap/bin to the end of the PATH Variable and concatenate using the : character.
Example lets assume we had the PATH variable in the file was: Path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
After your update this will look like: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/snap/bin
Finally to update your shell and have the PATH variable ready to use, run source /etc/environment
Done
If you come here and are just on Ubuntu rather than docker and you have just installed snapd without logging out/in again, log out then in again - you don't need to modify any files.
Open the ~/.bashrc with nano or vim => vim ~/.bashrc
add export PATH=$PATH:/snap/bin at the end of the file
log out from your user and log in again or reboot
if ~/.bashrc doesn't exist:
create ~/.bashrc file and open it => touch ~/.bashrc && vim ~/.bashrc
add PATH=$PATH:/snap/bin
logout from your user and login again or reboot
if you don't want to logout or reboot run these commands:
sudo su ${USER}
bash
open ~/.bash_profile
add export PATH=$PATH:/snap/bin and save the changes
run source ~/.bash_profile
you can open ~/.bash_profile with vi or gedit

Editing the ~/.zshrc file

I'm a complete newbie, so I think I'm just missing a step, but have no idea.
I'm following tutorials for Rails. Lots of steps say, "and then editing the ~/.zshrc file." but I don't have any ~/.zshrc file. I'm looking at the folders in Sublime. Also none of the following ~/.zprofile, ~/.zlogin, ~/.zlogout exist. Though, under my home files, there is .zprezto folder. No zshenv either...
Do I just create the files? Seems like they should be downloaded from somewhere. I'm using Terminal with OS X. So lost.
echo 'write whatever' >.zshrc
Thanks in advance!
You will get ~/.zshrc file only when you use zsh shell on your Mac OS. If you're not sure which shell you're using, open terminal and issue the following command.
echo $SHELL
if you get response like /bin/zsh then you're using zsh shell on your Mac. You can edit ~/.zshrc file using vim editor on your Mac which is the default for Mac OS.
to open ~/.zshrc file using vim editor, issue the following command on your terminal.
vim ~/.zshrc
Then you can do any configurations you need. Or else you can use open -t .zshrc command to open ~/.zshrc file from your general TextEdit on Mac OS.
$ open ~/.zshrc
Make changes in the .zshrc file window that opens
Save file
$ source ~/.zshrc
The .zshrc file is used to configure your terminal prompt if you're using zsh (z-shell) login shell (n.b., a "login shell" is the command line presented to you when running the terminal application). If you're using a standard OSX terminal, then you're probably using bash (the BASH Shell), so editing .zshrc wouldn't affect anything. Bash uses .bashrc and .bash_profile` for it's configuration. These file are run overtime you open terminal window and setup things the command aliases, setup your prompt and maybe run scripts to initial other programs.
You almost certainly don't need to edit terminal config files to develop with Ruby on Rails, especially as editing these files incorrectly can mess up your system, or at least make it hard to return the system to a stable state.
I usually use the vi(vim) editor to edit the .zshrc file.
1)To open ~/.zshrc
vi .zshrc
or
vi ~/.zshrc
or
You can open the file in VsCode, and it would be easier to edit it.
code .zshrc
2)To update the edited .zshrc file:
source ~/.zshrc
or
source .zshrc
If you are using zsh shell , run the below lines in the terminal:
echo 'setopt PROMPT_CR' >.zshrc
echo 'setopt PROMPT_SP' >.zshrc
echo 'export PROMPT_EOL_MARK=""' >.zshrc
You can edit zshenv instead of zshrc for appending PATH . Please check whether file already exists
cat ~/.zshevn
You can edit file using below command
vi ~/.zshenv
You can refer this to see how to add an entry in PATH

Rubymine 6.3.2 doesn't find environment variables on Ubuntu 13.10

I'm trying to execute a bundle install via RubyMine but I'm receiving the following error message:
Error Message:
Set the environment variable ORACLE_HOME if Oracle Full Client.
Append the path of Oracle client libraries to LD_LIBRARY_PATH if Oracle Instant Client.
I'm using Oracle Instant Client and my ~/.bash_profile contains this:
[[ -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*
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
I have no issues when I try bundle install via terminal. I suspect that Rubymine is not loading the same environment variables that the terminal app loads when it starts.
run RubyMine, go to Tools -> Create Command-Line Launcher, it should create a /usr/local/bin/mine file.
Edit your RubyMine launcher in Ubuntu, and make it execute bash -ic '/usr/local/bin/mine' (the -i is for an interactive shell)
That will launch RubyMine after loading your profile files (.profile, .bashrc ...)
Sounds like you're running RubyMine from your desktop manager and none of the parents of the desktop manager run your ~/.bash_profile. Fixing that would be an Ubuntu question.
But you could
find the RubyMine executable on disk and run RubyMine by typing the full path of the executable in a terminal (and you could make an alias), or
run RubyMine, go to Tools -> Create Command-Line Launcher, and use the launcher that it creates.

Automatically Run Command Upon Opening Terminal (Linux Mint 16)

I am using Rails and for some reason unbeknownst to me I have to execute the following line every time I start the terminal in order to use ruby and rails.
source ~/.bash_profile
If I type the following before running the above command, it will recommend that I install the packages (ie "type 'sudo apt-get install package' to install")
rails -v && ruby -v && irb -v
Is there a way to make my terminal execute a command upon opening? Or, better yet, can anybody help explain the reason I have to run this line? I found an article that said I had to do that given my issue but it didn't explain why.
Assuming you're using the bash shell, then ~/.bash_profile will be sourced once (and only once) when you log in to the system but not each time you open a terminal window.
The ~/.bashrc, however, will be sourced every time a new shell is opened (i.e. when you open a terminal window).
So they are probably some environment variables settings in ~/.bash_profile which are required for ruby to run. Those settings should be moved to the ~/.bashrc file instead so they are defined in all shell instances.
Alternatively, source ~/.bash_profile from your ~/.bashrc (this is at your own risk, it may have side-effects).

Resources