issue using gemfile in ruby on rails - 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'

Related

Ruby: I cannot create gemfile.lock with default bundler version

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

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

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

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.

When I run gem install *some gem name* where does it install?

As the question states - where does the gem install?
Is it installing within the app directory that I'm working in (i.e. user/sites/sample_app)? Or is it being installed on my computer? If the latter where exactly?
Thanks!
gem install process
first download gem and save desktop
1.next step open command prompt and set location that means c:/desktop> gem install --local "gemname"
2.next step com to rails consoler and type $bundle install --local.
3. type the gem name on gem list
I have two questions:
Where do you install your ruby?
Did you use RVM or rbenv?
Now I will explain your question using my situation as an example.
I use RVM to manage rubies on my mac os.
now the ruby install in path
/Users/pin/.rvm/rubies/ruby-2.1.1
and these will be a gems directory under .rvm path. In this directory,
/Users/pin/.rvm/gems
there are many gems group, I have a group named
ruby-2.1.1#global
which is used by the default ruby version.
This is a directory and there will be a gems directory under it.
/Users/pin/.rvm/gems/ruby-2.1.0/gems
In this directory, you will find all of the gems you installed using cmd
bundle install
If you don't use ruby version management tools like rvm or rbenv, you may find the gems
around your ruby path. If you still can't find them, you can post the details of how you
install the rubies and other system configs, so that we can discuss here.
If you are using rvm then its get installed in
/home/user/.rvm/gems/ruby-version#global/ or /home/user/.rvm/gems/ruby-version/
If you are using specific gemset for gems then
/home/user/.rvm/gems/ruby-version#gemset_name/
If you want to know where gem is installed use gem which *gem_name* e.g.:
gem which rails
If you installed your gems with bundle install use bundle show *gem name* e.g.:
bundle show rails
Gems
If you use gem install x, you're adding the gem to the local ruby version on your system. This is a system-wide installation, and will be stored in your rubylib/ruby/gems dir:
The install command downloads and installs the gem and any necessary
dependencies then builds documentation for the installed gems.
Bundler
Using the bundle install command (when you have a Gemfile & use bundler), you basically tell bundler to install the gems relative to your specific applicaiton:
Bundler makes sure that Ruby can find all of the gems in the Gemfile
(and all of their dependencies). If your app is a Rails 3 app, your
default application already has the code necessary to invoke bundler.
If it is a Rails 2.3 app, please see Setting up Bundler in Rails 2.3.
For example, if you have a Rails 3.2 app, and a Rails 4.1 app on your system, using bundler allows you to instal the dependencies (gems) for each app independently
If you use gem install x, it will install the gem for all applications, and should only be used for things like rmagick and the database connection gems

Resources