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.
Related
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.
I have a set of old gems I can't install from internet.
My plan is to copy what is in production server to my local environment.
gem env to know where gems are being installed.
cd to_gems_dir
there are a of of folders there,
I copied cache folder to my local machine
under vendor/cache inside project folder.
run bundle to check everything is OK.
But is not, bundler tries to install some gems, some others not. I don't know too much about bundler and gems envs, so my question is what am I doing wrong here? any other ideas to replicate remote gem set in my local machine?
This is what I did:
for file in vendor/cache/*; do gem i --local $file; done
Then all gems where installed, finally:
bundle check
The Gemfile's dependencies are satisfied
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.
I am trying to run an app taken off Github.
I have run bundle install to install required gems from the Gemfile. However when running the app, an error message tells me the gems installed are the wrong version.
On inspecting the Gemfile.lock I note that the versions are older than the gems installed. (i.e. I have newer versions of gems installed and the application requires older gems.)
Is there a quick way to install all the gems as per the versions described in the Gemfile.lock file? Alternatively is there a method to ignore that file?
Gemfile:
source 'http://rubygems.org'
gem 'rails', "3.0.9"
gem "sass"
..
Gemfile.lock:
sass (3.1.1)
..
In the above example, even though sass is installed the app specially requires version 3.1.1.
With a valid Gemfile.lock file, bundle install alone should be sufficient, unless some particular gem version has been yanked. In that case you would need to look for an alternative gem version that is still currently available (usually bundle update name_of_yanked_gem would suffice).
About the sass 3.1.1, it is not so much that the application requires that particular version, but rather, that was likely the newest version available when the Gemfile.lock was last generated/updated given the overall version constraints as specified in Gemfile. As you have listed, there is no version range specified for sass itself, but other gems may impose further constraints if they have sass as a dependency.
Outright ignoring Gemfile.lock is not a good idea as under normal circumstances it will be specifying the gem versions that were last known to be still usable with the application.
try this ..
bundle install --deployment
With above deployment option, bundle then reads from Gemfile.lock.
What's more, the gems are installed to directory vendor/bundle, with the bundle directory being auto created.
Also, new directory .bundle is created directly under the rails root directory, and has a file named config, whose content is as follows ...
BUNDLE_FROZEN: '1'
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
Hope the above works for you.
Make sure you're running the web server with bundle execute rails server
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.