Understanding Gemfile.lock: Is it okay to delete Gemfile.lock then run bundle install again?

☆樱花仙子☆ 提交于 2019-12-20 11:09:19

问题


We would test this, but don't want to risk ruining our dev environment if this isn't supposed to happen.

Is it okay to delete Gemfile.lock?

We're on Rails 3.0.6.


回答1:


You're probably not going to ruin your dev environment. However, you might end up with newer versions of gems than you had before. It depends on how you have defined them in Gemfile.

If you're using entries like:

gem "rails"

Then you'll get the latest rails gem, whatever that might be.

If you're using entries like:

gem "rails", "3.2.11"

Then you'll get 3.2.11 again.

Having said all of that, this is what branches are for. Make a branch in git, hg, or whatever you're using, blow away Gemfile.lock, run bundle install, and then check your test suite. If it's horrible, then you can abandon the branch while you figure out what went wrong.

Another tip: Any time I've ever wanted to do this, I found that it was useful to clear out all of my installed gems as well. If you're using rvm with gemsets this is as simple as running

rvm gemset empty [gemset_name]




回答2:


It's ok to delete Gemfile.lock, just run

bundle install

to generate a new Gemfile.lock. Take note that if you didn't specify any version of a gem on your Gemfile, you will always get the latest




回答3:


I know this has been answered already, but for everyone else that happens to come across this post on Google, you should know that command bundle init will regenerate the Gemfile.



来源:https://stackoverflow.com/questions/14286872/understanding-gemfile-lock-is-it-okay-to-delete-gemfile-lock-then-run-bundle-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!