Gem from github in a different directory - ruby-on-rails

Hi im a bit astonished,
why sometimes a gem (installed with bundle install) isn't stored in the Project/vendor folder, but instead in ~/.rvm/gems/ruby-1.9.3-p484/bundler/gems folder.
This issues that, assets from this gem are not getting precompiled.
Is there a decent ways for handling this.

Run bundle install --path specify_path_that_you_want
so it will always install all of your gems in that your specified directory.

Related

Bundle - copy-paste gems from another PC

I am trying to setup a rails application. The application depends on an enormously huge number of gems. The gems were preinstalled in the vendor/gems folder of a copy I obtained from a friend. Now, considering the unavailability of those closed source gems, bundle install --path /home/umang/projectname/vendor/gems fails with the message Could not find gemname in any of the sources. Is there a way I could copy-paste the gems from the vendor/gems/ folder into my gem installation directory and make bundle believe that they are there. I copied the directory from vendor/gems to my local gem installation directory, but bundle check still suggests that those gems are missing.
Okay, it is time I answer my own question.
1. Copy-paste the gems to your gem installation directory.
2. Remove the .bundle/config or fix the conflicting setting.

Install gems via ftp

Can you install your ruby gems via ftp? I mean just copy your local gem directory /var/lib/gems/1.9.1/gems and put it online with filezilla in the ruby>gems>gems directory.
The reason I want to do this is because with cPanel it gives me errors when trying to install some gems (like permission errors, some require ruby >=1.9.2 but I already have ruby 1.9.3). So is there a simple way?
Thanks!
Instead of copying your system's gem which may be ruby version specific, you could place all the required gems sources in your application's lib directory and reference them in your Gemfile. Not that you cannot place these sources in other directories.
Place gem source in your local application e.g. #{Rails.root}/lib/my_gem and update your Gemfile to reference the gem using:
gem "my_gem", path: "lib/my_gem"
Then run bundle install to install the sourced gem in your application.
and you can run
gem server
then add the source
http://some.ip:8808
there you'll have shared the gem installed in that system

Rails: purpose of downloading gems locally

Generally, if I need a gem, I put it in the Gemfile and bundle install. However, I don't understand if there is a benefit to downloading the gems locally first with gem install _____. Is there any benefit to this? Does bundle install no longer have to connect to the net in that situation?
Bundler installs the gems located in your Gemfile locally the same as if you ran gem install for each of those gems.
Gem install needed for gems that can be used outside of bundler applications. For example request-log-analyzer need to be installed outside of any apps for be available in command line.
I myself use gem install _______ then i use bundle install --local which doesn't require internet connection if the gem is found locally but will return an error if the gem was not found locally...
I find this method faster in downloading and installing gems, plus if the gems are found locally then i have also the benefit of altering the gemfile and install the gems without having internet connection.

Is it possible to use Rails 3 without bundler?

We are deploying our apps as RPM linux packages (with all the dependencies also packaged in RPMs). It turns out that bundler is problematic in this situation and it only complicates our build process - we would like to get rid of it.
Is it possible to run Rails 3 app without it forcing Ruby to use system rubygems? How?
In the book Rails 3 Way there is a statement describing that the easiest way to remove Bundler is to delete Gemfile* files. That's it. It just works.
You could install all gems manually using gem install gemname. In your situation or if you do not have sudo rights it is perhaps recommendable to install the gem files locally in your user directory using
gem install --user-install gemname
You can also install your gems locally with bundler:
bundle install --path ~/.gem

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