I was tinkering with my Mac computer and did several administrative tasks that ended up messing up my rails and gem install processes. I would run rails or gem install and terminal would spew a bunch of error messages stating libcrypto.1.0.0.dylib and libssl.1.0.0.dylib could not be loaded.
[topads][/topads]
Below the complete error messages
esilva@Esau-MBP:~$ rails -v /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require': dlopen(/Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/digest/md5.bundle, 9): Library not loaded: /usr/local/lib/libssl.1.0.0.dylib (LoadError) Referenced from: /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/digest/md5.bundle Reason: image not found - /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/digest/md5.bundle from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require' from /Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/railties-4.2.5/lib/rails/generators/app_base.rb:1:in `<top (required)>' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:1:in `<top (required)>' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/railties-4.2.5/lib/rails/commands/application.rb:2:in `<top (required)>' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/railties-4.2.5/lib/rails/cli.rb:14:in `<top (required)>' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require' from /Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/railties-4.2.5/bin/rails:9:in `<top (required)>' from /Users/esilva/.rvm/gems/ruby-2.2.4/bin/rails:23:in `load' from /Users/esilva/.rvm/gems/ruby-2.2.4/bin/rails:23:in `<main>' from /Users/esilva/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval' from /Users/esilva/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
esilva@Esau-MBP:~$ gem install lunchy Error loading RubyGems plugin "/Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/executable-hooks-1.3.2/lib/rubygems_plugin.rb": dlopen(/Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle, 9): Library not loaded: /usr/local/lib/libssl.1.0.0.dylib Referenced from: /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle Reason: image not found - /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle (LoadError) Error loading RubyGems plugin "/Users/esilva/.rvm/gems/ruby-2.2.4@global/gems/gem-wrappers-1.2.7/lib/rubygems_plugin.rb": dlopen(/Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle, 9): Library not loaded: /usr/local/lib/libssl.1.0.0.dylib Referenced from: /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle Reason: image not found - /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle (LoadError) ERROR: Loading command: install (LoadError) dlopen(/Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle, 9): Library not loaded: /usr/local/lib/libssl.1.0.0.dylib Referenced from: /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle Reason: image not found - /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass
My next step was to find if those files indeed did not exists
esilva@Esau-MBP:~$ ls -la /usr/local/lib/libcrypto.1.0.0.dylib ls: /usr/local/lib/libcrypto.1.0.0.dylib: No such file or directory
Solution
First you would need to find the new location of the missing .dylib files
esilva@Esau-MBP:~$ sudo find / -name libssl.1.0.0.dylib find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory /Library/pgAgent/lib/libssl.1.0.0.dylib /opt/local/lib/libssl.1.0.0.dylib /usr/local/Cellar/openssl/1.0.1j_1/lib/libssl.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2d/lib/libssl.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2g/lib/libssl.1.0.0.dylib
esilva@Esau-MBP:~$ sudo find / -name libcrypto.1.0.0.dylib find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory /Library/pgAgent/lib/libcrypto.1.0.0.dylib /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/Cellar/openssl/1.0.1j_1/lib/libcrypto.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2d/lib/libcrypto.1.0.0.dylib /usr/local/Cellar/openssl/1.0.2g/lib/libcrypto.1.0.0.dylib
Then use this handy tool called install_name_tool to relink binaries.
The way to use it is sudo install_name_tool -change [/old/path/.dylib] [/new/path/.dylib] [/path/to/.bundle]
esilva@Esau-MBP:~$ sudo install_name_tool -change /usr/local/lib/libssl.1.0.0.dylib /Library/pgAgent/lib/libssl.1.0.0.dylib /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/digest/md5.bundle
esilva@Esau-MBP:~$ sudo install_name_tool -change /usr/local/lib/libssl.1.0.0.dylib /Library/pgAgent/lib/libssl.1.0.0.dylib /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle
esilva@Esau-MBP:~$ sudo install_name_tool -change /usr/local/lib/libcrypto.1.0.0.dylib /Library/pgAgent/lib/libcrypto.1.0.0.dylib /Users/esilva/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/x86_64-darwin15/openssl.bundle
And after making that change
esilva@Esau-MBP:~$ rails -v Rails 4.2.5
esilva@Esau-MBP:~$ gem install lunchy Fetching: lunchy-0.10.4.gem (100%) ------- Thanks for installing Lunchy. We know you're going to love it! If you want to add tab-completion (for bash), add the following to your .bash_profile, .bashrc or .profile LUNCHY_DIR=$(dirname `gem which lunchy`)/../extras if [ -f $LUNCHY_DIR/lunchy-completion.bash ]; then . $LUNCHY_DIR/lunchy-completion.bash fi or add the following to your .zshrc for ZSH LUNCHY_DIR=$(dirname `gem which lunchy`)/../extras if [ -f $LUNCHY_DIR/lunchy-completion.zsh ]; then . $LUNCHY_DIR/lunchy-completion.zsh fi ------- Successfully installed lunchy-0.10.4 Parsing documentation for lunchy-0.10.4 Installing ri documentation for lunchy-0.10.4 Done installing documentation for lunchy after 0 seconds 1 gem installed
Everything working good now 🙂
[bottomads][/bottomads]