Out of curiosity, what's your tool(s)?
Out of curiosity, what's your tool(s)?
We get around the 'sudo gem' problem by distributing our tool as a git repo, then bootstrapping a vendored install of Bundler to manage our own little gem path using /usr/bin/ruby. We take care to remove most ruby-related env vars during init so we're safe from whatever crazy RBENV or RVM shenanigans are happening on the system. This setup works fine, but we don't get recent language perf improvements since we use system Ruby.
Like you, we distribute it as a git repo. We don't use bootsnap with it, but we have a few strategies that give us reasonable times:
$ time ./bin/dev help up >/dev/null
0.07s user 0.03s system 98% cpu 0.102 total
* We vendor every dependency (and try really hard to avoid them in the first place -- we have 5, only one of which is >5 source files), and prevent loading rubygems. Rubygems takes a long time to load. Our shebang is `/usr/bin/ruby --disable-gems`.* Autoload everything. Our toplevel lib/dev.rb file is a whole-namespace autoload registry. Only a few other constants are defined there. Everything is loaded just by cascading through autoloads.
* Defer stdlib requires: We load most stdlib features within the method body from which they're used. Several stdlib features take a surprisingly long time to load.
- openssl
- digest
- resolv
- rgl
- net/ssh
- (internal http client)
- (internal package manager)
Doing this saved about 40% of our CLI boot time:
$ time /usr/local/bin/airlab > /dev/null
/usr/local/bin/airlab > /dev/null 0.27s user 0.15s system 79% cpu 0.521 total
$ git co jake--no-rubygems
$ time /usr/local/bin/airlab > /dev/null
/usr/local/bin/airlab > /dev/null 0.24s user 0.08s system 98% cpu 0.326 total