Installing mysql2 gem on Windows 8 - ruby

I'm trying to install the mysql2 gem on Windows 8 (Ruby 1.9.3 and Rails 4.0.1). I've installed the Devkit and it's working properly, and I'm entering the following:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-conector"'
I've done this before and it's worked, but for some reason this time it's throwing this bizarre message:
Cannot find include dir at C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector/include;
This is of course in addition to the whole "Could not create makefile for some reason..." message. I'm using the mysql connector that I found through a different post here--Ruby MYSQL2 gem installation on windows 7
Does anyone know how I can fix this? I really need this gem...

I figured this out...
All I had to do was:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector\"'
Strange though--last time it worked with the code above... Go figure...

I just ran into the exact same issue trying to install mysql2 0.3.14 on Window 64bit, Rails 3.2.15 and Ruby 2.0.0p247. I used a command very simliar to what user2986379 posted and it worked; literally 5 minutes later when I had to rerun the command to fix another issue it stopped working. I was even copying the command from notepad each time so there wasn't a typo. Odd.
Anyway, user2986379's solution of adding quotes to the paths helped me get past the issue, but I was still getting some errors. I ended up modifying the command by removing the single quotes. In case anyone needs it, here's the command I ran:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\mysql-connector"
Lastly, just for completeness, I had to use the version of connector c located here. You can read more about why this is necessary at the bottom of https://github.com/brianmario/mysql2/issues/372. It will install fine, but without the special connector_c you might get a segmentation fault when you go to actually use the gem. (Don't forget to grab the libmysql.dll out of that special connector c zip file as well and place it in your ruby bin directory.)

Related

'no such name' error on all gem install attempts

