Use the Source, Luke!
If you have source control, look back into your history to find your Gemfile or the gemspec for your application or gem. If you just have a Gemfile.lock, then you should be able to build the application with bundle install
as long as Bundler has valid gem sources it can access.
You can also grep your source code for the require
keyword, and at least identify what modules you're looking for. You can also look at the top-level items in your Gemfile.lock to see what was in your Gemfile or gemspec when the lockfile was built.
As an example, part of the Gemfile.lock for Sinatra lists the following dependencies:
DEPENDENCIES
activesupport (~> 5.1.6)
json
minitest (~> 5.0)
nokogiri (!= 1.5.0)
puma
rack!
rack-protection!
rack-test (>= 0.6.2)
rake
sinatra!
sinatra-contrib!
twitter-text (= 1.14.7)
yard
The other sections have to do with sources, constraints, and other dependencies that get pulled in as a result of the core dependencies. Everything you need to rebuild a Gemfile is there, but there's no tool that I know of that will do it for you since a Gemfile.lock is built from a Gemfile, not the other way around.
While there's no easy way to reverse-engineer a Gemfile.lock into a Gemfile or gemspec, you can certainly build one from the top-level entries under the specs:
keys, as well as the DEPENDENCIES
key.
See Also