planetscale-ruby
planetscale-ruby copied to clipboard
Cannot find FFI library
Having troubles running the generator (or requiring the gem):
$ bundle exec rails generate planetscale:install --organization $ORG_NAME
/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/proxy/planetscale-darwin.so': dlopen(/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/proxy/planetscale-darwin.so, 5): image not found (LoadError)
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:99:in `map'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:99:in `ffi_lib'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:30:in `<class:Proxy>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:14:in `<module:PlanetScale>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:6:in `<main>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `each'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `block in require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `each'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler.rb:173:in `require'
from /Users/adc/Developer/ayrton/careerwatchlist/config/application.rb:26:in `<top (required)>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/Users/adc/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/Users/adc/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
Some debug info:
$ pscale --version
pscale version 0.38.0 (build date: 2021-05-20T17:55:50Z commit: 1bd7252)
$ bundle list | grep planetscale
* planetscale (0.1.0)
$ bundle list |grep ffi
* ffi (1.15.1)
Here's a tree of a bundle open:
../
planetscale-0.1.0/
| bin/
| lib/
| | generators/
| | planetscale/
| | planetscale.rb
| vendor/
| | github.com/
| | go.uber.org/
| | golang.org/
| | google.golang.org/
| | modules.txt
| Gemfile
| LICENSE
| README.md
| Rakefile
| controller.go
| go.mod
| go.sum
| planetscale.gemspec
| proxy.go
| tags
Is it possible bin/setup isn't called before the gem was published? Looks like this changed as of https://github.com/planetscale/planetscale-ruby/commit/d908cf6c844dc003f9933ff91784169948718276
Hey @ayrton!
Pardon the late reply, I'll take a look at this today. It does seem possible that there was a mistake when publishing the Gem, as it looks like the shared libraries are missing from the looks of that bundle open.
Are you installing the version from rubygems, or the version from GitHub packages (https://github.com/planetscale/planetscale-ruby/packages/775007)?
Are you installing the version from
rubygems, or the version from GitHub packages (https://github.com/planetscale/planetscale-ruby/packages/775007)?
Installed from rubygems via a bundle add planetscale
Thanks @ayrton, I can definitely confirm that the rubygems version doesn't contain the compiled shared libraries. I'm not sure how that happened, but we'll get that updated (cc @mscoutermarsh).
For now, if you install the Gem from GitHub Packages, it should contain everything that's needed. I will follow up here as soon as we get it fixed on rubygems as well.
Seems to have similar issues when installed through the GH registry:
diff --git a/Gemfile b/Gemfile
index 77a0e81..baadb91 100644
--- a/Gemfile
+++ b/Gemfile
@@ -15,7 +15,6 @@ gem 'faraday_middleware'
gem 'mysql2', '~> 0.5'
gem 'oj'
-gem 'planetscale', '~> 0.1.0'
gem 'puma', '~> 5.0'
gem 'rack-timeout'
gem 'rails', github: 'rails/rails', branch: '6-1-stable'
@@ -30,6 +29,10 @@ gem 'stripe_event', '~> 2.3'
gem 'turbo-rails', '~> 0.5'
gem 'webpacker', '6.0.0.beta.7'
+source 'https://rubygems.pkg.github.com/planetscale' do
+ gem 'planetscale', '~> 0.1.0'
+end
+
group :development, :test do
gem 'byebug'
gem 'rubocop', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 91621f8..73145ec 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -181,8 +181,6 @@ GEM
parallel (1.20.1)
parser (3.0.1.1)
ast (~> 2.4.1)
- planetscale (0.1.0)
- ffi (~> 1)
public_suffix (4.0.6)
puma (5.3.2)
nio4r (~> 2.0)
@@ -305,6 +303,12 @@ GEM
nokogiri (~> 1.8)
zeitwerk (2.4.2)
+GEM
+ remote: https://rubygems.pkg.github.com/planetscale/
+ specs:
+ planetscale (0.1.0)
+ ffi (~> 1)
+
PLATFORMS
ruby
@@ -324,7 +328,7 @@ DEPENDENCIES
minitest-spec-rails
mysql2 (~> 0.5)
oj
- planetscale (~> 0.1.0)
+ planetscale (~> 0.1.0)!
puma (~> 5.0)
rack-timeout
rails!
$ rails c
/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/proxy/planetscale-darwin.so': dlopen(/Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/proxy/planetscale-darwin.so, 5): image not found (LoadError)
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:99:in `map'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.1/lib/ffi/library.rb:99:in `ffi_lib'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:30:in `<class:Proxy>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:14:in `<module:PlanetScale>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.1.0/lib/planetscale.rb:6:in `<main>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `each'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:61:in `block in require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `each'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler/runtime.rb:50:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.2.15/lib/bundler.rb:173:in `require'
from /Users/adc/Developer/ayrton/careerwatchlist/config/application.rb:26:in `<top (required)>'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /Users/adc/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/Users/adc/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/Users/adc/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
Hey @ayrton - I've gone ahead and bumped the version to 0.2.0 and pushed a new Gem up to Rubygems. That shows as >11 MB instead of under a megabyte, and gem unpack shows the appropriate shared libraries on my end.
Let me know if that works for you, otherwise I will be very confused!
@nickvanw working now 🎉🎉
Happy to hear it! If you come up with anything weird while you're using it, please do open up issues; the more feedback the better!
I just installed 0.2.1 on an M1 laptop and I'm seeing a similar-ish problem.
/Users/nettofarah/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.3/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/Users/nettofarah/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.2.1/proxy/planetscale-darwin.so': dlopen(/Users/nettofarah/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.2.1/proxy/planetscale-darwin.so, 5): no suitable image found. Did find:
/Users/nettofarah/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.2.1/proxy/planetscale-darwin.so: mach-o, but wrong architecture
/Users/nettofarah/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/planetscale-0.2.1/proxy/planetscale-darwin.so: mach-o, but wrong architecture (LoadError)
It seems like the gem can find the binary, but the architecture doesn't seem to match
Thank you @nettofarah, re-opening!