Your Ruby version is 2.7.0, but your Gemfile specified 2.6.3 - gemfile

Why is a Gemfile being created what specifies 2.6.3? How do I make it create a Gemfile that specifies 2.7.0???
Thank you

Just change: ruby '2.6.3' to ruby '2.7.0' in your Gemfile and run bundler install in your terminal. Gemfile is just a manifest that contains gems and ruby version that must be installed in current folder. Here's some info about Gemfile on bundler doc.

Related

How to find the single gem installed when only specifying a Ruby version in a Gemfile

I'm running Ruby 2.7.0, Bundler 2.1.4 and macOS 10.15.3.
I have a Gemfile in an otherwise empty folder which is only specifying the Ruby version:
ruby '2.7.0'
When I run bundle, or bundle install, I get:
% bundle install
The Gemfile specifies no dependencies
Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
However, bundle list gives me:
% bundle list
No gems in the Gemfile
What is the one installed gem? Where would I find it?
It looks like Bundler itself.
These are the links to the code for the output from the bundle install command:
https://github.com/rubygems/bundler/blob/v2.1.4/lib/bundler/cli/install.rb#L69
https://github.com/rubygems/bundler/blob/v2.1.4/lib/bundler/cli/install.rb#L119-L122
https://github.com/rubygems/bundler/blob/v2.1.4/lib/bundler/definition.rb#L180-L183
The important part is the last part where specs["bundler"] is empty then it assigns bundler spec to specs["bundler"] so specs.count returns at least 1.
You can try with:
bundle show
bundle show name_of_gem

Adding a customized version of bundler as a dependency in a Gemfile

How can I make a typical gem setup (as generated by bundle gem) run a customize version of bundler?
I've added:
#group :development do
gem "bundler", github: 'pjump/bundler'
#end
to my Gemfile (with or without the the hash symbols), and bundle install works, but bundle exec keeps telling me that the bundler repo is not yet checked out. The only way I can make it work for now is by installing the customized version with gem istall and not specifying a bundler dependency in the package at all.
Bundler isn't able to bootstrap itself from a Gemfile, so adding a customized version to your Gemfile will not do what you want. Installing it with gem install is the correct solution (or running rake install from the forked Bundler repo directory, which builds and installs the gem in one step).

How to load forked github repo as gem in sinatra/rack application

I'm trying to use a gem called "rbing" but there is an issue with it and the project has been abandoned but someone made a fix in a repo so I decided to use bundler to specify the new version.
gem "rbing", :git => "https://github.com/KellyMahan/rbing.git"
It even installed correctly when I ran bundle install, but inside my Gemfile RubyMine is complaining that "The gem with the specified version requirements isn't available inside SDK RVM: ruby-2.0.0"
And it doesn't show up in my external libraries directory.
Any help is very much appreciated guys,
Cheers, Adam
EDIT: Ruby version,
Bundler 1.3.5
Ruby 2.0.0 (2013-05-14 patchlevel 195) [x86_64-darwin12.3.0]
Rubygems 2.0.3
rvm 1.20.11 (stable)
GEM_HOME /Users/adam419/.rvm/gems/ruby-2.0.0-p195
GEM_PATH /Users/adam419/.rvm/gems/ruby-2.0.0-p195:/Users/adam419/.rvm/gems/ruby-2.0.0- p195#global
rubygems-bundler (1.1.1)
Change your Gemfile to:
source "https://rubygems.org"
gem 'sinatra'
gem 'rbing', :git => 'https://github.com/KellyMahan/rbing'
I just did it here for RubyMine 5.4 and it works like a charm:

How to specify minimum bundler version for Gemfile?

When my Gemfile is using :mri_20, and previous versions of bundler do not support that, is it a good idea to add
gem 'bundler', '~>1.3.5'
to the Gemfile? Is there a better way to enforce a minimum bundler version?
This won't have any affect on the bundler used to manage the gems in the Gemfile. The version of bundler that's used is the one that's available in your current ruby environment.
The best way to manage this is with gemsets - you can create a gemset with a known, working version of bundler and always switch to that gemset when working with that project.
To check the bundler version, run:
$ bundle --version
Bundler version 1.3.5
If you want to enforce the bundler version when running bundle install, put this at the top of the Gemfile:
# Gemfile
if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.3.5')
abort "Bundler version >= 1.3.5 is required"
end

Ruby: Rails: Which version of a gem is used?

I have a Rails 3 application which has the following line in the Gemfile.
gem 'sqlite3', '1.3.6'
However, if I list my local gems I get:
> gem list sqlite3 --local
*** LOCAL GEMS ***
sqlite3 (1.3.6, 1.3.4)
When my Rails apps does a
require 'sqlite3'
which version of the gem is selected? Is it that the first gem in the list is selected? Is there a way to tell the Ruby runtime to use version 1.3.4 even if version 1.3.6 is installed, and mandated by the Gemfile?
You could find out with
bundle exec gem list sqlite3
Either the Gemfile will specify a version or Gemfile.lock will have the version.
Examples:
Gemfile:
gem 'tiny_tds', '0.5.0'
Gemfile.lock:
tiny_tds (0.5.0)
Edit: if you want to see the version, use iltempos' suggestion or in the rails console type
1.9.3p194 :001 > SQLite3::VERSION
=> "1.3.6"
the Gemfile list all the dependencies of your Rails application, you can add constrains about the version to use for each gem. In your example you specified that your application depends on sqlite3 1.3.6 so it will use the version 1.3.6.
In general the exact version of the gems required by your application are in the Gemfile.lock.
There are several syntaxes you can you to specify the versions:
gem 'gemname', '1.2.3' - Requires gemname version 1.2.3
gem 'gemname', '>= 1.2.3' - Requires gemname version 1.2.3 or any higher version. Can break things
gem 'gemname', '~> 1.2' - Require gemname 1.2 or a minor update like 1.2.9. You get updates but not mayor one which could break compatibility
The interesting thing to note is that once the Gemfile.lock is written and checked in your version control, it's shared between all the members of the team that all will use the same, exact, versions of the required gems.
If you need to update a required gem you can do that in 2 steps:
Update the Gemfile if needed
Run bundle update gemname
The step 2 will download the new gem version (if there is a new version respecting the constrain in the Gemfile), install it and update the Gemfile.lock accordingly.

Resources