Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when loading libraries on OSX #438

Open
girardof opened this issue Apr 15, 2019 · 17 comments
Open

Error when loading libraries on OSX #438

girardof opened this issue Apr 15, 2019 · 17 comments
Assignees

Comments

@girardof
Copy link

Hello everyone,
I've been using for the past few days and so far everything is great. Recently I tried to integrate rmagick inside a Shoes app, I was able to install it using cshoes -c but when I try to open my app I get the following message :

Error in <unknown> line 0 | 2019-04-15 17:33:49 +0200
dlopen(/Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.3.0/gems/rmagick-3.0.0/lib/RMagick2.bundle, 9): Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib
  Referenced from: /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.3.0/gems/rmagick-3.0.0/lib/RMagick2.bundle
  Reason: Incompatible library version: RMagick2.bundle requires version 2.3.3 or later, but libruby.2.3.0.dylib provides version 2.3.0 - /Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.3.0/gems/rmagick-3.0.0/lib/RMagick2.bundle
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.3.0/gems/rmagick-3.0.0/lib/rmagick_internal.rb:22:in `<top (required)>'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/gems/2.3.0/gems/rmagick-3.0.0/lib/rmagick.rb:1:in `<top (required)>'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/girardo/Documents/Perso/gui/Glitcher/lib/animater.rb:1:in `<top (required)>'
glitcher.rb:8:in `require_relative'
glitcher.rb:8:in `<main>'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:353:in `eval'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:353:in `visit'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:139:in `show_selector'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:169:in `block (4 levels) in splash'

From what I understand rmagick need to use ruby v2.3.3 or more and Shoes is using 2.3.0 in my case. Is it be possible to specify the ruby version to use when opening my project ?
I'm currently on OSX V10.14.3 using Shoes 3.3.8 r3276 and rbenv.

Thank for your help and your work on Shoes.
Florian.

@girardof girardof changed the title Error when loading on OSX Error when loading libraries on OSX Apr 15, 2019
@ccoupe
Copy link

ccoupe commented Apr 15, 2019

Hi, Shoes 3.3.7 provides it's own ruby 2.3.7 so that should be good. Shoes 3.3.8 is beta, at best - did you build Shoes from source? The error message suggests that Shoes needs to be more specific in versioning it's dylib. we provide 2.3.0 (dylib) for any ruby 2.3.x we use - it's the 'normal' way but appears that isn't what rmagick thinks. There are several ways Shoes could have gotten this wrong.

If you're comfortable with symlinks you can look at how Shoes does it. I'll check my osx box later today.

@ccoupe
Copy link

ccoupe commented Apr 15, 2019

