Cursed Bundler: Using go get to install Ruby Gems
nesbitt.io·2d·
🥖Bun
Preview
Report Post

Here’s a thought experiment. What if Ruby had require "github.com/rails/rails" and you used go get to fetch it? Set GOPATH to a Ruby load path, and Go’s module fetcher becomes your transport layer. The Go team did not intend this. But it works. Consider this a gift from the Ghost of Package Managers Yet to Come.

The setup would look something like this:

export GOPATH=/usr/local/lib/ruby/vendor_gems
go get github.com/rack/[email protected]

Go fetches the module, and now you have:

/usr/local/lib/ruby/vendor_gems/pkg/mod/
github.com/
rack/
[email protected]/
lib/
rack.rb
rack/
request.rb
response.rb
...

Build your load path from the lockfile:

RUBYLIB=/usr/local/lib/ruby/vendor_gems/pkg/mod/github.com/rack/[email protected]/lib

Now require "rack"

Similar Posts

Loading similar posts...