Установка Ruby и gem через RVM на Mac OS
Официальный сайт
Процесс установки Ruby на Mac OS через систему управления пакетами RVM.
Введение
Минус вышеуказанной установки в том, что Ruby и его гемы будут установлены в рут директорию. В этом нет ничего плохого, если всё делать правильно.
А можно пойти другим путём и установить Ruby и gem-ы, не затрагивая основную версию. Для этого на Mac OS есть сторонние инструменты вроде rbenv и RVM (Ruby Version Manager). На последнем и остановимся.
Установка RVM (система управления пакетами)
Вариант 1
При этой команде может возникнуть ошибка:
Ругается на отсутствие GnuPG. По умолчанию в маке он не установлен. Можно его установить через Homebrew:
А затем заново повторить команду.
Вариант 2
Без дополнительных установок, инсталлируем через curl:
В конце установки появится надпись, которая сообщает, что делать дальше:
Команда установит RVM для текущего пользователя:
На этом установка менеджера для Ruby завершена.
Установка Ruby с помощью RVM
Посмотрим какие версии руби можно установить:
На само деле, указываются не все версии. Самые последние могут не показываться. Можно загуглить последнюю стабильную сборку и указать её версию в установке.
Устанавливаем последнюю версию руби:
Не пугаемся надписи, всё нормально:
Установка занимает несколько минут. Полный процесс установки:
Для выбора версии Ruby, которая будет использоваться по умолчанию, используется команда:
Можно вернуться к использованию системной версии ruby
Для каждой из версии руби можно установить отдельный набор гемов (gemset).
Создаём gemset который назовём work:
Можно посмотреть все созданные «наборы гемов»:
Применить «набор сетов» по умолчанию:
Установка gems в Ruby на RVM
Если после установки гемов ничего не работает, можно попробовать установить через sudo.
Устанавливаем гем компосса:
Устанавливаем дополнительные любые другие гемы, например:
Удаляем гем из набора гемов:
где listen — название гема
Чистка и удаление RVM
Удалить определенную версию Ruby:
Чтобы удалить «набор гемов» (gemset):
Посмотреть все установленные версии ruby:
Полностью удалить RVM:
Настройка в PhpStorm
По умолчанию compass в маке находится по такому пути:
Однако мы установили в другую директорию, поэтому меняем путь на другой:
Также настраиваем под себя Arguments:
Заключение
- Установили систему управления пакетами для Ruby
- Установили нужную нам версию руби в директорию текущего юзера
- Добавили туда необходимые гемы
- Настроили compass в PhpStorm
Возможные ошибки
Это может означать, что в шторме, в настройках File Watchers указан неправильный путь.
/Users/Dream/.rvm/gems/ruby-2.5.3@test/wrappers/compass compile /Users/.
LoadError on line [«59»] of /Users/Dream/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb: cannot load such file — autoprefixer-rails
Run with —trace to see the full backtrace
Process finished with exit code 1
Не хватает определенного гема. В данном случае ругается на отсутствие autoprefixer-rails. Как установить недостающие гемы указано выше.
English Query (запросы по теме на английском языке)
How to resolve error during RVM – gpg command not found
Читайте также
Если вам пригодилась информация, вы можете поблагодарить автора сайта символическим пожертвованием:
rvm command not found
I installed rvm with rails, from the official website of RVM, I specified the command suggested by the tutorial. When the installation my system has rails 4.0.0, rvm 01/23/12, ruby 2.0.0, bundler gem 1.3.5 and 2.0.3 But I need to install ruby 1.9 to practice with a course that I am currently doing. «Rails for Zombies 2» I try to execute the instruction rvm install 1.9.3 and the console returns this message: rvm: command not found
1 Answer 1
Your problem is that RVM is not loaded when you open a new terminal.
To solve this, run this command line: (if using login-shell)
Or this (if using non-login shell):
This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).
/.bash_profile then it works for me after above command to update on system – sunil May 9 ’18 at 8:48
How to resolve “gpg: command not found” error during RVM installation?
I have a new mac pro (OS X 10.9.5) that I get to set up from scratch. I want to install RVM and the first thing it says to do is:
Install mpapis public key (might need gpg2 and or sudo )
When I tried I got:
I’ve tried to find a good guide on how to overcome this that also looks trustworthy but I’ve had no luck.
Can someone explain what gpg is, why I dont already have it, and how do I get it the right way.
4 Answers 4
GnuPG (with binary name gpg ) is an application used for public key encryption using the OpenPGP protocol, but also verification of signatures (cryptographic signatures, that also can validate the publisher if used correctly). To some extend, you could say it’s for OpenPGP what OpenSSL is for X.509 and TLS.
Unlike most Linux distributions (which make heavy use of GnuPG for ensuring untampered software within their package repositories), Mac OS X does not bring GnuPG with the operating system, so you have to install it on your own.
Possible sources are:
- Package manager Homebrew: brew install gnupg gnupg2
- Package manager MacPorts: sudo port install gnupg gnupg2
- Install from GPGTools, which also brings GUI applications and integration in Apple Mail
RVM installed by Ruby not working?
I installed RVM using the single instruction mentioned at the RVM website (using git).
Then I installed Ruby version 1.9.2 and 1.8.7 using:
However, I cannot find the Ruby binary. When I try to execute the command, I get the following error:
Here is the output of rvm info :
10 Answers 10
RVM requires a minor addition to your
/.bash_profile to initialize it when you log-in. It is specified in the installation docs in the Post Install section. Did you do that?
Per your rvm info output, it looks like you haven’t completed your installation. All the entries in the output should have corresponding values. So, I suspect you haven’t added:
/.bash_profile and then started a new session.
If you are doing a «Multi-User» installation then you’ll need to do a lot more. Have you modified /etc/profile , or, if you are using Bash as your shell, have you modified /etc/bash.bashrc to include:
and started a new shell?
Personally I don’t like the multi-user install as much as the single-user install, and don’t recommend it but your mileage might vary.
As a FYI: In a discussion with the RVM maintainers on IRC last year, they told me they do not recommend the system-wide installation, and instead recommend the local «single-user» installation, even for servers.
/.bash_profile and restart your terminal session. It’s all covered nicely in the RVM docs. Try rvm help and read about implode . – the Tin Man Apr 7 ’11 at 14:58
/.bash_profile is exactly the line you’ve said should be added. Still every time I open a shell, the rvm info returns the same output as in the question and the ruby command doesn’t work. I did a single-user install. What else could be wrong? – Slavo Sep 6 ’11 at 19:25
I installed Ruby on Rails on a Ubuntu 11.10 VM, using «HOW TO INSTALL RUBY ON RAILS IN UBUNTU 11.10».
After installing it, I was running into the same issue. The only thing that seems to be missing from the tutorial in my opinion, is the following command:
Although Ruby is properly installed, RVM seems to redefine in each session Ruby is to be used. The problem was that the default Ruby pointed to the «system ruby», and, in my case, this one pointed to nowhere and made the call rvm info return a result similar to the initial post.
To solve this issue, one of the follwings commands must be used:
or (valid only for the current session)
Before I could start the server, I also came across «ExecJS and could not find a JavaScript runtime». As proposed in several answers, I solved it by adding the following lines to the Gemfile.
and running bundle install afterwards.
I had similar problem (using Ubuntu 13.10) to solve it
I had ran in the same issue. I just executed the command:
Here is how to fix undetected Rubies inside RVM.
First, I did a sanity check to make sure that very thing looks great, then ran
which did the job. It comes down to this command:
Are you making sure to source /usr/local/lib/rvm? echo ‘source /usr/local/lib/rvm’ >>
/.bashrc and relog via SSH/start a new instance of Bash.
To clarify, since there is some confusion: there are two ways to install RVM: a «per user» install, and a «system wide» install.
For most day-to-day use, you want to use a «per user» install, which installs RVM into
/.rvm . System-wide installs are good for servers, where one set of Rubies should be used. The default location for RVM in this case is /usr/local/rvm .
Based on your question, it appears you’ve installed RVM as a system-wide install.
To use RVM, it must be initialized by running a script each time you log in. To do this easily, you include the file in your
/.bash_profile if you’re on OS X), so that it is automatically run each time you log in. For a per user install, add the following text to the file:
for system wide installs, use this text instead:
If you do indeed have a system-wide install, you will also need to make sure you are a member of the rvm group; type the following to do so:
Once you have made the necessary changes, log out of your session and then log back in. Once you have done so, rvm use 1.9.2 should set a bunch of environment variables, which you can see by typing rvm info . If all is well, ruby should execute correctly.