rubyonmac / rubyonmac-issues

Bug fixes and feature request tracking for Ruby on Mac.
https://www.rubyonmac.dev
3 stars 0 forks source link

Error in ffi / glib / jekyll #8

Closed afoeder closed 2 years ago

afoeder commented 2 years ago

Hi, I don't know if this kind of error is covered by your script or if you could help; it's basically the reason why I've bought it but without luck:

In which version of Ruby on Mac did you find the bug? Prime

Describe the bug I am trying to run Jekyll and still get the following error, both after normal and reset mode:

$ bundle exec jekyll build
bundler: failed to load command: jekyll (/Users/adrian/.gem/ruby/2.7.6/bin/jekyll)
Traceback (most recent call last):
    38: from /Users/adrian/.rubies/ruby-2.7.6/bin/bundle:25:in `<main>'
    37: from /Users/adrian/.rubies/ruby-2.7.6/bin/bundle:25:in `load'
    36: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/exe/bundle:36:in `<top (required)>'
    35: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    34: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/exe/bundle:48:in `block in <top (required)>'
    33: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli.rb:25:in `start'
    32: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    31: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli.rb:31:in `dispatch'
    30: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    29: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    28: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    27: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli.rb:479:in `exec'
    26: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli/exec.rb:23:in `run'
    25: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli/exec.rb:58:in `kernel_load'
    24: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/cli/exec.rb:58:in `load'
    23: from /Users/adrian/.gem/ruby/2.7.6/bin/jekyll:25:in `<top (required)>'
    22: from /Users/adrian/.gem/ruby/2.7.6/bin/jekyll:25:in `load'
    21: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll-4.2.0/exe/jekyll:11:in `<top (required)>'
    20: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll-4.2.0/lib/jekyll/plugin_manager.rb:53:in `require_from_bundler'
    19: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler.rb:187:in `require'
    18: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:44:in `require'
    17: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:44:in `each'
    16: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:55:in `block in require'
    15: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:55:in `each'
    14: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
    13: from /Users/adrian/.gem/ruby/2.7.6/gems/bundler-2.3.16/lib/bundler/runtime.rb:60:in `require'
    12: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag.rb:5:in `<top (required)>'
    11: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag.rb:5:in `require_relative'
    10: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag/images.rb:2:in `<top (required)>'
     9: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag/images.rb:2:in `require_relative'
     8: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag/images/generated_image.rb:1:in `<top (required)>'
     7: from /Users/adrian/.gem/ruby/2.7.6/gems/jekyll_picture_tag-2.0.3/lib/jekyll_picture_tag/images/generated_image.rb:1:in `require'
     6: from /Users/adrian/.gem/ruby/2.7.6/gems/ruby-vips-2.0.17/lib/ruby-vips.rb:1:in `<top (required)>'
     5: from /Users/adrian/.gem/ruby/2.7.6/gems/ruby-vips-2.0.17/lib/ruby-vips.rb:1:in `require'
     4: from /Users/adrian/.gem/ruby/2.7.6/gems/ruby-vips-2.0.17/lib/vips.rb:36:in `<top (required)>'
     3: from /Users/adrian/.gem/ruby/2.7.6/gems/ruby-vips-2.0.17/lib/vips.rb:45:in `<module:GLib>'
     2: from /Users/adrian/.gem/ruby/2.7.6/gems/ffi-1.15.0/lib/ffi/library.rb:99:in `ffi_lib'
     1: from /Users/adrian/.gem/ruby/2.7.6/gems/ffi-1.15.0/lib/ffi/library.rb:99:in `map'
/Users/adrian/.gem/ruby/2.7.6/gems/ffi-1.15.0/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'glib-2.0.0': dlopen(glib-2.0.0, 0x0005): tried: 'glib-2.0.0' (no such file), '/usr/local/lib/glib-2.0.0' (no such file), '/usr/lib/glib-2.0.0' (no such file), '/Users/adrian/Code/vn/www-public/glib-2.0.0' (no such file). (LoadError)
Could not open library 'libglib-2.0.0.dylib': dlopen(libglib-2.0.0.dylib, 0x0005): tried: 'libglib-2.0.0.dylib' (no such file), '/usr/local/lib/libglib-2.0.0.dylib' (no such file), '/usr/lib/libglib-2.0.0.dylib' (no such file), '/Users/adrian/Code/vn/www-public/libglib-2.0.0.dylib' (no such file)

Details about your Mac Homebrew was installed.

Please attach the Ruby on Mac log file

Thanks again!

monfresh commented 2 years ago

Hi @afoeder. Thanks for buying Ruby on Mac!

As mentioned in this FAQ, Ruby on Mac cannot automatically fix issues with existing projects, especially those with outdated gems. The issues are usually unique to each project. Some issues are more complex to fix than others, which is why I'm introducing the Pro version that includes a 30-min consultation with me for help with older projects.

However, in your case, I'm pretty sure the solution is simple: you need to update the ffi gem.

The rule of thumb to remember is to see if there is a newer version of the gem that is causing the error. This is usually the gem mentioned at the bottom of the error log. You can check all outdated gems by running bundle outdated. If so, update it. That resolves most errors.

