How to install mysql gem on Mac os 10.6? - ruby-on-rails

i just installed MAMP on this iMac and the rubygems but when i run:
sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
gives me
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
ERROR: could not find gem — locally or in a repository
ERROR: could not find gem –with-mysql-config=/usr/local/mysql/bin/mysql_config locally or in a repository
how can i install this gem ?

I found this and worked out perfectly:
you can go to http://www.tmtm.org/en/ruby/mysql/ to download the tar
file, and run the command below
# ruby ./install.rb
to install the mysql.rb

Use the following it worked with me
brew install mysql

Do you have the Xcode developer tools installed on Mac OS X? If not, I'd start there.
You can download them here: http://developer.apple.com/technologies/xcode.html
Once you've installed that, try again.

i'm still getting this
$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
* extconf.rb failed *
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

You need the mysql development libs to compile it. If you were on linux you could use "yum install mysql-devel". Not sure about how to get them installed on a mac, but try downloading the connector libraries from here:
MySql Connector Downloads
You may have to pass in a --with-mysql-libs option to point to the directory when the C libraries are unpacked to. Hope this points you in the right direction.
Or you can just put the libraries in the default directory:
/usr/lib64/mysql

Download mysql-dev from mysql.com

Related

Ruby Sqlite3 installation sqlite3_libversion_number() macOS Sierra

I'm trying to install the Metasploit framework (unimportant) and bundler is attempting to install sqlite3, which is where it fails consistently. Sqlite3 is installed (executing sqlite3 at the command line brings me into the environment) and is linked using brew link sqlite3 (and adding the --force, for some reason) but bundler install fails each time with this error:
sudo gem install sqlite3
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'brew install sqlite3',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/
--with-pthreadlib
--without-pthreadlib
--with-sqlite3lib
--without-sqlite3lib
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.12 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.12/ext/sqlite3/gem_make.out
I finally managed to solve this by specifying the built-in Mac OS X sqlite library directory on macOS Sierra 10.12.5 (16F73):
$ whereis sqlite3
/usr/bin/sqlite3
# if binary is in /usr/bin then library is typically in /usr/lib
$ gem install sqlite3 -- --with-sqlite3-lib=/usr/lib
Building native extensions with: '--with-sqlite3-lib=/usr/lib'
This could take a while...
Successfully installed sqlite3-1.3.13
Parsing documentation for sqlite3-1.3.13
Done installing documentation for sqlite3 after 0 seconds
1 gem installed
I tried specifying the Homebrew library directory but for some reason it didn't work:
$ brew ls --verbose sqlite3
/usr/local/Cellar/sqlite/3.19.3/.brew/sqlite.rb
/usr/local/Cellar/sqlite/3.19.3/bin/sqlite3
/usr/local/Cellar/sqlite/3.19.3/include/msvc.h
/usr/local/Cellar/sqlite/3.19.3/include/sqlite3.h
/usr/local/Cellar/sqlite/3.19.3/include/sqlite3ext.h
/usr/local/Cellar/sqlite/3.19.3/INSTALL_RECEIPT.json
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.19.3/lib/pkgconfig/sqlite3.pc
/usr/local/Cellar/sqlite/3.19.3/README.txt
/usr/local/Cellar/sqlite/3.19.3/share/man/man1/sqlite3.1
$ gem install sqlite3 -- --with-sqlite3-lib=/usr/local/Cellar/sqlite/3.19.3/lib
This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
...
If someone knows how to specify the Homebrew library directory, please let me know because that would provide a little more control over installation (supposedly MacPorts works but I no longer use it).
For anyone curious, here's the full command to install Ruby's Sequel:
gem install sequel mysql sqlite3 -- --with-sqlite3-lib=/usr/lib
And how to convert a Laravel Homestead MySQL database listening on host port 3306 to SQLite from my comment on the question:
sequel mysql://homestead:secret#192.168.10.10:3306/my_database -C sqlite://my_database.sqlite
This worked for me on Mac High Sierra OS 10.13
gem install sqlite3 -- --with-sqlite3-lib=/usr/lib
Digging into the mkmf.log who you will find by replacing the last part of the file pointer to the log of the installation attempt. In my case:
Results logged to ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/sqlite3-1.3.13/gem_make.out
so I find the mkmf.log here:
~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/sqlite3-1.3.13/mkmf.log
I found a more explicit description of the errors:
conftest.c:13:15: error: implicit declaration of function 'pthread_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
conftest.c:13:15: error: implicit declaration of function 'sqlite3_libversion_number' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
So adding the --with-cflags="-Wno-error=implicit-function-declaration" made the trick!
gem install sqlite3 -- --with-cflags="-Wno-error=implicit-function-declaration"

RMagick installs using devkits msys.bat but not using gitbash

