Rails 4.0.8 Bundle Install keeps poiting to the wrong Ruby version - rvm

I'm working through the Railstutorial with Rails 4.0.8. and Ruby 2.1.2. Recently Bundle Install, Rails Console and Rails Server seem to ALWAYS choose the alternate version of Ruby from whichever is specify in my Gemfile. When I enter ruby -v it also always suggests the OTHER version.
Is this a bash_profile problem and how can I set it to permanently leave the internal OS X Ruby (v2.0.0) alone and just use v 2.1.2 where all my gems are installed?
I'm using rvm and Homebrew... I suspect both may be adding to the confusion...
Any helpful tips?
First...
micanansmbp:sample_app micanan$ rails console
Your Ruby version is 2.1.2, but your Gemfile specified 2.0.0
Then...
micanansmbp:sample_app micanan$ bundle install
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
Finally...
micanansmbp:sample_app micanan$ bundle install
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
micanansmbp:sample_app micanan$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
micanansmbp:sample_app micanan$

Related

Can't remove bundler in RVM

I have 1.9.2 Ruby installed in RVM. When I do a gem list I get this:
bundler (1.1.3)
When I try to remove it I get:
gem uninstall bundler
INFO: gem "bundler" is not installed
When I try to run bundle install for my app I get:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.1) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
I have tried uninstalling 1.9.2 but that did not help.
Found the answer in another Stack thread but closed it without noting the link. The issue is that rvm will not let you uninstall gems from a custom gemset that are still a part of the default "global" gemset. Do a rvm gemset use global then uninstall 1.1.3 from global.
Running 'sudo gem uninstall' did the trick for me. It seems that 'gem uninstall' will sometimes "lie" when not running as sudo.

Can RVM hide a gem from the global gemset?

The project I'm about to work on asks for version 1.0.10 of bundler and version 0.8.7 of rake. My global gemset has slightly newer versions of these gems. I.e., the install instructions for the new project look like this:
rvm gemset use rails3
gem uninstall -x bundler
gem install bundler -v 1.0.10
gem uninstall -x rake
gem install rake -v 0.8.7 # Rake needs to be at 0.8.7
What happens is that when I'm in this new rails3 gemset I can't uninstall the existing gems (and personally I don't want to) because they exist in the global gemset.
So, question: can I somehow hide those two gems that exist in the global gemset?
I can list the gems:
$ gem list
*** LOCAL GEMS ***
addressable (2.2.6)
archive-tar-minitar (0.5.2)
awesome_print (1.0.1)
bundler (1.0.21, 1.0.10)
...
rake (0.9.2.2, 0.8.7)
...
Maybe an ancillary question would be: since I have installed the older versions into the the rails3 gemset, will rvm prefer those because the fact they were specifically installed somehow overrides the version in global, or will rvm take the gems with the highest version number?
any command except bundle should be prefixed with bundle exec and this will assure proper version of gem is used (using Gemfile)
you can avoid writing always bundle exec by using my gem rubygems-bundler
for running bundle command - rubygems will select latest available version if you do not specify one ex. bundle _1.0.10_ exec rake db:create

Rails 3 and mongoid setup

I'm trying to follow the Railscasts on mongoid
http://railscasts.com/episodes/238-mongoid
When I install the mongoid and bson_ext gem it seems fine, but each time that I run a rails command, like:
rails g scaffold article name:string content:text
I get a warning in the console:
Able to load bson_ext version 1.3.1, but >= 1.4.1 is required.
But I can't find a bson_ext 1.4.1, current version seems to be 1.3.1 in the rubygems directory.
Is there an other step that I missed?
Finally found the answer to that bson 1.4 mistery
http://rubygems.org/gems/bson/versions/1.4.1-jruby
need to be installed with the -v flag
gem install bson -v 1.4.1
Default bson is 1.3, and ~> 1.4 has been pulled out from gems repo. Need to be download and installed manually. But they recommend to wait for 1.4.2 .
Issue is referenced here too:
Bundler: "Could not find bson-1.4.0 in any of the sources"
You need to run
gem update bson_ext

Mac OS X Leopard showing different version of Rails after install

so I'm installing rails with
gem install rails
and I didn't have any version of rails prior to the one I'm installing (3.0.9).
By the time the installation finishes I get the documentation error
Installing ri documentation for rails-3.0.9...
file 'lib' not found
Installing RDoc documentation for rails-3.0.9...
Even though it says that rails 3.0.9 was installed successfully.
If I run
gem list rails
it shows me version 3.0.9, but when I run
rails -v
it shows me version 2.3.5 ( I don't know here that came from ).
See: http://cl.ly/353h1o1b3y3T260L3F3p
Any help please?
If you don't really care, just remove rails 2.3.5 with gem uninstall rails and chose the appropriate one when it asks you which.

Problems with installing mail gem for Rails 3

I'm trying to install rails 3.0.7 on Mac OSX. I'm using rvm and I've got ruby 1.9.2p180 installed.
When I run
gem install rails --version 3.0.7
It seems to work fine, until it gets to the mail gem.
Fetching: mail-2.2.17.gem (100%)
ERROR: While executing gem ... (Zlib::DataError)
invalid block type
The installer them stops and rails is not installed. How do I get around this?
Update: Since I asked this question the mail gem has been updated to 2.2.19, and this seems to have solved the problem.
I just replicated your env (MacOS, ruby 1.9.2) and rails installed fine, along with the mail gem (2.2.17).
Perhaps try again? Maybe the package that was fetched was temporarily corrupt. You can also run gem with the verbose flag to see more info:
gem install rails -V --version 3.0.7