Installing MySQL gem in Ruby - ruby-on-rails

I can't seem to install the MySQL gem. I'm using this command:
ARCHFLAGS="-arch i386" gem install mysql --
--with-mysql-dir=/usr/local/mysql/
--with-mysql-config=/usr/local/mysql-5.1.50-osx10.6-x86/bin/mysql_config
The errors that I am getting seem to indicate that I have no headers and etc. Not sure where I can get those. I'm on Snow Leopard.
Any ideas?

I had massive problems with this as well on Snow Leopard, but this worked great for me: http://blog.m-schmidt.eu/2009/12/11/ruby-on-rails-mysql-on-mac-os-x-10-6-snow-leopard/. Good luck!
EDIT: you could also try using Homebrew, described as "the missing package manager for OSX". Some instructions on installing MySQL with Homebrew can be found here: http://solutions.treypiepmeier.com/2010/02/28/installing-mysql-on-snow-leopard-using-homebrew/

His instructions in this link have worked for me time and time again. master kain's awesome mysql
Oh, and you did install xcode right? From the disks before you did all this, cause that is where the headers are.

Related

Big Sur - Ruby - Cannot load such file — Interrupted system call

After upgrading to Big Sur I am getting errors running my Ruby server rotating through different files either with
cannot load such file --
or
Interrupted system call --
These errors rotate various files each time I run bundle exec rackup. I have tried uninstalling/reinstalling RVM, XCode Command Line Tools, and even tried switching to rbenv. Same outcome.
Any ideas?
It seems to get solved by uninstalling Kaspersky.
Also, it seems that the ruby applications are not the only ones facing this issue.
There are other security solutions too, eg. Avira.
https://github.com/rbenv/ruby-build/issues/1710
https://github.com/dart-lang/sdk/issues/44509
I was able to solve this problem for an rbenv ruby installation after noticing a similar-ish issue listed at the end of the ruby-build wiki. Adding MAKE_OPTS=-j1 finally worked, though it took much longer; The whole build ran with one process. The final command I used (though I don't know if calling ruby-build directly was necessary):
MAKE_OPTS=-j1 RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)" \
ruby-build --verbose 2.6.6 ~/.rbenv/versions/2.6.6/
# to hook it up with rbenv:
rbenv rehash
I know this isn't your exact problem, but perhaps re-installing ruby would help.
Not a complete resolution yet, but we did find out that the issue seems specific to the newrelic-ruby-agent and have opened an issue (https://github.com/newrelic/newrelic-ruby-agent/issues/528) with them to do further investigation.
As a workaround, we are able to run locally by setting NEW_RELIC_AGENT_ENABLED=false in the env.list
Uninstalling Avira solved the problem I was having with rbenv install 3.0.0 on macOS 11.2. (See ruby-build #1710 (comment).) Thanks to #alex for the tip.
I got this error in brew install lima
this may not look like answer, but running up that command again and again brew install lima I kept getting different errors, I ran that command 7-8 times, and was able to finally install lima.

RMagick/ImageMagick installation

I am trying to install the rmagick gem. When I run "gem install rmagick" it gives me the following error:
In file included from rmagick.c:13:
./rmagick.h:1210:51: error: unknown type name 'MagickPixelPacket'
extern void Color_to_MagickPixelPacket(Image *, MagickPixelPacket *, VALUE);
followed by a few similar complaints about missing methods and incorrect parameters(I can post the rest if they seem helpful).
To me, this seems like a version problem, which makes sense because I had ImageMagick 6 installed as well as version 7, so I uninstalled version 6 but the problem persists.
I also had to symlink the following for rmagick to find the required .h files, in case that's significant:
ln -s /usr/local/include/ImageMagick-7/MagickCore /usr/local/include/magick
ln -s /usr/local/include/ImageMagick-7/MagickWand /usr/local/include/wand
I'm on a Macbook, installing things with brew. My current ImageMagick version is 7, but I'm suspicious of some leftover version 6 things causing problems.
Any thoughts? I'm happy to give more information if necessary, but I can't think of anything else at the moment.
Each distribution manages the Ruby gems it's own way, ex :
Debian requires the installation of libmagickwand-dev for this gem
What you whant to look for is see if the gem requires additionnal dependencies or not on Mac ( had similar problems with bundle on Debian )
Thanks to Brad and Matthieu for your suggestions! MiniMagick does seem like a good solution, and Matthieu is definitely right about there being different dependencies from system to system; in my case I ended up giving up on trying to use ImageMagick 7 with RMagick, but I did get it to work with ImageMagick 6. Here's what worked for me:
brew remove imagemagick
PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig
brew install imagemagick#6
gem install rmagick
Many thanks to this SE post: https://stackoverflow.com/a/41788501/5054505
For the record, I am on OSX Yosemite
Also, see this RMagick issue: https://github.com/rmagick/rmagick/issues/256.
Hopefully this will be fixed soon, but for now it seems like reverting to version 6 is the popular approach.

Lazy symbol binding failed when creating ruby db

I am trying to install ruby on rails, and everything is installed now so far, but when I try to create a database with rake db:create, I get a weird error:
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap: 5
I am working on osx mountain lion latest update. Does anyone have the right solution for me?
You might try this.
sudo gem install mysql2 — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Be sure to modify the mysql config path with the location for yours.
You can determine this with the following command.
locate mysql_config
Leverage the path given with the command above.
The messge is telling that you have linked wrong version 32 vs. 64
On OSX you can see all versions on mysql installed
cd /usr/local/
and find right config in /usr/local/mysql-xxxx/bin/mysql_config
In my case it was:
gem uninstall mysql2
sudo gem install mysql2 --
--with-mysql-config=/usr/local/mysql-5.5.27-osx10.6-x86_64/bin/mysql_config
As discussed here: https://www.ruby-forum.com/topic/1440086
There are numerous questions about this and at least as many answers that work some of the time but not others. After trying most of them I noticed that the gem was 64bit and the mysql installation was 32bit.
To fix it:
install the 64 bit mysql
set up the symbolic links in /usr/local to point to the 64 bit version
set the PATH and DYLD_LIBRARY_PATH in your profile to include the correct versions
uninstall the mysql2 gem
install the mysql2 gem
ruby now plays nicely with mysql!
I haven't included the exact code as this tends to vary with your environment.
I was having a hard time with this one.. I tried all of the answers above, so I can't really pinpoint what combination resulted in the fix. I already had mysql installed and had reinstalled from mysql's website. It finally started working after I followed the bellow.
This is on Mavericks using rails 4 and brew is installed
brew install mysql
I'm not recommending this process .. Just noting that it worked for me after hours of frustration.
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo gem uninstall mysql
gem uninstall mysql2
gem install mysql
gem install mysql2
You need to install 64 bit MySql server. Don't forget to re-install mysql gem.
I had two versions of mysql installed (32 & 64 bit) for some reason.
Make sure your $MYSQL environmental variable (most likely found in ~/.bash_profile or ~/.profile) is pointing at the 64 bit version.
Also make sure you point towards the correct the mysql install when your installing the gem as the other answers have mentioned.
I had same problem. mysql2 version was 0.4.9, downgraded it to 0.4.5 and problem solved

Rails Server broken after PostgreSQL download

Operating System I am using is Mac OSX Mountain Lion.
First I will give some back story on how this cluster F started. I am going through a Ruby on Rails Web development book. I want to use PostgreSQL as my server. Before today I was using sqlite3. I downloaded PostgreSQL 9.1 from there website. I used the DMG installer. Once I was done with the install process it asked me to re-boot because of some sort of memory problem, I did that and it installed without error.
The problem started when I tried to use the "Rails Server" command in the terminal. This is what I got (I tried to strip out the unimportant stuff which would clutter everything up)
/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: /usr/lib/libcrypto.dylib (LoadError)
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8 - /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle
...
from /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/commands.rb:50:in
I have read through the out put and I have done a lot of Google searching, and what I have found is that it's a problem with which version of libcrypto the server is fetching. Or something about the libssl. I have gone through the solutions on google and nothing seems to be working. Hopefully someone has had the same problem I have, and can help me.
Thanks in advance! -Chris
I really recommend you to use Homebrew to install postrgresql. It helps you to install all proper dependencies for version which correctly works with rails.
$ brew install postgresql
Do not forget to follow after install instructions from homebrew
Are you sure you installed PostgreSQL server/rubygem successfully? From the stack trace I think there's a problem about it.
If your PostgreSQL server/rubygem are working well, then switch another webserver, mongrel/thin are both OK, both have better performance than the default rails server(webrick) and easy to use.

Ruby, RVM, LLVM and MySQL

I'm having big trouble in configuring Ruby and MySQL on MacOSX. Just a fact, I'm new on MacOSX and Ruby On Rails.
So, first I was having problems to install mysql2 gem, after get the gem installed I was trying developer a test, and when I tried start the WEBrick got this error saying that couldn't load a MySQL lib called "libmysqlclient.18.dylib". Googlin' about the error I saw that everyone was recommending using Ruby through RVM. I installed RVM and tried install ruby 1.9.3 and get this error:
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.
I'm almost giving up learn Rails, setup a development environment shouldn't be that painful. On Windows I got no problems.
Unfortunately, you're trying Rails at a bit of a bad time. There's a lot of transition at the moment, as others have mentioned Xcode 4.2 was recently released and has a new compiler, also Ruby 1.9.3 came out.
I've been developing Ruby and Rails for some years now, but trying to get up and running again after installing Lion clean this week has been more problematic than in the past.
First, make sure RVM is up to date (as the issue should be fixed):
rvm get head
Then try installing like so:
CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared
EDIT:
Note, working through my own issues I believe the first command probably fixed the problem. The second wouldn't have provided any benefit over:
rvm install 1.9.3
As on my clean install, /usr/bin/gcc-4.2 doesn't exist.
Also I wanted to add that I ended up compiling the older GCC manually for those situations where the new compiler fails. I followed this very informative blog post.
add --with-gcc=clang as a parameter:
rvm install ruby-1.9.3 --with-gcc=clang
Did you install the latest Xcode from Mac Store?
here is a nice guide i followed to update my ruby/Rails to 1.9.2/3.0
guide
good luck
Part of the problem is that with Mac OS X 10.7 (Lion), Apple switched C compilers, and some things don't build well with the new (LLVM) compiler yet. See http://eddorre.com/posts/rails-ultimate-install-guide-on-os-x-lion-using-rvm-homebrew-and-pow for decent instructions (note: I haven't followed these exact instructions, but they're a pretty good summary of the things I did do to get Rails working on Lion).
Once you have the C compiler issue dealt with, everything else should be pretty effortless.
Bonus tip: avoid MySQL. PostgreSQL is better in nearly every respect.
Thanks Delamenko finally got it to work
SUMMARY FOR STACK OVERFLOW
I was trying to install SiriProxy on a clean Lion installation on Xcode from App Store
I kept getting errors like :
The provided CC(/usr/bin/gcc) is LLVM based.
bash-3.2$ rvm install 1.9.3
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
After 2 days finally got it working with these two lines
http://stackoverflow.com/questions/8000145/ruby-rvm-llvm-and-mysql
bash-3.2$ rvm get head
bash-3.2$ CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared
Before that I had tried every stackoverflow article on Ruby and Lion so doing these may have done some setup that helped the above 2 steps work:
Things I tried included:
Running Install Xcode.app (I had downloaded from App Store - running this does futher installation)
Installing
https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC.
Set up CC in
more /Users//.bash_profile
bash-3.2$ more /Users/<USERNAME>/.bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export CC=/usr/share/TargetConfigs/bin/gcc
First line came from SiriProxy install instruction
https://github.com/plamoni/SiriProxy
2nd line export CC never seemed to work. So dont add.
It had many versions each pointing
I finally used CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared
See Arkku's answer - I tried everything here first, then did what he said and all is well.
As of Lion 10.7.3, Xcode 4.2 and Ruby 1.9.3p0 it's what works.

Resources