omniauth requires Ruby version >= 2.1.9. issue while installing gem file - ruby-on-rails

Got an error after typing "bundle install" with some sort of issue with the Ruby version. Have been installed many-many gems so far and never got incompabilities with the Ruby version.
What's the best way to upgrade the Ruby version to get back on track with the "bundle install" without putting the app at "risk"?
Here it is what I have done:
1st - Added the twitter omniauth gem to my gemfile.
2nd - Created a omniauth.rb file in the app/config/initializers folder.
3rd - Typed the "bundle install" command and got the following error: "omniauth requires Ruby version >= 2.1.9."

Dependencies can specify a required_ruby_version in their .gemspec file. In this case, one of your sub-dependencies (omniauth - a sub-dependency of omniauth-oauth, which is in turn a sub-dependency of omniauth-twitter) has had such a requirement since v1.5.0.
To get a working install, you've got two options:
Pin to an older version of omniauth, by adding gem "omniauth", "~> 1.4.2" to your Gemfile. This will ensure Bundler uses an older version of omniauth. However, that may cause conflicts with other gems, leaving you with the same problem - indeed, it's probably the reason Bundler didn't automatically try to install an older version.
Update your Ruby version. If you have a .ruby-version file in your application, update the version there to 2.1.9. Similarly if your Gemfile has a ruby "..." line in it, update that too. You'll probably also need to install the new version of Ruby locally - with rbenv you can use $ rbenv install 2.1.9, or if you use RVM try $rvm install 2.1.9.
My recommendation would be option 2 (updating your Ruby version).

Related

In a Ruby on Rails installation, what is causing webrick to be outdated and why `gem i webrick` can update it?

I have a new Mac computer and installed rails on it, and then I tried out the command
gem outdated
for some reason, it showed one of the gems outdated:
webrick (1.4.2 < 1.6.0)
I wonder why it is outdated on the first installed, and when I did
sudo gem install webrick
it actually installed 1.6.0 onto the system. Doesn't it require gem update instead of install to update something? How come install also updated it?
Not exactly, gem install GEM_NAME will install the last version available if you don't specify a version when installing, and you can have more than 1 version of the same gem on your machine.
you can run gem environment, and check where gems are installed, go to that folder and you will see both version gems folder there.
so when you create a rails project for example and add a specific version of a gem in the gemfile and another version on another project, you can have both without problems

Upgrading rails on Mac

I know the question to this is probably very straight forward, but Im a bit new to rails, so please bear with me. I have had rails version 5.1.5 on my Mac and I need to update rails to version 5.1.6 and I'm not able for the life of me to do that.
I tried
`sudo gem install rails -v 5.1.6`
but this gives the error
ERROR: Failed to build gem native extension.
Using gem list gives that I have
rails (5.1.5, 5.1.4)
I also tried bundle update rails
I keep getting Could not locate Gemfile
What am I doing wrong??
gem is the native package manager for Ruby.
Bundler (bundle) is a gem to manage bundles of gems via a Gemfile.
I recommend you use a version manager for Ruby like rvm, rbenv or chruby and also install xcode and the commandline-tools package of xcode. Some gems have dependencies written in C that need to be configured and compiled, all of that and some more comes with xcode.

How to run a specific version of a ruby gem

I am running brakeman outside of my Gemfile, so am not using bundler.
If I do gem list, I can see I have the following for brakeman
brakeman (3.3.3, 3.3.2, 3.1.4, 3.1.2)
But if I do brakeman --version, I get
brakeman 3.1.2
so I am not using the latest version. If I do gem update brakeman or
gem update brakeman, '3.3.3,
I get
Updating installed gems
Nothing to update
So how do I run brakeman version 3.3.3?
If you have several gem versions installed and you want to invoke a specific version from the command-line, you could use:
brakeman _3.3.3_ [args go here]
This is not specific to brakeman, you can do this for most other gems as well.
I can't reproduce this issue, but I can think of a few reasons why this might happen:
Bundler artifacts (perhaps in .bundle/) pointing to the old version. Try running in a different directory and see if it still happens
A bug in RubyGems (try gem update --system)
During install, it asked if you wanted to replace the brakeman binary and you selected "no"
If you are using a Ruby version manager, maybe one version is on a different path than another (like a system gem versus one managed by rvm)
Any number of GEM_PATH, bundler, gem, rvm weirdness that sometimes occurs
In any case, if I were you I'd gem uninstall brakeman, remove all versions, and install fresh. If you are using rvm, start with a fresh gemset or rvm gemset empty the current one.
I had a similar problem: I uninstalled a certain gem version, but the version still showed up.
TL;DR: rbenv rehash did the trick. (Only valid for rbenv users, obviously)