You are using version 1.15.0 of ffi which is not compatible with M1 Macs. You need to update it to at least 1.15.2, but I recommend updating to the latest version. You can do that by running this command:

bundle update ffi 

If that shows an error coming from another gem, or some sort of conflict, then you might need to update several gems at the same time. For example:

bundle update ffi [some other gem]

I hope this helps.

monfresh commented 2 years ago

You might also find this guide helpful: https://www.moncefbelyamani.com/how-to-update-gems-in-your-gemfile/

monfresh commented 2 years ago

Since I haven't heard back, I'm assuming updating ffi solved the issue and I'm closing the issue. Feel free to reopen if you're still having issues.

afoeder commented 2 years ago

Hi @monfresh sorry for not having replied; I also didn't want to stretch your willingness to help :) After bundle update ffi I still get basically the same error message but from a slightly newer ffi version,

/Users/adrian/.gem/ruby/2.7.6/gems/ffi-1.15.5/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'glib-2.0.0': dlopen(glib-2.0.0, 0x0005): tried: 'glib-2.0.0' (no such file), '/usr/local/lib/glib-2.0.0' (no such file), '/usr/lib/glib-2.0.0' (no such file), '/Users/adrian/Code/acme/www-public/glib-2.0.0' (no such file). (LoadError)
Could not open library 'libglib-2.0.0.dylib': dlopen(libglib-2.0.0.dylib, 0x0005): tried: 'libglib-2.0.0.dylib' (no such file), '/usr/local/lib/libglib-2.0.0.dylib' (no such file), '/usr/lib/libglib-2.0.0.dylib' (no such file), '/Users/adrian/Code/acme/www-public/libglib-2.0.0.dylib' (no such file)

I am also not at all a ruby guy (that's why I hoped the magic script would chime in anyways) so I'm limited to copy the error message to google but there's also not much stuff. I hope time fixes it when enough other people stumble upon this problem.

thanks and best! -Adrian

monfresh commented 2 years ago

Hi @afoeder. Can you please send me the output of these commands:

brew doctor
cat ~/.zshrc
cat ~/.zprofile
cat ~/.bash_profile
cat ~/.profile

And can you also please attach your rom-prime.log file that's in your Home folder?

afoeder commented 2 years ago

Sure!

$ brew doctor
Your system is ready to brew.

$ cat ~/.zshrc

alias rom='cd ~/rubyonmac &&/usr/bin/env bash ~/rubyonmac/rom-prime 2>&1 | tee ~/rom-prime.log'

source /opt/homebrew/opt/chruby/share/chruby/chruby.sh

source /opt/homebrew/opt/chruby/share/chruby/auto.sh

chruby ruby-3.1.2

chruby ruby-2.7.6

eval "$(nodenv init -)"

nodenv global 16.15.1

$ cat ~/.zprofile

eval $(/opt/homebrew/bin/brew shellenv)

$ cat ~/.bash_profile
cat: /Users/adrian/.bash_profile: No such file or directory

$ cat ~/.profile
cat: /Users/adrian/.profile: No such file or directory

Thanks again!

monfresh commented 2 years ago

Everything looks good from what you sent, so I'm pretty sure the problem is specific to your Jekyll project. Here's how we can check:

  1. Let's create a brand new jekyll site to test with:

    cd ~
    mkdir testing-jekyll && cd testing-jekyll
  2. Create a new jekyll site
    chruby 2.7.6
    jekyll new .
  3. Try building the jekyll site:
    bundle exec jekyll build
  4. Try running jekyll:
    bundle exec jekyll serve

If that works, then the issue is specific to your project. One more thing you can try is to update all the gems at once, but do that in a separate git branch in case it causes more errors:

git checkout -b update-gems
bundle update

If that still doesn't resolve the ffi issue, I'd be happy to help you via a Zoom session. If you're interested, let me know and I'll email you a discount coupon to upgrade to the Ultimate version, which includes a 30-min session with me (which normally costs $150).

If I don't fix your Jekyll project, then I'll give you your money back, and you can keep the Ultimate version.

monfresh commented 2 years ago

One more thing you can try is to go through the gems in your project and make sure you have the required dependencies installed. If the error is complaining about not finding a tool, and updating ffi didn't fix it, then it most likely means one of your gems depends on something to be installed on your machine, which you would typically install via Homebrew.

I see the jekyll_picture_tag gem in your stack trace. Check their documentation.

afoeder commented 2 years ago

Man I'm such a moron, sorry for wasting your time:

brew install vips 🙄

I was distracted / put on the wrong path since ruby-vips et al was present and the error message "looked like it came from vips", hence "its lacking could not be the issue". But of course the actually underlying lib was not there, and with it apparently the glib, eventually.

As you've recommended, the docs of jekyll_picture_tag even state it.

So, thank you thousand times for your effort and your offering, eventually you did nudge me in the right direction. Just needed some rubberducking it seems :)

Thanks again!

monfresh commented 2 years ago

You're very welcome! I'm glad it all worked out.

Now that everything is working, could I ask you for a quick favor please? If you're on Twitter, could you write a testimonial about Ruby on Mac? You can mention @rubyonmac and/or @monfresh. Otherwise, would you mind filling out this short survey: https://tally.so/r/wAkaWm

Thanks!