Reputation: 485
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.
Upvotes: 16
Views: 25199
Reputation: 131
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.
Upvotes: 13
Reputation: 7101
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.
Upvotes: 12
Reputation: 12273
Make sure you're running the web server with bundle execute rails server
Upvotes: 7