Why does a Ruby version update require installing bundler?

My application was running fine with Ruby 2.2.4, until running a test gave me an error saying "the ruby version you're using is outdated/buggy".
So I updated and used Ruby 2.3.0 as the default for my application. After that I got an error saying "could not find bundler".
I already had bundler, so why does updating the Ruby version require reinstalling bundler into my application?
(I am learning Ruby-on-Rails, so treat me as a beginner.)
Each copy of Ruby installed on a computer has its own set of installed gems. One reason that gems aren't shared between installations of Ruby is that some gems include compiled native code, and the compiled output might be different for different versions of Ruby.
bundler is a standalone gem, not part of Ruby, so whenever you install a new Ruby you have to install bundler in that Ruby.
This is independent of whether you're using a Ruby version manager (chruby, rbenv, rvm, etc.); if you install a new Ruby, it needs its own set of installed gems.
Whenever you install a new version of Ruby with RVM it creates a wrapper with what they call gemsets. Gemsets are not shared between ruby version so therefore when you installed your new Ruby 2.3.0 it installed without any gems.
To fix this problem simply install bundler by running gem install bundler.
Once that's done, you should have it available for your new installation of Ruby.
I also had faced such issue. First I run this with selected RVM version.
gem install bundle
Then you should run:
bundle install
In your project directory.
Please let me know if you have any confusion.

Two versions of rspec installed on my computer?

I've been attempting to make a start on learning Ruby/rspec. I read that rspec is now broken for Windows so an early version (2.14.1) should be installed instead. I started on testfirst's learn Ruby but kept getting errors whenever I attempted the "rake" task. I checked my rspec version and apparently I'm running 2.14.8. I thought maybe that was why I was getting some errors. So I typed into git "gem uninstall rspec" but it then said version 2.14.1 was uninstalled, not .8. So I checked to see if there were any versions of rspec installed on my computer and it says that 2.14.8 is still installed... now it won't let me uninstall it, even though I typed in "gem uninstall rspec -v 2.14.8."
I also tried to check the contents of version 2.14.8, but it couldn't find gem 'rspec' in default gem paths.
It's as if I had two versions of rpec on my laptop... how do I get rid of the .8 version?
If gem uninstall rspec -v 2.14.8 did not work for you. Try cleaning up all the rspec version from your computer first by running:
gem cleanup rspec
Then, install the required version again.
Update:
Try:
gem uninstall -Iax rspec
If doesn't work, then try and remove the executables as well:
gem uninstall rspec-core
Where did you hear that RSpec is broken on Windows? AFAIK the current version (3.3.2) works just fine.
If you are going to learn Ruby and RSpec, you should also learn about using Rubygems and Bundler, since many projects rely on them. Install Bundler with:
gem install bundler
Create a new folder and CD into it, and then:
bundle init
This creates a file named "Gemfile" in the folder. This allows Bundler to manage the versions of gems used within your project. Edit the Gemfile and add this line:
gem 'rspec', '~> 3'
This tells Bundler that your project requires RSpec 3, and to install the latest version. Save the Gemfile, and then do:
bundle install
Bundler will install the RSpec gems and create a Gemfile.lock file that details the gem dependencies. To verify that the right version is installed:
rspec --version # => 3.3.2 (or whatever is the latest)

Resources