How to change version of gem? - ruby-on-rails

I am trying to update a gem (specifically bootstrap-sass) to the latest version (3.1.1). To do this I first edited the Gemfile to change the bootstrap line to this:
gem 'bootstrap-sass', '3.1.1'
Then I ran
bundle install
bundle update
bundle install
and started the server, but when looking at the custom CSS file with Bootstrap included, the CSS included was still version 2.3.2. There is probably a simple answer to this question to force the update upon all components of the app, but how do I apply this update?
Here's the Github repo so people can help debug faster:
https://github.com/afuhrtrumpet/menu_app

Per the bootstrap-sass readme.md at:
https://github.com/twbs/bootstrap-sass
Make sure you have sass-rails in your Gemfile too.
gem 'sass-rails', '>= 3.2'
Since you already had been running bootstrap, I presume you have #import 'bootstrap' in your CSS tree.

The old version of bootstrap-sass was still installed along with the new version and was still being used. The following command fixed it:
gem cleanup bootstrap-sass

Delete Gemfile.lock, and rerun bundle commands

Related

Bundle Update downgrades several gems in a gem

Disclaimer before reading: I have resolved this issue but I am asking because I still don't know the reasons behind it.
I'm working on an old gem that pulls assets into the asset pipeline. I'm not positive how the gem was originally created I imagine it was with rails plugin new static_assets.
Since it is a gem the Gemfile is not overly complex (I haven't made any changes to it):
source "http://rubygems.org"
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
But the Gemfile.lock has dozens of gems and dependencies showing up. For the most part, the gems seem up to date.
When I run a bundle update several of the gems go back to much older versions; like Rails 5 to Rails 3.
I believe I solved this by updating the Gemfile to
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
but I want to know why this was happening.
I'm not overly familiar with how Gemfile.lock gets created and updated but I was under the impression that it was based on the Gemfile, pulling all gems and their dependencies from the Gemfile. If all the gems in Gemfile.lock are dependant on jquery-rails why was it automatically downgrading them so unilaterally and by so much?

How does one upgrade a specific ruby gem to a specific (or the latest) version?

I am trying to upgrade a gem (hydra-derivatives) to version 3.3.2 to see if it solves a bug we are having.
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
What I've Tried
bundle update --conservative
hydra-derivatives but that only upgraded hydra-derivatives to
3.2.2 (& we want 3.3.2) and its dependency mini_magick from 4.5.1 to 4.8.0
adding gem 'hydra-derivatives', '~> 3.3.2' but that gave me:
You have requested:
hydra-derivatives ~> 3.3.2
The bundle currently has hydra-derivatives locked at 3.2.1.
Try running `bundle update hydra-derivatives`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
I don't want to run bundle update hydra-derivatives because I don't want it to update a bunch of unnecessary gems and cause problems, hence why I read about --conservative
a. I ran this anyway to test it, and it upgraded target gem to only 3.2.2 and 15 gems in total!
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
You can still add this as an explicit dependency in your Gemfile:
# only restrict the version if you know of an incompatibility
gem 'hydra-derivatives' , '~> 3.3'
then run
bundle update hydra-derivatives --conservative
or
bundle update hydra-works --conservative
Remove the hydra-works gem from your Gemfile.
Either remove the gem and its dependencies by hand from the installed gem location or if you have the application in its own Ruby environment using rbenv or rvm run bundle clean --force.
Beware bundle clean --force will remove all of the gems in the Ruby version other than those specified in your Gemfile. If you have other applications that use the same version of Ruby you'll have to reinstall the gems for that application if they are different than what you are using in this application.
Add this to your Gemfile
gem 'hydra-derivatives', '~> 3.3.2'
gem 'hydra-works'
And run bundle install
You should see the correct dependency version now in your Gemfile.lock

New user trying to install a Ruby Gem (bootstrap)

I am new to rails and I'm trying to create a new project and add the bootstrap 3 ruby Gem (https://rubygems.org/gems/bootstrap-sass) and I can't work out what I'm doing wrong.
I create the new application:
rails new demoapp
I add the following line to the Gemfile
gem 'bootstrap-sass', '~> 3.1.1'
I bundle it
bundle install
I run it
rails server
However no bootstrap is present on my site and I can't use bootstrap css, what am I doing wrong?
You need to add boot strap to the assets file.
Import Bootstrap into a Sass file (for example, application.css.scss)
to get all of Bootstrap's styles, mixins and variables!
From https://github.com/twbs/bootstrap-sass
Basically, add #import "bootstrap"; to your application.css.scss file...
You need to add the gem inside the GemFile like
gem 'bootstrap-sass'
And then run the following command
bundle install
No need to run
gem install bootstrap-sass

Gemfile updated, error doing bundle install

I´m totally lost so i will try to explain my problem.
Actually im reading the book Ruby on Rails tutorial. I´m actually installing all the environment to start learning this language.
The book asks me to update the Gemfile, and add this
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
So i delete my old gem sass-rails, my old gem coffee-rails and my old gem uglifier.
After doing this the book asks me to save it and run Bundle install on my console.
After doing this i get this message:
You have requested:
coffee-rails = 3.2.2
The bundle currently has coffee-rails locked at 4.0.1.
Try running `bundle update coffee-rails`
So i´m totally lost, and i have no idea what i´m doing cause im only following the steps from the book. Someone could help me and tell me what i should do here? Why the book is asking me to do all this if then it does´t work?
Sounds like you have already done a bundle install on a newer (probably without the version requirement) of coffee-rails and that is currently locked down in your Gemfile.lock file.
Do what it says and run bundle update coffee-rails to update your Gemfile.lock file to the version you specify

Rails - Understanding Gems

I'm using the rails devise gem. I noticed a case sensitivity bug which turns out is fixed in the latest version of devise so I'm thinking about upgrading.
In my gem file I have:
gem 'devise', '~> 1.1.3'
When I run bundle I get:
Using devise (1.1.9)
Why the difference. And what setting should I be using in my gem file to upgrade to the latest and greatest?
Thanks
The ~> in your Gem declaration says that Bundler can install any version up to the next major version, so in this case it could install any version of devise that is => 1.1.3 and < 1.2.0.
Including the ~> is good practice, as it means security updates are automatic if the gem is using versioning correctly; in a production environment, you'll probably want to drop this moniker, though, and just set your gem versions statically to avoid issues.
To update to the latest version of the gem, everytime, just use the following with no second version argument:
gem 'devise'
See more information on the Gemfile format at http://gembundler.com/gemfile.html.
Just use :
gem 'devise'
and you will be getting the latest stable gem :)
The difference is because you're telling to Bundler to use 1.1.3 or a major version of this gem in you system, if you want to use a specific version just put '1.1.9' in the version param.
use bundle update devise to update the devse gem and bundle update to update all the gems (which is not advisable)
http://jsbin.com/ihiqe4
if you know the version number you want, try this (assuming it's 1.2.3):
gem 'devise', '1.2.3'
or just leave out the version number
if it has not been released yet, you can point to it's github repository instead.

Resources