The gem doesn't build/install for me - probably homebrew reasons installing imagemagick. You can get better error messages by doing 'cshoes -g install rmagick` Mine seemed happy with Shoes' libruby.dylib version but it couldn't find the imagemagick .h files. Sigh. I'm on 10.11 so that may be part of the homebrew issues.

For symlinks you could can cd into /Applications/Shoes/Contents/MacOS/

$ ls -ld libruby*
$ ln -s libruby.2.3.0.dylib libruby.2.3.7.dylib 

It might get you going. Note: Shoes with the rmagick gem is not likely to be distributeable because of the dependency on imagemagick.

@girardof
Copy link
Author

Thank you for your help, I just tried using Shoes 3.7.7 from binaries and it's the same I can install the gem without issue but get the same error message when open my app. I tried also you idea of creating symlink inside the /Applications/Shoes/Contents/MacOS/ but again same result. But I'm not sure to understand why dlopen load /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib and not Applications/Shoes/Contents/MacOS/libruby.2.3.0.dylib.

@ccoupe
Copy link

ccoupe commented Apr 15, 2019

That is a good clue. It should not be opening from Frameworks. That suggest's that some library that
Shoes uses was tagged as needing /System/Library/Frameworks/Ruby.framework - odds are high its a shared library used/provided by imagemagick or possibly the rmagick gem spec is causing the confusion. Imagemagick has been difficult to get correct since it's beginning many, many years ago. Until I can get it installed on my system all you can do is learn/experiment. Your rmagick gem should be in ~/.shoes/+gem/gems/ and somewhere in there is an .so or .dylib or two. One of them likely has a reference to the Framework ruby. The otool cmd line program can list the library dependencies.

@ccoupe
Copy link

ccoupe commented Apr 15, 2019

It seems brew and imagemagick are known to be 'hard' to get correct. . Which version of imagemagick did you install, @girardof ? I'm running osx 10.13.6 and ImageMagick 7.0.8-40 seems to hit the problem in the linked issue.

UPDATE - after brew install imagemagick@6 I was able to get the rmagick gem installed and I'm getting the original error message about wrong version of libruby.2.3.0.dylib

UPDATE 2 - ah.. the gem install was done (by Shoes) in my rvm area (rbenv for you), not in ~/.shoes/+gem/ - that is wrong - Shoes should be insulated from any installed rubies.

UPDATE 3 - manual->furthermore->sample->simple->info shoes that rvm is bleeding into the Shoes ext/gem paths.

@ccoupe ccoupe self-assigned this Apr 16, 2019
@ccoupe ccoupe added the High label Apr 16, 2019
@ccoupe
Copy link

ccoupe commented Apr 16, 2019

Sigh... It seems this has been broken for a long time on OSX. I don't need it to build shoes so it never got good testing in the last couple of years. Basically, rubygems has a built-in love for finding ruby in homebrew or system frameworks. Shoes doesn't help by bleeding rvm info so that it seems to install gems properly but can't load them. I got the bleeding to stop by adding this hack to the end of lib/shoes/cache.rb

if ENV['GEM_HOME'] 
	$stderr.puts "Killing rvm in paths"
	$:.each do |p| 
	  if p =~ /(\.rvm)|(\.rbenv)/
			$:.delete(p)
		end
	end
end

Now we get useful information about whats not working from a ./cshoes -g install rmagick. In ~/.shoes/+gem/extensions/x86_64-darwin-14/2.3.0/rmagick-3.1.0/mkmf.log (it might be darwin-17 for @girardof ) it's not finding most of the ENV vars needed to compile. This will take some time to fix.

UPDATE: rmagick's extconf.rb has some blame here. It's making assumptions Shoes may not be able to meet.

@girardof
Copy link
Author

Thank you very much for your time and your answers. For ImageMagic I am also using the version 6, let me know if I can do something for you concerning this issue.

@ccoupe
Copy link

ccoupe commented Apr 16, 2019

@girardof Did you build Shoes from source? If so, there are several workarounds to explore: You can point the Ruby and GemLoc fields to point to your rbenv ruby and it will copy those into Shoes at build. That still may not be good enough for rmagick gem but who knows. Ideally, you could build a 'minosx' target but that's broken (but fixable and untested).

Or you can try a Jail Break. . I have my doubts with rmagick and jailbreak.

UPDATE: Jailbreak doesn't work with rmagick gem. Building from source with the latest commits does allow building Shoes with rvm/rbenv ruby and all gems in that ruby. Will only work of the builder's system (imagemagick and homebrew issues)

ccoupe pushed a commit that referenced this issue Apr 16, 2019
ccoupe pushed a commit that referenced this issue Apr 16, 2019
* can build 'osx' target using rvm and it's gems - unique situations only
@ccoupe
Copy link

ccoupe commented Apr 17, 2019

It's now complex enough to move this issue to Shoes 3.3.8 - no completion date - Sorry. The only way to get the rmagick gem working with Shoes 3..3.7 is to build your own Shoes from source and make sure that ruby and homebrew build for the same arch - x86_64-darwin17 for me on osx 10.13.6. @girardof probably has x86_64-darwin18 . BUT shoes as I distribute it, is actually for osx 10.10 (aka x86_64-darwin13) . Getting Shoes (binary download) to build gems for darwin13 is a deep dive into gem internals.

@ccoupe ccoupe added Normal OSX and removed High labels Apr 17, 2019
ccoupe pushed a commit that referenced this issue Apr 17, 2019
@ccoupe
Copy link

ccoupe commented Apr 18, 2019

@girardof I've got a OSX Shoes 3.3.8 beta with the rmagick gem inside. Download. The gem should work for you since your brew probably installed the imagemagick dylibs the same place my homebrew did. FWIW, you don't have to replace the Shoes in /Applications to test it. Just drag it somewhere else and create a cshoes file to point to that.

@girardof
Copy link
Author

@ccoupe That's great, thank you for your hard work.

ccoupe pushed a commit that referenced this issue Apr 24, 2019
* osx: './cshoes -g install rmagick' works. or 'bluecloth'
    Cobbler and Shoes.setup - not yet.
* create some targets for 64 bit Ruby Windows building. Experiment.
@ccoupe
Copy link

ccoupe commented Apr 24, 2019

I managed to get some things working properly for shoes 3.3.8. ./cshoes -g env now displays properly and ./cshoes -g install rmagick builds and installs the gem properly. There are prerequisites for OSX

  1. You need homebrew installed and used that to install imagemagick.
  2. You have an Apple developer ID - free is OK.
  3. You have xcode-command-line tools installed which means you have Xcode installed.
  4. You have the SDK that Shoes uses (10.10) - in /Applications/xcode/...../SDK/

These are not trivial things. Note: an Xcode update will wipe out old SDK's so use symlinks in /Apllications/xCode..../ . The Cobbler/Shoes.setup() GUI code needs updating but that seems doable.

@ccoupe
Copy link

ccoupe commented Apr 26, 2019

Getting the rmagick gem to load is one thing. Getting it to work is something else. Shoes has a real problem here. I believe it depends on how the ruby inside Shoes is built - currently libruby.xxx.dylib is built to use @executable_path for loading. All gems are built with that assumption. That assumption won't work for the other dylibs Imagemagick wants (homebrew has absolute paths which should work, in theory - but don't in practice. I did have Shoes built with a ruby from homebrew and that rmagick gem did run a tiny test. Of course the display method won't work unless you have X11 installed and I don't. I've can't think of a way this gem would work with a downloaded Shoes. Still pondering what can be done but I'm not hopeful.

The rmagick gem uses the old memory management macros that stopped working in Ruby 2.4 - it compiles but beware, segfaults will occur unless rmagick doesn't let ruby manage the gc for it's objects. Either way, it's trouble and I've got other things to fix.

ccoupe pushed a commit that referenced this issue May 1, 2019
it's easy for the gem (rmagick in partular) to not work. It's an
OSX and ruby thing. Shoes only looks like ruby.
ccoupe pushed a commit that referenced this issue May 15, 2019
@apjanke
Copy link

apjanke commented May 27, 2019

I'm having what may be the same problem with the hpricot gem. I'm a Shoes newbie, so sorry if I've gotten this wrong.

I'm running Shoes 3.3.7 downloaded from http://shoesrb.com/downloads/. I'm running on a macOS 10.14.5 box. I have Homebrew installed, and a Homebrewed ruby 2.6.3, but I don't think that's relevant.

My Shoes app attempts to depend on hpricot by doing this early in the application code:

Shoes.setup do
  gem "hpricot"
end

When I run my app, I can see the progress meter for it fetching and building hpricot. But after that happens, I get this error:

Warn in <unknown> line 0 | 2019-05-27 07:49:19 -0400
Ignoring jaro_winkler-1.3.7 because its extensions are not built.  Try: gem pristine jaro_winkler --version 1.3.7

Error in <unknown> line 0 | 2019-05-27 07:49:49 -0400
dlopen(/Users/janke/.shoes/+gem/gems/hpricot-0.8.6/lib/hpricot_scan.bundle, 9): Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib
  Referenced from: /Users/janke/.shoes/+gem/gems/hpricot-0.8.6/lib/hpricot_scan.bundle
  Reason: Incompatible library version: hpricot_scan.bundle requires version 2.3.3 or later, but libruby.2.3.0.dylib provides version 2.3.0 - /Users/janke/.shoes/+gem/gems/hpricot-0.8.6/lib/hpricot_scan.bundle
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/janke/.shoes/+gem/gems/hpricot-0.8.6/lib/hpricot.rb:20:in `<top (required)>'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/janke/local/repos/peaksprints/lib/setup.rb:159:in `<top (required)>'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
opensprints.rb:125:in `<main>'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:353:in `eval'
/Applications/Shoes.app/Contents/MacOS/lib/shoes.rb:353:in `visit'
/Applications/Shoes.app/Contents/MacOS/lib/shoes/setup.rb:81:in `block (2 levels) in setup_app'

That looks like the same issue OP encountered with rmagick?

I download the Shoes 3.3.8 beta (build 3.3.8 r3350), deleted my ~/.shoes folder, and tried again (running the Shoes 3.3.8 beta from my Downloads folder). But with that one I got an error when trying to install the activesupport 2.3.8 gem, which my app also needs. (The progress dialog just says "Error while installing activesupport" and there's no stack trace in the Shoes Console.)

I think I can work around this by migrating my app to Nokogiri, but I hear that's hard to build correctly, too.

UPDATE: Nokogiri installed just fine. That's a workaround for me.

@ccoupe
Copy link

ccoupe commented May 27, 2019

Hpricot is very very old. Shoes used to include it but now we include nokogiri - you wont have to build it. We also include activesupport so you shouldn't need or try to replace it - them manual uses it, indirectly.

There is no need for Shoes.setup for built in gems like nokogiri and activesupport and some danger that they will attempt to install later versions which if built (big if) might confuse Shoes or us as to which to use.

@apjanke
Copy link

apjanke commented May 27, 2019

Using the built-in nokogiri and activesupport seems to work fine. Thanks!

Is there somewhere with a list of all the gems that come built in to each Shoes version?

@ccoupe
Copy link

ccoupe commented May 27, 2019

Is there somewhere with a list of all the gems that come built in to each Shoes version?

As mentioned else where, $ ./cshoes -g list -l will do that. Also the Cobbler->Manage Gems-> List Local if you like a GUI. You can also open the contents of the Shoes.app on OSX and navigate inside to Contents/MacOS/lib/ruby/gems/2.4.0/specifications - but that's harder to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants