I just installed rvm and then the bundler gem.
➜ ~ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.7.0]
➜ ~ gem list|grep bundler
bundler (1.0.12)
But when I try to run the bundle command then I got the following error:
➜ ~ which bundle
bundle not found
The interesting thing is that it works if I prepend "rvm ruby"
➜ ~ rvm ruby bundle
Still, I don't think like I should prepend rvm ruby before any command. Is this behavior correct?
EDIT: apparently the problem is that the default configuration is not remembered between shells.
If I type "rvm 1.8.7 --default" then it works, but as soon as I open a new shell it doesn't.
Run $ rvm use 1.8.7 and you should be good. The reason for this is that rvm will use the system ruby/gems unless you specify otherwise. You can verify this by running which ruby and checking the path.
You can set the default ruby with rvm as well, like so: $ rvm --default use 1.8.7.
My problem was that I had .rvm/bin on my path on .zshrc, which was causing all kind of troubles
This works for me :
rvm gemset list
rvm gemset use global
More details here : http://marcgrabanski.com/gem-management-with-rvm-and-bundler/
Related
$ ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ which ruby
/usr/local/rvm/rubies/ruby-2.7.2/bin/ruby
$ which gem
/usr/local/rvm/rubies/ruby-2.7.2/bin/gem
$ sudo gem install pg
ERROR: Error installing pg:
pg requires Ruby version >= 2.2.
Error installing pg, requires Ruby version >= 2.2 even if ruby is >=2.2.
When using RVM, it is necessary for some environment variables to be loaded to RVM (and RVM-installed Rubies) to find its code.
When running your gem install command with sudo however, sudo will reset your $PATH and unset the required environment variables before executing the gem command with the sanitized $PATH. With that, you will likely use your system ruby rather than your RVM-installed ruby.
In general, you should not use sudo to install Rubies or any gems when using RVM. Instead, you generally can and should just use your normal user.
If you do have to use sudo with RVM for some reason, there is a special rvmsudo command which retains your RVM environment in the evaluated context. See https://rvm.io/integration/sudo for details. However, as written above, you should try to avoid using this!
I have installed ruby 1.9.3 in my Ubuntu 12.04 machine following the instructions in https://github.com/postmodern/ruby-install and executing the following command:
sudo ruby-install ruby 1.9.3
I was assuming this would link from my /usr/bin or somewhere else visible from my path ruby or gem, but it doesn't. When I try for example: gem install bundler, I get:
sudo: gem: command not found
It also can't find ruby when I try ruby -v.
If I install with sudo apt-get install ruby1.9.3, I'm able to execute both ruby and gem:
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.11
I was expecting from ruby-install the same output I got from apt-get. Am I looking in the wrong place? How do I run ruby and gem after installing with ruby-install?
I know there are other installers for ruby like rvm and rbenv, but I'm following some installations instructions and they clearly instruct to use ruby-install.
Thanks in advance!
OK, found the answer.
After running
sudo ruby-install ruby 1.9.3
the last line from the log is:
>>> Successfully installed ruby 1.9.3-p547 into /opt/rubies/ruby-1.9.3-p547
Which I have no excuse for not paying attention to since it's in bold colourfull letters.
Erm, anyway, adding /opt/rubies/ruby-1.9.3-p547 to the PATH makes ruby and gem work.
export PATH=$PATH:/opt/rubies/ruby-1.9.3-p547/bin
I am using Bundler and Rbenv, with everything working fine. However if I use:
$ bundle show example
The path returned seems odd as it contains a reference to ruby 1.9.1:
/Users/me/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/fog-1.15.0
Is this normal? Why is 1.9.1 in the path?
1.9.1 is compatibility level for all 1.9.x rubies, it was the same for 1.9.1 and 1.9.2
probably ruby-gems version 1.9.1 within ruby 1.9.3
bundle exec ruby -v
bundle exec gem -v
I get an "rvm: command not found error" on rvm gemdir, but only when I'm using one of the rvm ruby installations. I get the same result with 1.9.2 and 1.8.7 (the only ones I've tried):
$ rvm install 1.8.7
...
Installation of rubygems completed successfully.
...
Install of ruby-1.8.7-p334 - #complete
# works ok using system ruby
$ rvm gemdir
/Library/Ruby/Gems/1.8
$ rvm use 1.8.7
Using /Users/aneil/.rvm/gems/ruby-1.8.7-p334
#
# HERE IS THE ERROR:
#
$ rvm gemdir
/Users/aneil/.rvm/scripts/gemsets: line 786: rvm: command not found
/Users/aneil/.rvm/gems/ruby-1.8.7-p334
$ rvm use system
Now using system ruby.
$ rvm gemdir
/Library/Ruby/Gems/1.8
Any ideas what's going on here? Should I be concerned?
Thanks.
try running
rvm get latest
from shell. addressed the issue for me.
reading around the various ruby install tutorials it's required to change path from /usr/bin/ruby to /usr/local/bin/ruby but i cant seem to be able to do it. Ultimately i want to install Ruby 1.9.2, should i uninstall 1.8.7 or what? i tried to install Ruby 1.9.2 with macports, the installation seemed to go ok, but i cant find the new version, i seem to be stuck with 1.8.7
iMac:~ rebel$ which ruby
/usr/bin/ruby
rebel$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
.profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
From your shell I notice you are on a Mac. If that's true, I recommend you to have a look to Homebrew. Then follow the instructions and install RVM for Ruby. With RVM you don't need to uninstall ruby, you can have several versions encapsulated in their own directory. You simply switch from one version to another according to your needs.
For example you can have ruby 1.9.2 with rails 3.0.1 in one setup and in another one you can have ruby 1.8.7 with rails 2.3.8...
In Mac, Homebrew with RVM is the easiest way...
Homebrew installation:
https://github.com/mxcl/homebrew/wiki/installation
Here is a nice screencast with RVM:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm