Ruby: I cannot create gemfile.lock with default bundler version - ruby-on-rails

I want to create my gemfile.lock file with bundler version 2.3.25
But when I try to bundle install it always is bundled with 2.4.5
So I uninstall bundler version 2.4.5 and it STILL bundles with that version, and then throws errors when I rails s because version 2.4.5 isn't there.
When I run gem list bundler right now I get: bundler (2.4.5, default: 2.3.25)
I've gone as far as to delete the file from
\\wsl$\Ubuntu\home\me\.rbenv\versions\2.7.0\lib\ruby\gems\2.7.0\gems\bundler-2.4.5
then, I delete the gemfile.lock file and bundle install and low and behold its bundled with 2.4.5..
I've tried gem uninstall bundler and no luck..
I've tried all of the following methods and no luck
Here
or
Here
How can I either force Ruby to use the default version of Bundler, or REALLY get rid of the version I don't want?

Bundler will add its version number to Gemfile.lock after you've run bundle install:
BUNDLED WITH
2.4.5
Therefore you can run bundle install with version 2.4.5 to generate Gemfile.lock and then edit it with a text editor to replace the version with the version you require. Then, when you run bundle install again bundler will notice that and will use the older version that you specify.
Gemfile.lock is a pretty straightforward and standard format and there are no material changes to it between those versions.
Otherwise, you can do like #engineersmnky said (and is explained in this other answer) and use:
bundle _2.3.25_ install

Related

omniauth requires Ruby version >= 2.1.9. issue while installing gem file

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).

How to change the version of bundler being used in rails?

When I run the following command, it gives me the available installed versions of bundler:
command :
gem list | grep "bundle"
output:
bundler (1.11.2, 1.10.6, 1.10.4, 1.3.6, 1.3.0, 1.3.0.pre)
The current version of bundler I obtained was 1.11.2 using the following command:
bundler --version
I want to use version 1.3.6
How do I swap the current version of bundler with the available ones?
Normally during development Bundler is used from it's executable on your system, so I don't believe you can specify a specific version in your Gemfile, for example. (You might try it, though). However, you can install the version you like and force the shell/rubygems to use that version:
$ gem install bundler -v 1.3.6
...
1 gem installed
$ bundle _1.3.6_ -v
Bundler version 1.3.6
To get my machine to use 1.3.6 by default I had to uninstall 1.11.2.
Update: I tried specifying gem 'bundler', '~> 1.3' in one of my projects and it worked, although the CLI for bundler still used the system default version.
Sept 2019
If you want to upgrade bundler 1 to 2, then you should do the following:
1- The first step in upgrading to Bundler 2 is installing the Bundler 2 gem by running:
gem install bundler
2- When Bundler 2 installed, Bundler will automatically switch between version 1 and version 2 based on your application’s Gemfile.lock based on the BUNDLED WITH ((version)) in your Gemfile.lock
Note:
Before the next step, you should commit your Gemfile & Gemfile.lock, so that you can revert to bundler version 1 if needed
3- To upgrade from bundler 1 to 2, run:
bundle update --bundler
The answer is based on the official bundler update guide
To change your bundler default version, use bundle config default <the desired version>.

issue using gemfile in ruby on rails

I have some dependency issues with the latest bundler version of "1.9.7". I need bundler version "1.7.3" for this.
I tried specifying the required bundler version as "1.7.3" in my project's Gemfile. But, it isnt working. It is always referring to the latest bundler version thats installed in my PC.
So, how should I specify the required bundler version for my project?
It seems like you can force a particular version using e.g. $ bundle _1.7.3_ install.
See How to `bundle install` when your Gemfile requires an older version of bundler?
If you're using this version only in this project, I would recommend to create a gemset using rvm and install the version that you want on it.
Here some tips:
# rvm gemset create your_project_name
# rvm gemset use your_project_name
# gem install bundle -v '1.7.3'

bundle install creating a 'parallel' folder in the rails app

I'm currently working on a project which was changed from ruby version 2.0.0 to ruby verion 2.1.1,
i'm using rvm for maintaining my ruby versions. After installing ruby 2.1.1, I ran gem install bundler which installed version 1.6.2, doing so I had copied a specific gemset version to a newly created one for version 2.1.1 after which when running gem list on, it displayed all the gems, and when I tried to run the app it started throwing errors.
So when I ran bundle install again it created a separate folder parallel and installed the gems there. My question is why does this happen, is it a new feature of bundler 1.6.2'?
Initially I had my bundler version to 1.5.2.
Any input on this will be really helpful.
Thanks.
Found this post which explains clearly, the reason was my config file was corrupted.
we have to remove .bundle/config file and bundle install again.
rm -r .bundle/config
bundle install
click here for more information.
Thanks.
My guess is you have two different bundlers tied to a different RVM gemset, even if you tried to install the newest globally.
In the future you may consider using :
bundle install --path .bundle
to install your gems in a consistent manner, always in the same .bundle folder, no matter what RVM gemset you're using.

Why does bundler update gems when it knows the gemfile requires a specific version

This seems to happen a lot. I run bundle update or bundle install and for one reason or another I often get something like this:
You have already activated kgio 2.8.0, but your Gemfile requires kgio
2.7.4. Using bundle exec may solve this
I then have to go and run: sudo gem uninstall kgio and select kgio 2.8.0 to uninstall it.
Why does bundler even update the gem if it knows my gemfile locks those gems to a specific version. I NEVER install gems outside of the gemfile and bundler so Im not circumventing its conventions. I do have another project on my machine, but I havent ran a bunle update on that project in a long time -- is there some mix up there? Has this happened to anyone else? Am I doing something wrong?
actually bundle update the gems specified (all gems, if none are specified), ignoring the previously installed gems specified in the Gemfile.lock.
whereas bundle install will fetch all remote sources, but use the dependencies specified in the Gemfile.lock instead of resolving dependencies.
and use
gem cleanup
This command will remove (uninstall) all the versions of a gem, except for the latest one.
bundle update, installs newer versions of your gems and states that in your Gemfile.lock. bundle install just makes sure you have the correct versions installed. I suppose you are running bundle install in projects with different locked versions for kgio.

Resources