How do I uninstall openssl in /usr/lib? - ruby-on-rails

After installing the pg gem, I'm getting this error when I try to start the server on my local machine:
/Users/foo/.rvm/gems/ree-1.8.7-2011.12/gems/pg-0.14.0/lib/pg_ext.bundle: dlopen(/Users/foo/.rvm/gems/ree-1.8.7-2011.12/gems/pg-0.14.0/lib/pg_ext.bundle, 9): Library not loaded: #loader_path/../lib/libssl.dylib (LoadError)
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libssl.dylib provides version 0.9.8 - /Users/foo/.rvm/gems/ree-1.8.7-2011.12/gems/pg-0.14.0/lib/pg_ext.bundle
I have an up to date version of openssl installed on my machine via macports but it seems like the gem is looking at the older version that I have installed in /usr/lib for some reason (maybe something to do with a messed up #loader_path?).
'openssl version' gives me 'OpenSSL 1.0.1c 10 May 2012'
and 'which openssl' gives me '/opt/local/bin/openssl' as I expected
Any help is really appreciated. Thanks!

I just ran into this problem after updating to Mountain Lion. After checking that I had a proper OpenSSL version, I did the following.
$ ls /Library/PostgreSQL/9.1/lib/libssl*
Provided the following:
/Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
/Library/PostgreSQL/9.1/lib/libssl.dylib
/Library/PostgreSQL/9.1/lib/libssl.a
I copied the file as so:
$ sudo cp /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib /usr/lib/
Then linked:
$ cd /usr/lib
$ ln -sf libssl.1.0.0.dylib libssl.dylib
After that, I tried rails s again and the same error came up with a different file, so I repeated the process (libcrypto):
requires version 1.0.0 or later, but libcrypto.0.9.8.dylib
provides version 0.9.8
so:
$ sudo cp /Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib /usr/lib/
$ cd /usr/lib
$ ln -sf libcrypto.1.0.0.dylib libcrypto.dylib
See this question's answers for reference as well:
python pip install psycopg2 install error

Related

FFI::NotFoundError (Function 'OPENSSL_init_ssl' not found in [libssl.dylib])

I'm using Mac OS for development. Now I'm developing an app using Blockcypher API. With Ruby on Rails, when I try to send money using the Gem, it always return this error
FFI::NotFoundError (Function 'OPENSSL_init_ssl' not found in [libssl.dylib])
Already try to upgrade or downgrade the OpenSSL version on my mac but nothing happend and it so frustating. My friend on linux doesn't get this error, work perfectly on his device. Has anyone ever got this error?
I had the same problem, after research for one day I found the solution for rvm ruby-2.7.2 version:
Install openssl version 1.1:
brew update & brew upgrade & brew install openssl#1.1
cd in your openssl lib folder in my case: /usr/local/opt/openssl#1.1/lib
copy files to /usr/lib
cd /usr/local/opt/openssl#1.1/lib
Copy the libssl.1.1.dylib file
sudo cp libssl.1.1.dylib libcrypto.1.1.dylib /usr/local/lib/
make softlink
sudo ln -s libssl.1.1.dylib libssl.dylib
sudo ln -s libcrypto.1.1.dylib libcrypto.dylib
Reinstall ruby with openssl version:
rvm reinstall 2.7.2 --with-openssl-dir=/usr/local/opt/openssl#1.1
References github issues, stackoverflow.

Ruby and Homebrew error "Refusing to link: openssl" [duplicate]

I'm on: OSX 10.11.6, Homebrew version 0.9.9m OpenSSL 0.9.8zg 14 July 2015
I'm trying to play with with dotnetcore and by following their instructions,
I've upgraded/installed the latest version of openssl:
> brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h_1.el_capitan.bottle.tar.gz
Already downloaded: /Users/administrator/Library/Caches/Homebrew/openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Pouring openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
But when I try to link openssl I continue to run into this linking error:
> brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only OpenSSL means you may end up linking against the insecure,
deprecated system version while using the headers from the Homebrew version.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
The option to include compiler flags doesn't make sense to me, since I'm not compiling these libraries that I'm dependent on.
EDIT dotnetcore has updated their instructions:
brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
This is what worked for me:
brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl /usr/local/bin/openssl
Thanks to #dorlandode on this thread https://github.com/Homebrew/brew/pull/597
NB: I only used this as a temporary fix until I could spend time correctly installing Openssl again from scratch. As I remember I spent best part of a day debugging and having issues before I realised the best way was to manually install the certs I needed one by one. Please read the link in #bouke's comment before attempting this.
As the update to the other answer suggests, the workaround of installing the old openssl101 brew will no longer work. For a right-now workaround, see this comment on dotnet/cli#3964.
The most relevant part of the issue copied here:
I looked into the other option that was suggested for setting the rpath on the library. I think the following is a better solution that will only effect this specific library.
sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Security.Cryptography.Native.dylib
and/or if you have NETCore 1.0.1 installed perform the same command for 1.0.1 as well:
sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.1/System.Security.Cryptography.Native.dylib
In effect, rather than telling the operating system to always use the homebrew version of SSL and potentially causing something to break, we're telling dotnet how to find the correct library.
Also importantly, it looks like Microsoft are aware of the issue and and have both a) a somewhat immediate plan to mitigate as well as b) a long-term solution (probaby bundling OpenSSL with dotnet).
Another thing to note: /usr/local/opt/openssl/lib is where the brew is linked by default:
13:22 $ ls -l /usr/local/opt/openssl
lrwxr-xr-x 1 ben admin 26 May 15 14:22 /usr/local/opt/openssl -> ../Cellar/openssl/1.0.2h_1
If for whatever reason you install the brew and link it in a different location, then that path is the one you should use as an rpath.
Once you've update the rpath of the System.Security.Cryptography.Native.dylib libray, you'll need to restart your interactive session (i.e., close your console and start another one).
None of these solutions worked for me on OS X El Capitan 10.11.6. Probably because OS X has a native version of openssl that it believes is superior, and as such, does not like tampering.
So, I took the high road and started fresh...
Manually install and symlink
cd /usr/local/src
If you're getting "No such file or directory", make it:
cd /usr/local && mkdir src && cd src
Download openssl:
curl --remote-name https://www.openssl.org/source/openssl-1.0.2h.tar.gz
Extract and cd in:
tar -xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
Compile and install:
./configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.2h shared
make depend
make
make install
Now symlink OS X's openssl to your new and updated openssl:
ln -s /usr/local/openssl-1.0.2h/bin/openssl /usr/local/bin/openssl
Close terminal, open a new session, and verify OS X is using your new openssl:
openssl version -a
Just execute brew info openssland read the information where it says:
If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
If migrating your mac breaks homebrew:
I migrated my mac, and it unlinked all my homebrew installs - including OpenSSL. This broke gem install, which is how I first noticed the problem and started trying to repair this.
After a million solutions (when migrating to OSX Sierra - 10.12.5), the solution ended up being comically simple:
brew reinstall ruby
brew reinstall openssl
Edit much later: as Gal Bracha noted in the comments, you ?might? need to delete /usr/local/opt/openssl before doing the reinstalls, just to be safe. I didn't need to at the time, but if you're still having trouble, give that a try.
After trying everything I could find and nothing worked, I just tried this:
touch ~/.bash_profile; open ~/.bash_profile
Inside the file added this line.
export PATH="$PATH:/usr/local/Cellar/openssl/1.0.2j/bin/openssl"
now it works :)
Jorns-iMac:~ jorn$ openssl version -a
OpenSSL 1.0.2j 26 Sep 2016
built on: reproducible build, date unspecified
//blah blah
OPENSSLDIR: "/usr/local/etc/openssl"
Jorns-iMac:~ jorn$ which openssl
/usr/local/opt/openssl/bin/openssl
The solution above from edwardthesecond worked for me too on Sierra
brew install openssl
cd /usr/local/include
ln -s ../opt/openssl/include/openssl
./configure && make
Other steps I did before were:
installing openssl via brew
brew install openssl
adding openssl to the path as suggested by homebrew
brew info openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
I have a similar case. I need to install openssl via brew and then use pip to install mitmproxy. I get the same complaint from brew link --force. Following is the solution I reached: (without force link by brew)
LDFLAGS=-L/usr/local/opt/openssl/lib
CPPFLAGS=-I/usr/local/opt/openssl/include
PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
pip install mitmproxy
This does not address the question straightforwardly. I leave the one-liner in case anyone uses pip and requires the openssl lib.
Note: the /usr/local/opt/openssl/lib paths are obtained by brew info openssl
This worked for me:
brew install openssl
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
By default, homebrew gave me OpenSSL version 1.1 and I was looking for version 1.0 instead. This worked for me.
To install version 1.0:
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Then I tried to symlink my way through it but it gave me the following error:
ln -s /usr/local/Cellar/openssl/1.0.2t/include/openssl /usr/bin/openssl
ln: /usr/bin/openssl: Operation not permitted
Finally linked openssl to point to 1.0 version using brew switch command:
brew switch openssl 1.0.2t
Cleaning /usr/local/Cellar/openssl/1.0.2t
Opt link created for /usr/local/Cellar/openssl/1.0.2t
I had the same problem while trying to install newer version of ruby 2.6.5
https://github.com/kelaberetiv/TagUI/issues/86 helps me to solve the problem. This if for macOS catalina Version 10.15.1
Basically, I did update and upgrade homebrew and install openssl and install ruby.
brew update && brew upgrade
brew install openssl
Then create these 2 symlinks
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
then installed ruby 2.6.5
Note: this no longer works due to https://github.com/Homebrew/brew/pull/612
I had the same problem today. I uninstalled (unbrewed??) openssl 1.0.2 and installed 1.0.1 also with homebrew. Dotnet new/restore/run then worked fine.
Install openssl 101:
brew install homebrew/versions/openssl101
Linking:
brew link --force homebrew/versions/openssl101
for me this is what worked...
I edited the ./bash_profile and added below command
export PATH="/usr/local/opt/openssl/bin:$PATH"
export https_proxy=http://127.0.0.1:1087 http_proxy=http://127.0.0.1:1087 all_proxy=socks5://127.0.0.1:1080
works for me
and I think it can solve all the problems like
Failed to connect to raw.githubusercontent.com port 443: Connection refused
The solution might be updating some tools.
Here's my scenario from 2020 with Ruby and Python:
I needed to install Python 3 on Mac and things escalated. In the end, updating homebrew, node and python lead to the problem with openssl. I did not have openssl 1.0 anymore, so I couldn't "brew switch" to it.
So what was still trying to use that old 1.0 version?
It tuned out it was Ruby 2.5.5.
So I just installed Ruby 2.5.8 and removed the old one.
Other things you can try if this is not enough: Use rbenv and pyenv. Clean up gems and formulas. Update homebrew, node, yarn. Upgrade bundler. Make sure your .bash_profile (or equivalent) is set up according to each tool's instructions. Reopen the terminal.

Installing bcrypt gem failed

gem install bcrypt
Building native extensions. This could take a while...
ERROR: Error installing bcrypt:
ERROR: Failed to build gem native extension.
/Users/mohit/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling bcrypt_ext.c
make: /usr/local/opt/gcc46/bin/gcc-4.6: No such file or directory
make: *** [bcrypt_ext.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p547/gems/bcrypt-3.1.9 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/bcrypt-3.1.9/gem_make.out
Edit with additional info from the OP:
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ brew doctor
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be
undone should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
$ brew info gcc
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require':
cannot load such file -- global (LoadError) from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:
in require' from /usr/local/Library/brew.rb:16:in `<main>'
$ gcc -v
Configured with:
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0 Thread model: posix
$ ls -ladg /usr/local/opt/gcc*
No such file or directory
OSX help
Try installing XCode, which tends to be a huge download:
$ xcode-select --install
If the result is anything like this message below, that's ok for now.
command line tools are already installed,
use "Software Update" to install update
Update OSX to ensure it's ok and current:
Apple Menu -> About This Mac -> Software Update
Verify you have a current system, 10.10 as of this writing:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10
BuildVersion: 14A389
Brew help
If you use the homebrew package manager, what version? (Please post output)
$ brew --version
Verify brew is healthy:
$ brew doctor
If the doctor finds any errors, fix these. For example, doctor may say to do this, so do it:
cd /usr/local/Library && git stash && git clean -d -f –
When doctor says everything is fine, then bring brew current:
$ brew update
$ brew upgrade
Is homebrew adding GCC? (Please post output)
$ brew info gcc
GCC help
Is GCC available?
$ command -v gcc
/usr/bin/gcc
See if your CC compiler variable is blank or set. (Please post the output)
$ echo $CC
What GCC version are you running? (Please post the output)
$ gcc -v
...
Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn)
...
Do you have any GCC installed where Ruby is looking? (Please post the output)
$ ls -ladg /usr/local/opt/gcc*
lrwxr-xr-x 1 admin 21 Dec 18 16:41 /usr/local/opt/gcc -> ../Cellar/gcc/4.9.2_1
Root gem help
Does the gem install if you're root?
$ sudo su -
$ gem install bcrypt
The root problem here is that ruby itself comes with bcrypt version 3.1.5 which is having bugs with the newer updates. However when you install or uninstall the bcrypt you are leving behind bcrypt-ruby which it always asks for first and hence all what you are doing won't go through so what to do ? 1- uninstall bcrypt and bcrypt-ruby by running these two commands:
$ gem uninstall bcrypt
and
$ gem uninstall bcrypt-ruby
2- Install it again with
gem install bcrypt --platform=ruby
In your Gemfile write gem 'bcrypt','~>3.1.11'
NOW as i write these lines the latest version is 3.1.11 but whatever version is updated just add it from their gem page. Run bundle install and it should work just fine.
I hope you fully understand the solution and the mechanism of it hence you would know that bundle install might cause the same issue so you have to repeat this process and it'll work again.
Stuck working on an old project I was able to get the gem installed by using the following steps (check you own paths - don't just copy paste):
1) Install the specific version of gcc required (check the version) :
brew install gcc46
2) Symlink the installed gcc directory :
ln -s /usr/local/Cellar/gcc\#4.6/4.6.4_2 /usr/local/Cellar/gcc46/4.6.4
3) Install the gem reporting the error (check your gem name)
gem install bcrypt-ruby -v '3.0.1'

