I personally prefer chruby and ruby-install to manage Ruby versions. I'm not sure why it didn't install 2.6.1, but I do recall in the past when I used RVM that it wouldn't always install the latest version. When you first installed RVM, it installed version 2.6.0. Similarly, the reason why RVM couldn't recognize that Ruby 2.6.1 had been installed by Homebrew is because RVM and Homebrew install Ruby in two separate places that don't know about each other. bash_profile is read, and anything defined there is used. Every time you open a new Terminal window or tab. bash_profile in your user's root directory ( ~/). To explain the command above, it takes everything between the single quotes and adds it ( >) to a file called. If you had run this command: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' > ~/.bash_profileĪnd then opened a new Terminal window or tab (or ran source ~/.bash_profile) for the changes to take effect, the Homebrew Ruby directory would have been first in your PATH, which means your computer would have looked for gem there first, and it would have used the Homebrew version of Ruby. This will tell you the location of the program where the computer first found it.Īnother command you can use to see if you're using the right Ruby version is: ruby -v If you want to know which version of a particular program is in use in the current Terminal session, you can use the which command. Since the Homebrew version of Ruby wasn't in your PATH, when you typed gem install, the computer looked for the program called gem in /usr/local/bin first and didn't find it, then it looked for it in /usr/bin and found it because that's where the system gem (the version of gem that comes with macOS) is installed. Admittedly, the message might not mean much to a beginner: If you need to have ruby first in your PATH run:Įcho 'export PATH="/usr/local/opt/ruby/bin:$PATH"' > ~/.bash_profile I know this because it's mentioned by Homebrew at the end of the Ruby installation. However, when you install Ruby with Homebrew, Ruby is installed in /usr/local/opt/ruby/bin, which doesn't get added to the PATH automatically. The list looks like this: /usr/bin:/bin:/usr/sbin:/sbinĭuring the Homebrew installation, a new directory /usr/local/bin gets created and added to the beginning of the PATH. By default, on a brand new macOS installation, I believe If you type echo $PATH in Terminal, you will see the list of directories, separated by a colon. The list of directories, and the order in which the computer looks them up is called the PATH. The reason why your Mac didn't automatically recognize the Ruby version installed by Homebrew is because by default, the computer only looks for executable programs in certain directories. First of all, nothing you say or do is going to sound stupid.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |