Search code examples
ruby-on-railsrubyrubygemsgemfilegemfile.lock

How to specify Gemfile so that it won't install a specific version of a gem


I'm new to ruby, and I'm trying to specify a specific version number to rack. I want 1.4.5 installed and 1.5.2 removed, and I did gem uninstall rack --version 1.5.2, and specified the version number of rack to 1.4.5 in file Gemfile.lock.

But after I got up this morning I found that rack 1.5.2 was automatically installed back again, and the version of rack in Gemfile.lock was reset to 1.5.2. How can I specify a configuration so the machine doesn't automatically do the things above?


Solution

  • Dont edit the Gemfile.lock, write this in the Gemfile:

    gem 'rack', '1.4.5'
    

    If you have some warning or error message, type bundle update rack

    Notice: Basically Gemfile.lock is the result of the Gemfile bundle