Command rake db:schema:dump not working properly

The following rake command doesn't work
rake db:schema:dump
/Library/Ruby/Gems/1.8/gems/bundler-1.1.4/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /usr/local in PATH, mode 040777
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
You need to install mysql. I recommend installing a package manager such as Homebrew, then doing a simple brew install mysql
Your are probably missing something about a correct installation on osx and with a correct distribution of mysql libraries.
The fastest way of getting rid of this problem was a:
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
use the
$ sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
should be the proper solution
Note: Copied from here
You need to install mysql-client and libmysqlclient-dev excepting your using a debian based linux. Anyway you need these libaries which are NOT part of the mysql-server package!
In my case: Mountain Lion with mysql 5.5 and ruby 1.9.3 installed by RVM
The file libmysqlclient.18.dylib lives in
/usr/local/mysql-5.5.25a-osx10.6-x86_64/lib/libmysqlclient.18.dylib
I copied this file to "/usr/lib" folder and it fixed the error.
sudo cp /usr/local/mysql-5.5.25a-osx10.6-x86_64/lib/libmysqlclient.18.dylib /usr/lib/

How to Install wkhtmltopdf?

Now i am working on rails 3.0.0.i am using Ubuntu 11.10 ,64 bit os.i want to install wkhtmltopdf.please tell me the static version of wkhtmltopdf.
Installing wkhtmltopdf
on Ubuntu Linux machine
First check os is 32 bit or 64 bit by using following command
Try uname -m. It seems like the uname -m actually gives x86_64 when it is an kernel 64 bits
Run following command
sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev
Then run following command
sudo apt-get install wkhtmltopdf
Based on OS download wkhtmltopdf package from following site
http://code.google.com/p/wkhtmltopdf/downloads/list
OR
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
(wkhtmltopdf-0.9.9-static-i386.tar.bz2 is a stable release for wkhtmltopdf )
Then extract using command
tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
Then move extracted DIR to usr/local/bin folder
sudo mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
Check wkhtmltopdf is install or not using following command
which wkhtmltopdf
wkhtmltopdf –help
Installing wkhtmltopdf on MacOs
brew install Caskroom/cask/wkhtmltopdf
Another way to use official binaries within Rails is adding the following line to your Gemfile:
gem 'wkhtmltopdf-installer'
This way the official binaries from http://wkhtmltopdf.org will be downloaded and added to your bundle during bundle install phase.
I encountered this problem this morning.
Before you do anything, please check out: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF
Download a binary edition of wkhtmltopdf at http://code.google.com/p/wkhtmltopdf/downloads/list
Decompress the package.
Copy the file like wkhtmltopdf-i386 to /usr/local/bin/ & /opt/ (also you could make soft link).
That's done.
Good luck.

Resources