I want to install ruby 2.1.2 with rbenv on my computer.
I've installed Homebrew to accomplish this.
After doing brew install rbenv
I get the following messages, of which I don't understand much:
To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=/usr/local/var/rbenv
To enable shims and autocompletion add to your profile:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
==> Summary
🍺 /usr/local/Cellar/rbenv/0.4.0: 31 files, 152K, built in 3 seconds
What does the above mean and what should I do..?
Your profile is a file called .profile inside your home directory, e.g. /Users/youruser/.profile. Create that file in a text editor, and paste those two lines into it. The commands in that file will be executed when you open a new terminal window.
I think it means that if you want to use a global directory for settings etc. instead of a local user-specific directory (i.e. YOUR_HOME/.rbenv), you can add the first line to your profile file.
Moreover, if you want to enable autocompletion for commands etc, you can do the same with the second line.
I'm not sure, but I think that if you use Bash (the mac os x default), your profile file is in your home directory, named .bash_profile
Related
I am trying to resolve this issue and trying to get it work. What are all the steps of the solution? I really don't know what to do on my Mac terminal
-bash: emacs.profile: command not found
What are you trying to accomplish? If you're trying to open a file named .profile with emacs you'll want to add a space between the command emacs and the file .profile:
$ emacs .profile
If you are typing emacs.profile you will get an error because you are mixing together the command emacs and the file you are trying to edit: .profile. Therefore the solution would be to add a space between them like someone suggested: $ emacs .profile.
On the other hand, if you are typing emacs .profile and you are still getting: -bash: emacs: command not found, this means that you haven't installed emacs yet and your system doesn't recognize that instruction.
Emacs is a very popular text editor and is widely used by technical users, but it is not installed by default.
Solution 1:
If you want to edit a file (in this case ~/.profile) you don't need emacs to do so, you could just use a normal text editor or a pre-installed text editor using your terminal like:
$ vi ~/.profile or $ nano ~/.profile
(Guide to use Vi/Vim text editors) (Guide to use Nano).
Solution 2:
If you want to install emacs to edit that file, you can do so using brew:
$ brew update
$ brew install emacs
And after that you can use:
$ emacs ~/.profile
You can find other ways to install emacs here.
Important Note:
One important thing to consider in this example, is that if you are trying to edit the .profile file (i.e. to set an exported environment variable) you should know that the name of the .profile file might vary from one Mac system to another. The name of this profile configuration file depends on the shell of your system, if you are using bash the name of this profile will be .bashrc or .bash_profile.
Before editing your profile file make sure what is the name of the profile file you are trying to edit. To do so, you can use:
$ cd $HOME
to go to the Home folder and then use:
$ ls -al
to see hidden files (These files starting with . are hidden files). You will find the profile file of your system there.
Long story made short, I am trying to issue myself an SSL certificate using LetsEncrypt, and have recently installed rbenv to make this process easier. After installing rbenv, I check to see if everything checks out using
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
I than get this message saying that there are no versions of ruby installed. After trying to install ruby using the command
"rbenv install 2.3.1"
I get this error
rbenv: no such command `install'
Is it because the path to my rbenv shims aren't in my PATH variable ? If this is the case how do I add directories to my PATH variable ? I know you have to add them to your bash_profile file, but am not sure where in this file I need to add something, and what I need to add.
~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
function letsencrypt_webfaction {
PATH=$PATH:$GEM_HOME/bin GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib ruby2.2 $HOME/.letsencrypt_webfaction/gems/bin/letsencrypt_webfaction $*
}
eval "$(rbenv init -)"
PATH=$PATH:$HOME/bin
export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
Always be careful when editing the profile.
Better make a backup first
switch to home directory:
cd
list hiden files:
ls -la .bash*
make a backup copy of .bash_profile:
cp -p .bash_profile .bash_profile.bak
check the current PATH: echo $PATH
check if ruby is in the PATH: which ruby
check the ruby version: ruby --version
I am not sure where this function is comming from in your .bash_profile: function letsencrypt_webfaction()
Use : as a separator and add a new directory new_dir to your PATH, use $PATH to keep the contents of the actual PATH, then export the new PATH:
PATH=$PATH:/new_dir:/new_lib
export PATH
Verify if the PATH is what you need from the terminal: echo $PATH
Personaly I sugest making a backup of .bash_profile as it is. Comment out with # the 3 lines for the function and the others where the PATH appears and add this:
export RUBYLIB=$HOME/lib
export GEM_HOME=$HOME/gems
export PATH=$HOME/bin:$PATH:
After this please check the bulet points above and see if you have the ruby version you expect.
According to the documentation you should install the ruby-build plugin:
The rbenv install command doesn't ship with rbenv out of the box,
but is provided by the ruby-build project.
When running this in terminal:
$ curl -L https://get.rvm.io | bash -s
It seems to work fine, but in the Upgrade Notes at the end it says
* WARNING: You have '~/.profile' file, you might want to load it,
to do that add the following line to '/Users/steven/.bash_profile':
source ~/.profile
And I can't use RVM, getting the error
-bash: rvm: command not found'
I am pretty new to terminal and Ruby, so any help would be greatly appreciated.
When you install rvm its paths get added to ~/.bash_profile. RVM will warn you about this during installation as you noticed. You could run source ~/.profile each time you load the terminal, but that's a pain in the neck.
From the bash docs:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
What this means is that /.bash_profile is being run, and /.profile and /.bashrc are being ignored.
To resolve this just open .bash_profile and copy the rvm paths at the top and paste them at the top of your .bashrc file. Open a new terminal window and it should be working just fine.
You can either delete .bash_profile, if it's empty, or copy and paste the contents of ~/.profile into it if you choose to keep it.
Do as the instruction said.
From the RVM Troubleshooting page.
If your .bash_profile isn't being correctly loaded on OSX, you need to do one of three things:
Create a file named ~/.bash_profile and add the RVM source line there
Add the RVM source line to ~/.profile
In your terminal preferences, change the shell from the default of /usr/bin/login to /bin/bash.
So, check if you have /Users/steven/.bash_profile in your system. If it is present, open the file and add that line at end of file:
source ~/.profile
else create the file and add it.
Goal: install Ruby 2.0.0
Brew Doctor says:
Warning: "config" scripts exist outside your system or Homebrew directories. `./configure`
scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config
I found the answer here: Brew doctor gives out warnings but don't know how because he didn't tell us how to do it
I need to remove /opt/sm/pkg/active/bin/ from my path.
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
but when I open my file
touch ~/.bash_profile; open ~/.bash_profile
I get:
export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
##
# Your previous /Users/john/.bash_profile file was backed up as /Users/john/.bash_profile.macports-saved_2013-06-06_at_14:30:25
##
# MacPorts Installer addition on 2013-06-06_at_14:30:25: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Notice the path I'm trying to remove is not in the file, but it's in my path. What do I do??
The /opt/sm is in the /etc/profile.d directory. Open it by entering
cd /etc/profile.d
in terminal and then
open .
Open sm.sh file in text editor and then
change
PATH="${PATH}:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin"
to
#PATH="${PATH}:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin"
and then quit and relaunch Terminal. Run brew doctor 'Warning' should be gone.
It seems that "sm" comes from RailsInstaller, at least in my case. Following the approach in this post, I commented out the line in /etc/profile.d/sm.sh and restarted Terminal. This solved the above brew doctor errors.
I'm following a tutorial called Starting a Django 1.4 Project the Right Way, which gives directions on how to use virtualenv and virtualenvwrapper, among other things.
There's a section that reads:
If you're using pip to install packages (and I can't see why you wouldn't), you can get both virtualenv and virtualenvwrapper by simply installing the latter.
$ pip install virtualenvwrapper
After it's installed, add the following lines to your shell's start-up file (.zshrc, .bashrc, .profile, etc).
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/directory-you-do-development-in
source /usr/local/bin/virtualenvwrapper.sh
Reload your start up file (e.g. source .zshrc) and you're ready to go.
I am running Mac OSX, and don't know my way around the Terminal too well. What exactly does the author mean by shell's start-up file (.zshrc, .bashrc, .profile, etc)? Where do I find this file, so that I can add those three lines?
Also, what does he mean by reload your start up file (e.g. source .zshrc)?
I would appreciate a detailed response, specific to OSX.
You're probably using bash so just add these 3 lines to ~/.bash_profile:
$ cat >> ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/directory-you-do-development-in
source /usr/local/bin/virtualenvwrapper.sh
^D
where ^D means you type Control+D (EOF).
Then either close your terminal window and open a new one, or you can "reload" your .bash_profile like this:
$ source ~/.bash_profile
If you use bash, it usually means ~/.bash_profile.
In Terminal and iTerm new shells are login shells by default, so ~/.bashrc is not read at all. If instructions written for some other platform tell you to add something to .bashrc, you often have to add it to .bash_profile instead.
If both ~/.profile and ~/.bash_profile exist, only .bash_profile is read. .profile is also read by other shells, but many of the things you'd add to .bash_profile wouldn't work with them.
From /usr/share/doc/bash/bash.html:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
[...]
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
I have Anaconda install, so I add these 3 lines to ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Documents/Python
source /Users/Username/anaconda3/bin/virtualenvwrapper.sh
and then reload profile by:
$ source ~/.bash_profile
I use an approach that I think is easy to maintain.
It also works well if you sometimes use Ubuntu systems, however I will be sure to address the OP's OSX requirement in my answer.
Create a .aliases file with your alias(es) in your home directory, e.g. ~/.aliases
Execute this file from your .bashrc file (this is executed each time for a new shell process) with source ~/.aliases. This is all you would actually need to do for Ubuntu btw.
On OSX call .bashrc from your ~/.profile file, i.e. have ~/.bash_profile contain: source ~/.bashrc