Bundle install not running properly, gem corrupted - ruby-on-rails

While running the bundle install, it stops installing when it reaches the installation of the byebug gem. Saying, the gem maybe corrupt. I have tried uninstalling the ruby application and also tried updating my ruby and also my rails version

If you are using Bundler 1.1 or later you can use bundle clean, or bundle clean --force just as you imagined you could. This is redundant if you're using bundle install --path (Bundler manages the location you specified with --path, so takes responsibility for removing outdated gems), but if you've used Bundler to install the gems as system gems then bundle clean --force will delete any system gems not required by your Gemfile. Blindingly obvious caveat: don't do this if you have other apps that rely on system gems that aren't in your Gemfile!
Source -Bundle Clean

Related

Why is "install" run twice?

I'm going through Micharl Hartl's well known Rails tutorial, and this piece is confusing me. Every time a new app is set up, these commands are run:
$ bundle install --without production
$ bundle update
$ bundle install
I don't really get why install is being run twice. What is the effect of these three commands run in this sequence?
You should not have to run bundle install twice as bundle update will also install all of your gems (as well as updating them to their most current version). I have not read the tutorial you mentioned but perhaps the purpose of the second install is to install all of the gems, including those reserved for production.
Your second question, what is the effect of these three commands:
bundle install --without production
Inspect the gemfile, ignoring gems that are reserved for production
Resolve all dependencies
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle update
Inspect the gemfile
Resolve all dependencies from scratch using the newest version of each gem and completely ignoring Gemfile.lock
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle install
Because this is the first run of the production gems, inspect the gemfile and resolve dependencies of the production gems
Use Gemfile.lock for exact versions of all other gems to be installed
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
Hoped this helped, for more detailed info about the two commands check out this and this.
$ bundle install --without production prevents bundler from installing any of the production gems. It also gets saved in your local repository and you don't have to run it more than once. Any subsequent run of bundle install will include --without production.
bundle install installs only the missing gems from your Gemfile, while bundle update updates/installs every single gem to the latest version as specified in the GemFile..

Does bundle package install gems globally

I used to have a new ruby installation for each new rails project, because it's impossible not to have conflicting gems with between two of them.
I have seen that 'bundle package' command could freeze a project specific set of gems in the 'vendr/cache' directory.
I though it wouldn't install them globally, just store them in that directory.
However, when i did it, 'bundle package' ended up installing (globally) the gems before storing them in 'vendor/cache' folder.
Did I do something wrong? Is it a bug?
From the Bundler docs:
The package command will copy the .gem files for your gems in the bundle into ./vendor/cache.
As far as I can tell, Bundler does not handle installing gems, it passes that off to the gem command. What Bundler does is to make sure that you have the right version of the gem activated. So even when you package the gems, when you later install them it'll take those gems and install them "globally".
So, to answer your question: No, you didn't do anything wrong and this is not a bug but the intended behaviour.

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.

rails - Unexpected behaviour of 'bundle install': installation into a folder in the app directory

I've started a simple rails application. I tried to install Compass and Haml, (using gem install) and ran 'bundle install'. The bundler re-installed all the gems and placed them in a new folder '/haml' inside the main directory of the rails application.
Your bundle is complete! It was installed into ./haml
Is that expected? Shouldn't these gems be placed in the rvm directory, not in the application directory?
$ bundle install --system
Will solve your problem.
Gems will be installed to your default system location for gems. If your system gems are stored in a root-owned location (such as in Mac OSX), bundle will ask for your root password to install them there.
While installing gems, Bundler will check vendor/cache and then your system's gems. If a gem isn't cached or installed, Bundler will try to install it from the sources you have declared in your Gemfile.
The --system option is the default. Pass it to switch back after using the --path option as described below.

How does bundler work (in general)?

I'm pretty new to Ruby/Rails but I was taking a look at bundler and was wondering how it works exactly. Do you install a full set of gems like normal gem install XYZand then use the Gemfile to pull a certain subset of those gems for use with a specific application? Or do you not install gems normally anymore and just include them in the Gemfile and then do a bundle install to include them all in a bundle that is then used with your application?
Thank you so much for taking the time to answer this, I'm just a little confused on what bundler's functionality is exactly.
-- MAP
These two links explain everything about bundler.
How does bundler bundle
How does bundle require gems
Think of bundler as a package management tool.
From bundle help command:
bundle install # Install the current environment to the system
bundle package # Locks and then caches all of the gems into vendor/cache
So bundle install command will install all gems to the system that are listed in Gemfile as well as their dependencies. If the gem was not previously installed it will grab it from the gemcutter repo. bundle package will cache the .gem files into your apps vendor/cache directory.
No need to run gem install first.

Resources