I'm trying to install mysql2 in my Mac running on MacOS Big Sur. When I run 'gem install mysql2' I get:
library not found for -lzstd
If I then run 'gem install mysql2 -- --with-opt-dir="$(brew --prefix zstd)"' I get:
library not found for -lssl
I can then run 'gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"' but I again get:
library not found for -lzstd
How can I workaround this issue? Is there a way to specify both libraries with 'with-opt-dir'?
My question was answered by https://stackoverflow.com/a/13799101/9319119
After I downloaded mysql from https://dev.mysql.com/downloads/file/?id=508096 I was able to just run gem install mysql2 -- --srcdir=/usr/local/mysql/include
When I try to install modules using pod install command in directory ios of react native project, I get the following error:
LoadError - incompatible library version - /Users/user/gems/gems/ffi-1.13.1/lib/ffi_c.bundle
How can I fix it so that my command is executed successfully?
To solve this problem I tried to uninstall ffi-1.13.1 and tried to install versions ffi-1.13.0, ffi-1.12 and do the command pod install again. The same error was displayed.
Also issues were opened in Github repositories CocoaPods, React Native Mapbox
Use the below command
gem install ffi
This fixed the same issue in my system (Big Sur)
The error for me occured after changing/uninstalling my Ruby version.
Try this:
Install rvm (if you don't have it) \curl -sSL https://get.rvm.io | bash
install latest ruby (3.0.0p0) rvm install ruby#latest and set it as default rvm use ruby-3.0.0 --default
A few times install cocoapods gem install cocoapods
pod install
I run brew update and brew upgrade rbenv ruby-build. FYI: I updated xcode to version 8.1 yesterday.
I checked available versions, rbenv install -l.
Then I tried to install ruby2.2.5 by rbenv install 2.2.5, then I get the following errors.
I tried 2.3.1 but I got the same errors. How can I fix the problem?
Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...
BUILD FAILED (OS X 10.11.6 using ruby-build 20160602)
Inspect or clean up the working tree at /var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330
Results logged to /var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330.log
Last 10 log lines:
Referenced from: /private/var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330/ruby-2.2.5/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _clock_gettime
Referenced from: /private/var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330/ruby-2.2.5/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
make: *** [encdb.h] Trace/BPT trap: 5
make: *** Waiting for unfinished jobs....
make: *** [.rbconfig.time] Trace/BPT trap: 5
First, I've uninstalled all:
brew uninstall rbenv ruby-build
and because of an old sticky ruby-build installation, I've forced like this:
brew uninstall --force ruby-build
I can see an old invocation for rbenv when I type ruby -v. So I remove all rbenv references from $HOME/.bash_profile and then reload it with:
source $HOME/.bash_profile
Now I only see my old default MacOs ruby version:
ruby -v # ruby 2.0.0p481 (2014-05-08 revision 45883)
which ruby # /usr/bin/ruby
¡Good! Now it's time to install them again and then list available Ruby versions:
brew install rbenv
rbenv install -l
I now can see more Ruby options to install...
2.2.4, 2.2.5, 2.2.6, 2.2.7, 2.2.8, 2.2.9, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.5.0
I will choose one of them and make it global:
rbenv install 2.5.0
rbenv global 2.5.0
I case you don't have already the $HOME/.bash_profile rbenv config line, run:
rbenv init
... and add the resulting line to your $HOME/.bash_profile.
I tried to upgrade rbenv.
brew upgrade rbenv
Then I got a warning.
Warning: You have Xcode 8 installed without the CLT;
this causes certain builds to fail on OS X El Capitan (10.11).
Please install the CLT via:
sudo xcode-select --install
Error: rbenv 1.0.0 already installed
So I installed xcode-select.
sudo xcode-select --install
Then I tried to upgrade rbenv but rbenv 1.0.0 was already installed.
brew upgrade rbenv
Error: rbenv 1.0.0 already installed
So I tried to install 2.3.1 and 2.2.5
rbenv install 2.3.1
...
rbenv install 2.2.5
And it was a success.
➜ ~ rbenv versions
system
1.9.3-p327
* 2.2.2 (set by /Users/sokada/.rbenv/version)
2.2.5
2.3.1
I also need to install bundle since I came to this problem from using bundle.
gem install bundler -v 1.13.6 // newest as of this writing
bundler -v
bundler install // finally I could use it.
It's a really old question. However, the correct approach I believe is to upgrade ruby-build. It is available as a plugin for rbenv that provides the rbenv install command.
so to fix the issue follow this approach: https://github.com/rbenv/ruby-build#upgrading
# Via Homebrew
$ brew update && brew upgrade ruby-build
Using rvm I upgraded my ruby to 1.9.3-p392, also added 2.0.0, anytime I try to use this version when I run my bundle command I get this error.
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.
I have followed several different instructions on how to fix this. I have tried removing the version and installing it with the rvm options
--with-openssl-dir=$HOME/.rvm/usr
I have installed OpenSSL with rvm, and macports. Both have not helped the problem. I even changed the file location of the ssl cert using this:
export SSL_CERT_FILE=/Users/DarkLord/.rvm/usr/ssl/cert.pem
No matter what I do I continue to get the error.
Can someone please help me fix this?
This works for me:
rvm get stable
brew install libyaml
rvm pkg install openssl
rvm install ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr
rvm use ruby-2.0.0
All credits go to https://coderwall.com/p/tptocq
This helps me install 1.9.3-head on Mac:
rvm get latest
brew install openssl
rvm reinstall 1.9.3-head --with-openssl-dir=`brew --prefix openssl`
In my case after:
1. brew install openssl
2. rvm install ruby-2.6.0
bundle install failed with this error. The problem was that openssl was globally set so I had to install the new ruby version by setting the openssl directory explicitly.
So what I had to do was:
1. rvm reinstall ruby-2.6.0 --with-openssl-dir=/usr/local/opt/openssl
2. rvm reload
Assuming that usr/local/opt/openssl is where it is installed.
After that bundle install ran successfully.
Warning when I tried this command with this path /usr/local like some answers suggested, it didn't work.
To get this working again I had to install homebrew and move my mac ports out of the way. Then do the following after removing 1.9.3-p392 and 2.0.0-p0:
rvm get head --autolibs=3
rvm install 1.9.3 --with-opt-dir=/usr/bin
rvm install 2.0.0
There was something not working with my mac ports and openssl and make and configure. This was the only way I was able to get rvm to install ruby again with out getting openssl issues or make/configure issues.
The new way to do it, according to a comment by #Purplejacket above, is the following:
rvm autolibs homebrew
rvm install 2.1.1
rvm use 2.1.1
It's much easier.
In my case:
Problem: After installing ruby-2.3.1, I ran the command bundle install and then the error occurred.
Solution:
I first installed OpenSSL on my machine. $ brew install openssl
And then, reinstalled the ruby version I require (2.3.1) with the openssl.
$ rvm reinstall 2.3.1 --with-openssl-dir=/usr/local/opt/openssl
And this solved my problem!
According to the following question:
How to tell which openssl lib is actually being used by an RVM-installed ruby
It seems that the options --with-openssl-dir=... is no longer valid as of Ruby 1.9.3. I tried
rvm install 1.9.3 --with-opt-dir=/usr/local --with-openssl
and it worked.
macOS Catalina
brew install rbenv/tap/openssl#1.0
rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/opt/openssl#1.0
The following steps worked for me.
First ensure openssl is installed by running brew install openssl, then reinstall the ruby version using rvm, but this time around, you have to pass the with-opt-dir flag pointing to the location where openssl was installed on your machine (use command which openssl to find this location).
rvm install 1.9.3-p392 --with-openssl-dir=/usr/local/opt/openssl
On macOS 10.14, Ruby 2.5.3, and OpenSSL 1.0.2n this worked for me:
./configure --with-openssl --with-openssl-dir=/usr/local/ssl
but I was only trying what the error messages were telling me:
*** Following extensions are not compiled:
openssl:
Could not be configured. It will not be installed.
/Users/brian/Desktop/Ruby/ruby-2.5.3/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
make[1]: *** [note] Error 1
I encountered this issue when working on a Ruby 2.2.3 application.
I had previously uninstalled the MySQL database server on my machine, since I did not need it. However, I still needed the mysql2 gem since my application was connecting to another application's MySQL database to pull data.
However, when I try to run the bundle command I get the error:
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.
Here's how I solved it:
The issue was caused by removing the libssl-dev library when I was uninstalling the MySQL database server on my machine and its libraries.
First I ran the command below to reinstall ruby since I installed it using rvm:
rvm reinstall ruby-2.2.3
This raised an error:
Making gemset ruby-2.2.3 pristine............................................./-
.'command gem pristine --extensions mysql2 --version 0.5.3' failed, you need to fix these gems manually.
.
Error running '__rvm_with ruby-2.2.3 gemset_pristine',
please read /home/promisepreston/.rvm/log/1630094455_ruby-2.2.3/gemset.pristine-ruby-2.2.3.log
Next, I tried to install the mysql2 gem:
gem install mysql2
Then I ran into this error:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.
Finally, I installed the mysql client library using the command:
sudo apt-get install libmysqlclient-dev
Note: This also installs the libssl-dev library alongside.
And everything worked fine.
That's all.
That's what helped me:
rvm reinstall 2.5
brew tap raggi/ale
brew install openssl-osx-ca
brew services start openssl-osx-ca
Found this solution here: https://github.com/raggi/openssl-osx-ca#readme
I specified a more recent Ruby version in my Gemfile, then ran bundle install. All good now.
Specific case for ruby version 3.0.3
By default for brew and system and autolibs OpenSSL version is 3. Ruby 3.0.3 does not work with OpenSSL version 3 and ruby build silently ignores OpenSSL.
To build ruby properly use build options with OpenSSL 1 like this:
PKG_CONFIG_PATH=/usr/local/opt/openssl#1.1/lib/pkgconfig rvm reinstall 3.0.3 --with-openssl --with-openssl-lib=/usr/local/opt/openssl#1.1/lib --with-openssl-include=/usr/local/opt/openssl#1.1/include
Where path variables may be another - check your system.
Thanks to article Ruby 3.0.3 with OpenSSL using MacPorts and RVM
I got this to work on Ubuntu 22.04 by doing:
rvm pkg install openssl
...and adding --with-openssl-dir=$HOME/.rvm/usr to the rvm install command.
This doesn't seem particularly OS-specific and might work on Mac OS as well.
Fix which worked for me
rvm install 3.0.3 --with-openssl-dir=/opt/homebrew/etc/openssl#1.1
PS. Find the correct openssl location in your machine and install ruby pointing to that path like above, mentioning the brew installed openssl#3 path doesnot work.
I don't use rvm, and I don't want to. I had to install asdf in order to resolve what I used to be able to do with just homebrew & ruby.
Following this guide is the only thing that worked for me after following dozens of suggestions. I had to install asdf and update my .zshrc to include the following at the end of the doc:
eval "$(rbenv init - zsh)"
I'm on an Intel Mac running Monterey 12.2.1.
I installed zlib package and ruby 1.9.3 using rvm, but whenever I try to install
gems it says
cannot load such file -- zlib
The commands I used to install are
$ rvm install 1.9.3
$ rvm pkg install zlib
$ rvm reinstall 1.9.3 --with-readline-dir=/home/username/.rvm/usr \
--with-iconv-dir=/home/username/.rvm/usr \
--with-zlib-dir=/home/username/.rvm/usr \
--with-openssl-dir=/home/username/.rvm/usr
$ rvm use 1.9.3
$ gem install heroku
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
All the help on this subject tells me to just do rvm pkg install zlib, and
then reinstall the ruby with --with-zlib-dir=/home/username/.rvm/usr, but this
didn't work.
I ended up installing zlib from apt-get and then reinstalling ruby to not use the rvm directory for zlib.
Here's how do:
$ sudo apt-get install zlib1g-dev
$ rvm reinstall 1.9.3
[Edit] As commenter #chrisfinne mentions, on CentOS/RedHat based systems:
$ sudo yum install zlib-devel
$ rvm reinstall 1.9.3
The both other responses were almost right...
The rvm site for zlib provides a quick fix!
On the top off the page is a "Quick fix" follow it's instructions, it will:
fix your installation,
provide you instructions what to do to install zlib from your system
and show how to reinstall ruby
Use autolibs to install dependencies:
rvm autolibs enable
rvm reinstall 1.9.3
RVM will automatically install missing dependencies and use them for compiling ruby.
More details on autolibs => http://rvm.io/rvm/autolibs
The solution that worked for me is described in rvm github repo, issue #3389.
Run
rvm install 2.3.0 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8
for ruby 2.3.0 version.
Ruby has a bunch of package dependencies like the one on zlib-devel. They're nasty because there's nothing to indicate you need the library until get some obscure error message while trying to do something routine.
The solution is to use rvm. Use it even if you only need one version of ruby. Why? Because then you can do
rvm requirements
This will probe your particular OS and produce a set of commands you can copy back to the command line to install those missing packages.
rvm pkg install openssl && rvm pkg install zlib && rvm pkg install libyaml &&
rvm pkg install iconv
rvm install 1.9.3-p0 --with-opt-dir=$HOME/.rvm/usr \
--with-libxml2-dir=/usr/local/Cellar/libxml2/2.7.8 \
--with-readline-dir=/usr/local/Cellar/readline/6.2.1