I just installed Ruby 2.2.2 on a Windows 7 64-bit VM. Every gem install <gemname> attempt fails with the following error:
ERROR: Could not find a valid gem '<gemname>' ()= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name
(https://api.rubygems.org/specs.4.8.gz)
However, the list generated by the gem list contains the gem that I thought failed. Is it actually installed or not? I assume it isn't but even if it is, the error concerns me.
I know that I am working behind a proxy so I've tried appending --http-proxy but that hasn't helped either.
Any ideas to troubleshoot this? Thanks!
It's possible that one of the gems that you installed declares an invalid dependency such as <gemname> (specifically).
To validate this, open an irb or pry console and run Gem.loaded_specs to see if the string <gemname> shows up anywhere.
You could also try updating your rubygems with gem update --system.
And finally, you could also try to run gem check to validate all installed gems.
Unfortunately, this appears to be an issue that needs to be investigated to get to the root cause.
I ran into the same issue before figuring out my session was fucked up. Indeed the command whoami was displaying an id and not my username. I logged out and logged in again and everything was solved.

`require': cannot load such file -- oauth

I was happily using Emacs's evernote-mode until stupidly removed OS X system ruby (I'm on Yosemite). Then I tried installing one via RVM (first tried 2.0 then 1.9), got all necessary gems, yet thing is still broken. Throws this message:
$HOME/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- oauth (LoadError)
from $HOME/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from $HOME/.rvm/rubies/ruby-1.9.3-p551/bin/enclient.rb:40:in `<main>'
Please help me to fix that
upd: I don't see the point of reinstalling system ruby (as people suggested) and then having it conflicting with those that I want to use via RVM. Ruby developers advise to use RVM. I symlinked my default Ruby to /usr/bin/ruby.
I seems that specific script uses something I don't have. I remember having hard time figuring out all dependencies and gems and installing them the first time I used that script and after hours of investigating it finally worked. But this time I got stuck.
I tried to run the script outside of Emacs and it runs with no errors (maybe that's not enough to find what's broken)
I tried to run irb and require modules one by one. It says => true until reaches require 'oauth/consumer'. I guess that's what's missing maybe? I run gem install oauth_consumer. It installed few gems, and now says => true for oauth/consumer in irb, the script though still doesn't work
i removed systems ruby once. i just had to go to the trash and put back everything i deleted and it worked for me. don't know how you "removed" your system ruby. besides, if you installed one with RVM then you have to tell RVM to choose and use/set a default ruby. because RVM won't install ruby 1.9.1 (rather a higher version which i think you did). So you have to set to that version.
Like this:
$ rvm --default use 2.1.5
don't forget to install oauth as well. Hope it helps.

Ruby Gems suddenly stopped working on ubuntu 12.04

After a couple of days of not doing pretty much anything on the ubuntu box, I decided to try out some ruby stuff. For this, I wanted to fire up pry. Unfortunately, I was presented with
Sorry, you can't use Pry without Readline or a compatible library.
Please gem install rb-readline or recompile Ruby --with-readline.
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require': libreadline.so.5: cannot open shared object file: No such
file or directory -
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so
(LoadError)
Being quite new to linux in general, I figured I'd just do as it said, and install this rb-readline. The installation passes just fine, but doesnt seem to do anything at all. If I do gem list p, the package just doesn't appear.
So yeah, I just don't know what to do to get it working again, and the only thing I managed to find by searching was related to an installation without rbenv and had something to do with sudo etc.
Any ideas?
Without understanding the problem and following the advice in option 2 of the message:
Sorry, you can't use Pry without Readline or a compatible library.
Possible solutions:
* Rebuild Ruby with Readline support using `--with-readline`
* Use the rb-readline gem, which is a pure-Ruby port of Readline <==== Option 2
* Use the pry-coolline gem, a pure-ruby alternative to Readline
I added the gem into the Gemfile (as follows), bundled and pry was then available.
group :development, :test do
gem 'pry'
gem 'rb-readline'
end
I had this problem too. I am using rbenv and reinstalling ruby via
rbenv install -f 2.2.3
did fixed it for me. Of course you'd put in your respective version. -f forces the installation even though you already have that specific version installed. use rbenv global to find out what version you have installed and set.
I have some problem. But I don't want to add gem 'rb-readline'. So try it...
$ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
Do a sudo apt-get install libreadline-dev, seems like you're missing the readline shared library that pry is wanting. If it worked before, not sure why the library isn't there anymore.
I ended up doing rbenv uninstall, followed by rbenv install and re-installing all the gems, and got it back to working. Still no idea what caused it in the first place, but it works now.

Trouble with sqlite3 ruby 2.0 on Windows

I'm a newbie to programming, with ruby/rails successfully installed on my (mac) home computer. I'm trying to get ruby 2.0.0p195 (and Rails) set up on Windows at work (Windows 7, 32bit) and I'm failing on the sqlite3 installation. I've been through most of the solutions/suggestions I can find on the web, but just can't get it to work - the frustrating thing is that it tells me it's installed, but it doesn't work:
- I've tried the knapsack installation http://www.ruby-forum.com/topic/4413168
- If I try to install --with-opt-dir=c:/sqlite3 (or any of the many variations suggested) it gives a native extension error.
- I've put the .dll file in Ruby/bin, which is also in my PATH
- I have the devkit installed
The 'gem install sqlite3' command is successful, and if I do 'gem list', sqlite3 v1.3.7 x86-mingw32 appears in the list, but if I 'require sqlite3' in IRB I get:
LoadError: cannot load such file -- sqlite3/sqlite3_native
And the mkmf log says:
find_header: checking for sqlite3.h... -------------------- no
But I've confirmed the sqlite3.h file (and the sqlite3.c, sqlite3.o, and sqlite3.h files) is in my c:\sqlite3 directory, and as noted above, I've also tried installing '--with-opt-dir'.
So next I trace the error when I 'require' sqlite to a file '\kernel_require.rb' in ruby/lib, and it references to this:
if Gem::Specification.unresolved_deps.empty? then
return gem_original_require(path)
end
I'm lost, and WAY out of my depth. At this point my only solution would be either to completely uninstall and start again, or to downgrade to ruby 1.9.x, but others seem to have sqlite3 and ruby 2.0 working so it's obviously (?) semi-stable. Help?
UPDATE: I've now tried downgrading to ruby 1.9.3, and apart from pik reverting to the most recent version of ruby every time I shut the command line, I can actually get the server to run etc. So it seems this issue is related specifically to ruby 2.0.
I am encountering the same issue, except that I don't really think that it is related to Ruby 2, but to rails 4 instead.
I have managed to install the sqlite3 gem by downloading the source, dll and exec (dll and executables need to be added to PATH accessible) and installying the gem with the follwing process:
Download:
http://www.sqlite.org/2013/sqlite-amalgamation-3071700.zip
http://www.sqlite.org/2013/sqlite-dll-win32-x86-3071700.zip
Extract and put the files in a location on your C drive or wherever you want. Then copy sqlite.dll and sqlite.def to the Ruby/bin directory.
Then you go to the DevKit directory and run msys.bat, in which you issue the following command:
gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=path-to-sqlite --with-sqlite3-include=path-to-sqlite
This allowed me to install the gem successfully (using Ruby-2.0.0-p247 x86 and devkit). I validated through irb doing:
require 'sqlite3'
SQLite3::SQLITE_VERSION
I'm still trying to figure out this issue.
I get the same error message when I try to start the server or whenever I try to run the rails console.
I'd love to get this issue fixed...

fubar'd a ruby installation on ubuntu, need helping purging it for reinstall

i originally followed these steps to get a RoR environmentgoing: https://help.ubuntu.com/community/RubyOnRails
that worked. then i put 1.9.2 on here. then i decided i want the original setup, did a "whereis ruby" and deleted those directories manually.
that fubar'd my ruby installation. i can't use the repository to what i originally had. how can i purge ruby from completely and start fresh?
right now the specific error is this:
/usr/lib/ruby/1.8/rubygems.rb:11:in `require': no such file to load -- thread (LoadError)
from /usr/lib/ruby/1.8/rubygems.rb:11
from /usr/bin/gem1.8:8:in `require'
from /usr/bin/gem1.8:8
tipu#tipu_ubuntu:~$
You're not giving enough real information to be specific, but this is what I'd try:
Use apt-search to locate Ruby 1.8.7 for your OS version.
Using apt-get, uninstall that version so you're back to what APT thinks is a clean slate.
Again using apt-get, reinstall that version so you're back to what APT thinks is a normal installation.
From that point, I would STOP messing with the system Ruby, and instead use RVM to manage and install any new Ruby and gems installations into RVM's ~/.rvm sandbox.
To follow up on the Tin Man's answer:
I wrote a guide to installing Ruby and Rails on Ubuntu which you may find useful for getting this all peachy again.
Hope it helps!
You need to reinstall libruby1.8. I'm pretty sure that will take care of it. I had exactly the same problem.

Resources