I need to use addressable 2.2.4 gem, but I have 2.2.5 version (because of an issue discussed here: https://github.com/sporkmonger/addressable/pull/33). I tried:
source 'http://rubygems.org'
source 'http://gems.github.com'
gem "addresable", "2.2.4"
bundle install
and get Could not find gem 'adressable (= 2.2.4, runtime)' in any of the gem sources listed in your Gemfile.
If I install/uninstall gem manually by
sudo gem install addressable -v 2.2.4
sudo gem uninstall addressable -v 2.2.5
I get the same error.
So, how can I force 2.2.4 version for my app?
You've misspelled "addressable" in your gem line.
Your bundle might be locked at 2.2.5 — try running bundle update. It's counter-intuitive, but it'll rebuild your Gemfile.lock with the specified version.
You don't need gems.github.com as a source anymore — they quit building it and recommend rubygems.org.
Related
I'm trying to install the pg_search gem. In the first attempt I did not pay attention to the necessary version of ruby (we are using 2.3.1 and 2.4 was required), in the error message that appeared I was asked to run bundle update, but it updated pg_search to 2.3.5 which require ruby >= 2.5. Even though I specified an older version of the gem, it still shows the same message:
Gem::InstallError: pg_search requires Ruby version >= 2.5.
An error occurred while installing pg_search (2.3.5), and Bundler cannot continue.
Make sure that `gem install pg_search -v '2.3.5'` succeeds before bundling.
I already installed the gem by running docker-compose run web gem install pg_search -v 2.1.4, and recreated the container. My Gemfile:
source 'https://rubygems.org'
gem 'rails', '~> 5.2.0'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
#gem 'mina-puma', :require => false
gem 'puma', '~> 3.7.1'
gem 'pg', '~> 0.18'
gem 'pg_search', '~> 2.1', '>= 2.1.4'
...
Bundler version: bundler (>= 1.3.0)
I would like to know how to remove pg_search 2.3.5 and install 2.1.4.
Even though I specified an older version of the gem
No, you didn't.
You specified '~> 2.1', '>= 2.1.4', which means anything 2.1.4 <= version < 3.0.0.
By running bundle update, this installed the latest available version that met your requirements, which was apparently 2.3.5, not 2.1.4.
If you need to also specify a constraint to ruby version 2.3.1, you can also put this in the Gemfile:
ruby '2.3.1'
...And then running bundle update will also take that into consideration when finding the latest compatible dependencies.
I would like to know how to remove pg_search 2.3.5 and install 2.1.4
You don't have version 2.3.5 installed against this ruby version, because it's incompatible.
Apparently you've already installed version 2.1.4.
The problem is that your Gemfile.lock is still expecting version 2.3.5. There are a few ways you could resolve this, but one way or another you need to update the Gemfile.lock to have a compatible set of dependencies with your ruby version.
The simplest approach is probably to just re-run bundle update pg_search, but make sure you're actually using the correct ruby version this time. That should downgrade the dependency, as the newer library version isn't compatible with the older ruby version.
If you still encounter issues, you could take my advice of adding the ruby constraint to the Gemfile, and revert whatever other changes you've recently made that created this incompatible mix of dependencies.
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
I am trying to rails server from a cloned repo, I have updated ruby, and rails, followed the rvm process, updated all my gem files, and when I go to serve I receive the message
Could not find globalid-0.3.7 in any of the sources Run bundle
install to install missing gems.
So I do bundle install, then get the error
An error occurred while installing pg (0.20.0), and Bundler cannot
continue. Make sure that gem install pg -v '0.20.0' succeeds before
bundling.
Try to insall that and then get
ERROR: Could not find a valid gem 'globalid-0.3.7' (>= 0) in any
repository ERROR: Possible alternatives: globalid, globalize3
I have googled everything and asked many.
globalid is a dependency of the Rails core gem ActiveJob so it is a required gem to have in your Gemfile.lock. See if it is listed in your Gemfile.lock file. If not you could add it to the top of your gemfile including the version
# gemfile
gem 'globalid', '0.3.7'
Then bundle install. If it works, then you can delete it from your gemfile since it should load automatically when Rails loads (since it is a dependency of Rails' ActiveJob). I've run into a similar issue with another gem and this process worked for me.
It could be a version error. Try using gem 'globalid', '~> 0.4.0' in your gemfile and bundling.
I am trying to install the aws-sdk gem for Rails, but it requires a Nokogiri version less than 1.6.0. I think due to a previous bundle install my system is locked on Nokogiri v1.6.6.2.
I tried removing the locked gem, and ran a bundle update but it didn't work. What should I do?
Specify your desired Nokogiri version in your Gemfile:
gem 'nokogiri', '< 1.6.0'
and run
bundle update nokogiri
Run
gem uninstall nokogiri -v 1.6.6.2
then change the Gemfile to the version you want and then do a bundle install.
I am in an older Rails project that has a Gemfile. I tried to add a gem to the Gemfile and bundle install but got an error:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.1.5)
This Gemfile requires a different version of Bundler.
The version of Rails it's using requires bundler ~>1.0.0 but I have 1.1.5 installed and am using it for my other projects. Usually I would use bundle exec ... but since this is bundler we are talking about, it's a little more complicated than that. How can I add a gem to my Gemfile and run bundle install while using the version of bundler that it requires?
First you need to install the appropriate version of bundler:
% gem install bundler -v '~> 1.0.0'
Successfully installed bundler-1.0.22
Then force rubygems to use the version you want (see this post):
% bundle _1.0.22_ install
This is what I had to do to get it to work to install with a previous version (2.2.11) of bundler:
gem install bundler:2.2.11
bundle _2.2.11_ install
The error message In Gemfile: bundler (~> 1.16) is a bit inaccurate, since the version number requirement can come from other places, such as the .gemspec file, which was the case for me:
spec.add_development_dependency "bundler", "~> 1.16"
Removing the version number from the .gemspec file solved the issue for me:
spec.add_development_dependency "bundler"
I had the same issue on macOS Mojave. I installed the different version of the bundler gem and uninstall the current version.
gem install bundler -i '2.0.1'
gem uninstall bundler
Then gives me the option to choose the version to uninstall and I choose the one which is creating the problem.
If you use rvm to manage your ruby versions consider using gemsets for projects. This way you can install the specific version of bundler needed without having to specify the version each time.
You can confirm your gemset is loaded by running rvm info in your project directory.
Now you can install the version of bundler you'd like via gem install bundler -v '~> <VERSION>'. The next time you need to use bundler just run bundle.