(I am using Windows 8)
I finally got the rmagick gem to install by opening the msys.bat file in my Devkit folder using this command
gem install rmagick --platform=ruby -- --with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include
This is the output
Building native extensions with: '--with-opt-lib=c:/imagemagick/lib --with-opt-i
nclude=c:/imagemagick/include'
This could take a while...
Successfully installed rmagick-2.15.0
Parsing documentation for rmagick-2.15.0
Done installing documentation for rmagick after 6 seconds
1 gem installed
But when I run the same exact command using gitbash I get this error:
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include'
This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb --with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include
Invalid drive specification.
Unable to get ImageMagick version
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/RailsInstaller/Ruby2.1.0/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rmagick-2.15.0 for inspection.
Results logged to c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/rmagick-2.15.0/gem_make.out
I get this same exact error when running bundle install using gitbash and when I try to run bundle install using msys.bat I get the same error but its a bit longer and complains about development tools.
If it works using msys.bat, what do I need to change to get it to work with gitbash and with bundle installs?
EDIT: I did the same command using msys.bat but specified rmagick -v '2.13.3' and bundle install worked. My gemfile doesn't specify a version so not sure why 2.15.0 didn't work. Anyways things are working...so far. But I do think I should think about switching from windows like the first comment suggests due to all the problems I've faced so far with windows.

Error while installing ImageMagick for Ruby on Rails on Windows

I'm installing ruby on rails and redmine with xampp following this documentation:
http://nlb-creations.com/2013/06/26/installing-ruby-on-rails-and-redmine-with-xampp-on-windows-7/
Step 12 requires installing rmagick, I followed the steps correctly till I reached 12-d :
In the cmd window, run the following:
gem install rmagick --platform=ruby -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include
I got the following error:
C:\xampp\htdocs\dev-ruby\redmine>gem install rmagick --platform=ruby -- --with-o
pt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-opt-lib=c:/Im
ageMagick/lib --with-opt-include=c:/ImageMagick/include
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby1.9.3/bin/ruby
Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9
.1/gems/rmagick-2.13.3 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rmagick-2
.13.3/ext/RMagick/gem_make.out
I downloaded ImageMagick-devel-6.8.9.9.aarch64.rpm cz it might solve my problem but I don't know how to install it. Any ideas please?
Sounds like you're trying to install the RMagick gem before installing ImageMagick:
The RPM is for certain Linux distributions.
Try installing http://www.imagemagick.org/script/binary-releases.php#windows then the gem.

Unable to install Rails extconf.rb failed

I'm new to Ruby on Rails, and I'm getting the below error when I'm installing it.
Please note, I have installed the latest Xcode and installed command line tools, and I'm using OSX 10.8.4. I've installed Ruby 2.0.0 as well.
-bash-3.2$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'
Gem files will remain installed in /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out
I had similar problem and it gets solved by installing command line tools:
xcode-select --install
The symlinking did not solve the problem for me. I uninstalled my ruby that I previously had installed using rvm by typing rvm uninstall ruby-2.0.0 and then I typed rvm requirements. This command found that I needed a few other things, such as gcc46. It's strange that the gcc compiler was needed, even though I had installed the xcode command line tools, and gcc was most definitely installed on my system.
So, if none of the usual methods are working, give rvm requirements a shot!
I guess it's a same problem with this question.
Try sudo ln -s /usr/bin/{llvm-,}gcc-4.2 and gem install rails again.
By the way, you're in your own home directory, you don't have to use sudo.
I just ran into this with ruby 2.5.3 and was able to install cairo by calling:
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install cairo -v '1.15.2'
Took a while to find something that worked, as I already had the command line tools installed, and am using asdf not rvm.
Thanks to this thread for helping with the fix: https://github.com/ruby-gnome2/ruby-gnome2/issues/259#issuecomment-59751807

Gem install error with RMagick

In the past I used RMagick and also had Imagemagick, and recently I bundle installed a newer version of RMagick.
When restarting my rails server I got errors. So I decided to uninstall first imagemagick (from brew) and then uninstall rmagick.
I tried re-installing rmagick and I am some trouble (first one being I can't install from the bundle command). I tried gem install rmagick -v '2.13.1' but I get the following permission error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/username/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper
I also tried with the sudo and got
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/username/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper
usercomputer:~ Username$ sudo gem install rmagick -v '2.13.1'
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for /usr/bin/gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /Users/username/.rvm/gems/ruby-1.9.3-p194/bin:/Users/Aurelien/.rvm/gems/ruby-1.9.3-p194#global/bin:/Users/username/.rvm/rubies/ruby-1.9.3-p194/bin:/Applications/MAMP/bin/php5/bin:/Applications/MAMP/htdocs/cake/cake/cake/console:/Users/username/.rvm/gems/ruby-1.9.3-p194/bin:/Users/username/.rvm/gems/ruby-1.9.3-p194#global/bin:/Users/username/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/username/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/username/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
Gem files will remain installed in /Users/username/.rvm/gems/ruby-1.9.3-p194/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-1.9.3-p194/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
Surely I have done something wrong along the way, but I am not sure what?
Thank you for you answers.
It seems the latest version of ImageMagick is not compatible with RMagick. I solved the issue by following this:
http://blog.paulopoiati.com/2013/01/28/installing-rmagick-in-mac-os-x-mountain-lion-with-homebrew/

Resources