How to install gems based on Gemfile.lock (without Gemfile)

独自空忆成欢 提交于 2019-12-25 08:27:11

问题


Usually, people will use bundle install to install gems. But it require Gemfile and Gemfile.lock(optional).

My situation is a little different. I only have Gemfile.lock. So how can I install all these gems based on bundle command.

I tried bundle install --deployment. But I got Could not locate Gemfile error.


OK. I asked this question in bundler github issues. Their member gave me a good answer: https://github.com/bundler/bundler/issues/5293#issuecomment-269978731

For summary -- I CAN NOT DO THAT

I gave up to run bundle install with Gemfile.lock only. But I still need to solve my problem. And in my Gemfile, I don't have any special options like groups, platforms, install conditionals. So I wrote a script(gem) to revert the Gemfile.lock to Gemfile for my docker image.

[SOLVED]


回答1:


You can use deployment mode of a bundler.




回答2:


With only gemfile.lock, you can run

bundle install --deployment 

The only catch is that this command installs gems to the vendor/bundle instead of your normal gem bundle path. it is so because it is expected to be used only in production.

It works well all the same though.




回答3:


Have you tried simply running the gem install directly in your terminal? That way you won't need to use a Gemfile at all.

For example, with the devise gem, you can just run $ gem install devise in your terminal and that will install the devise gem without adding it to your Gemfile.



来源:https://stackoverflow.com/questions/41359249/how-to-install-gems-based-on-gemfile-lock-without-gemfile

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