Bundler and Rbenv Gem Path - ruby

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

Related

Rvm version error

I have installed many flavors of ruby on rvm, and using following command to change rvm ruby versions.
rvm use 1.9.3
then ruby -v gives me following result
ruby 1.9.3p551 (2014-11-13 revision 48407) [i686-linux]
but when i try to run any commands like rails s or bundle install
it gives me following error
Your Ruby version is 2.3.1, but your Gemfile specified 1.9.3
Using
rvm list
you can get list of ruby version on your system along with current & default versions.
If ruby version is not specified in Gemfile, then it is generally considering default rvm version.
But if it is specified in Gemfile, then that version of ruby should be installed in your system along with its bundler.
First make sure ruby version either installing or using it,
rvm install '1.9.3'
rvm use '1.9.3'
To install bundle of required ruby version, run this command
gem install bundler
That's can happens, when you trying to use fresh installed ruby without bundler, all newest installed ruby should also include bundler installation.
$> rvm use 1.9.3 && gem install bundler # may terminal reload needed
$> bundle install
$> bundle exec rails s

Installing Ruby 2.2.3 on Ubuntu

This problem probably has an obvious answer to anyone who has used Ruby on linux for a long time, but I can't really get a good answer via Google.
I'm trying to check out the Rails 5 beta, which requires Ruby 2.2.2 or greater. I've installed the RVM (Ruby Version Manager) and set my ruby version to 2.2.3. Running rvm list in the terminal results in the following output:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Okay, great. I have Ruby 2.2.3 installed. Let's try bundle update:
Installing rack 2.0.0.alpha (was 1.6.4)
Gem::InstallError: rack requires Ruby version >= 2.2.2.
Okay, that's weird. What version of ruby do I have? Running ruby -v gives me this:
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
So... do I have 2.2.3 or not? What gives?
Since you are using bundle, I would suggest you to check your Gemfile for ruby version. You can also test it with bundle exec ruby -v
Also try:
rvm use ruby-2.2.3
bundle exec ruby -v
Maybe by setting the default Ruby version on rvm to the one you have (ruby-2.2.3) solves the problem, by doing rvm --default use ruby-2.2.3. Then reload the bash and execute ruby -v to check if the default version of Ruby was changed properly and then try again to execute the bundle install command.
If you don't know zsh and oh-my-zsh, I highly recommend for this kind of things. You could configure the terminal in order to show you the current version of Ruby and Rails that you're using every moment. Check it here: http://ohmyz.sh/
In addition to doing rvm use --default 2.2.3 or rvm use 2.2.3 make sure that you don't have the ruby package from apt (or whatever package manager) still installed. For some reason, that ruby package could take precedence over an RVM Ruby.
Also, try doing rvm uninstall 2.1.5 to force your system to default to 2.2.3... You can always reinstall 2.1.5 later and, if this issue persists, 2.2.3 should stick as your default.

Installing gems to which Ruby with rbenv

How does one control which Ruby a gem is installed to using rbenv? Or could there be a central place accessible to all Rubies? I am just running Ruby scripts not Rails. rbenv-gemset seems to be for that?
The gem is installed into whatever your currently selected Ruby is. E.g.
rbenv shell 2.0.0-p247
gem install bundler # bundler is installed for Ruby 2.0.0-p247 only
rbenv shell 1.9.3-p447
gem install bundler # bundler is installed for Ruby 1.9.3-p447 only
Just to add on: rbenv-gemset would be for organizing your gems within the same ruby version. Only rbenv controls which ruby you install your gems to...

gem install rails does not work

I am working on ubuntu and rvm. In any case I tried to use sudo gem (any command) it does not recognize gem as command. In addition if I use gem seperately as:
gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: Possible alternatives: rails
I got that error. I cannot see the reason.
rvm version 1.10.3
ruby version 1.8.7
gem version 1.6.7
What is the possible reason behind this?
Re-install all rvm and ruby and the gems, solved my problem.

How do you update rubygems using rvm and ree?

How do you update rubygems under rvm when ree is your default vm (on Snow Leopard)? I am doing:
$ rvm ree gem update --system
This results in things looking like everything went fine:
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.7
Updating RubyGems to 1.3.7
Installing RubyGems 1.3.7
RubyGems 1.3.7 installed
[...]
RubyGems installed the following executables:
/Users/douglassellers/.rvm/rubies/ree-1.8.7-2010.02/bin/gem
but when I run gem --version it still says 1.3.5. Doing a which gem points at ree version of gem.
Anyone know how to get rubygems to update with RVM?
Now you can just do :
rvm rubygems latest
Or you can define which rubygems you really want. https://rvm.io/rubies/rubygems/
The problem, I think, is the initial command (or what you expect that command to do):
$ rvm ree gem update --system
That tells rvm to pass the gem update --system to the gem under ree, but it doesn't switch you to that particular Ruby interpreter. You continue using whatever interpreter you have set in that shell (whether by default or because you switched manually earlier in the shell session).
As an example, my default interpreter is Ruby 1.9.2. If I pass this command: rvm 1.9.1 gem install pony, then the Pony gem is installed for Ruby 1.9.1. However, I'm still using Ruby 1.9.2 after that installation is finished. If I enter irb and try require 'pony', I get a load error. If I run rvm 1.9.1 and then enter irb, Pony is installed and loads fine.
So as Brian says in his comment to your post, you could switch manually with rvm use ree. Alternatively, you could switch your initial command to this:
$ rvm ree
$ gem update --system
$ gem --version
rvm suggested me to use something like this:
rvm ruby-1.9.3-p327#mygemset do gem update --system
It is an unusual problem.
If it is not yet resolved, consider using
rvm --default use ree
which ruby
which gem
this should show you if you are in the right version.
install gems either using rvm or directly.

Resources