I am having some issues getting sql to work when trying to set my rails project. I have the latest version of both ruby and rails, the issue I believe lies within my terminal PATH. When typing gem install mysql, I get the following error:
ERROR: While executing gem ... (Errno::EACCES) Permission denied #
rb_sysopen -
/Users/myName/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/COPYING.
And when echoing my PATH I get the following description:
/Users/myName/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
This is a messed up path, and yes I have specified the PATH I want in the .bash_profile. My desired path looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" It just doesn't seem to work. Any ideas of what I am doing wrong? Running Sierra on a Macbook Pro 2015.
Thanks in advance for the help!
That error doesn't look like anything to do with your $PATH, which looks OK. It seems that you're trying to write to /Users/myName/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/COPYING but don't have permission. Maybe you installed something as root, and now root owns the gem files.
My guess is you need to fix the ownership of your .rbenv directory.
Try sudo chown -R myName /Users/myName/.rbenv, or if you want to be more rigorous, ls -l /Users/myName/.rbenv and see what the permissions look like before fixing whichever need it.
Managed to solve the issue with the help of this thread: brew install mysql on mac os. And with using my brain a bit more and installing the lated command tools... Hope this can help someone else who may have forgotten Xcodes part in it all.
Related
Good times for everyone.
I have such problem, feeling that it's simple, but due to I'm beginner I don't know the way to solve it: I'm trying to install mysql-gem for Ruby on Rails project in Windows. I've installed RubyGems succesfully, then command
RubyGems installed the following executables:
c:/Ruby19/bin/gem
D:\temp\ruby_sites\rubygems-1.8.10>
D:\temp\ruby_sites\rubygems-1.8.10>gem install mysql
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - C:/Users/Джестон/.gem/specs/rubygems.org%80/quick/Marshal.4.8/mysql-2.8.1.gemspec
D:\temp\ruby_sites\rubygems-1.8.10>
Please, hint me how to solve this problem. Turning off the antivirus software doesn't help.
Thanks for help!
gem installs stuff for admin user on your machine, so you need to start the command prompt as admin. (type cmd and instead of hitting enter, press ctrll+shift+enter to start command prompt as admin)
even if your account on windows (through which you logged in) is of type admin, it won't be enough. this is analogous to mac, wherein you use a "sudo" before doing similar stuff. hope this helps!
I originally configured my computer with rails, ruby and rvm. Afterwards, I downloaded mysql, but when I typed in mysql --version, it tells me that it is not installed. My echo path shows
/Users/ming/.rvm/gems/ruby-1.9.2-p180#default/bin:/Users/ming/.rvm/gems/ruby-1.9.2-p180#global/bin:/Users/ming/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/ming/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I am not sure if it's because I have both .bash_profile (blank) and .profile (export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"). I know that if they both exist, the latter would be ignored and since my .bash_profile is blank, mysql was saved to la-la land. When I copied the export PATH to the .bash_profile, I get an error message that reads:
"[[ -s "/Users/ming/.rvm/scripts/rvm" ]] && source "/Users/ming/.rvm/scripts/rvm" # This loads RVM into a shell session."
I am using:
Snow Leopard
Rails 3
Ruby 1.9.2
RVM
While I love RVM, it's becoming a real hassle so far whenever I download something new.
I read a bunch of stuff about this and it hasn't been helpful. Please help.
Thank you!
I don't know how you installed MySQL (there are a dozen ways to do so)
from source
from binary dmg
from macports
from fink
from brew
My recommandations is to install MySQL through the 'brew' command.
Personally I use .bash_profile along with rvm/brew and so far no issues.
I can't see the MySQL path in your $PATH though and neither the error message.
Try adding this:
PATH="$PATH:/usr/local/mysql/bin"
to your favourite file.
I'm trying to use Ruby with the MySQL that comes with MAMP, but there is a problem with the headers not being installed (or something like that).
Someone referred me to the tutorial copied below but I can't get it to work. When I put in the first line ./configure... it says no such directory.
1) One question in particular is, it says, "copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive." I don't know if by installing MAMP I have already done this step or not. If not, then I don't know what to do.
2) I also don't know what it means when it says "untar" the source file and "cd"...If MAMP is installed, has it been untarred already?
3) Also, do would I just open the terminal and start this code, or do I have to go into Mysql?
I wonder if anyone can tell me how to adapt it. Here are 2 other pieces of information about my installation that might be helpful.
a). MySQL is set up on port 8889 on my computer.
b) Also when I enter "which mysql" in the command line, it responds with "/usr/local/mysql/bin/mysql."
Please help if you can. Thanks.
Download the latest MAMP dmg file.
Download the 1.8.2 (or whichever the latest one you could find) components file from this page.
Unzip, mount the dmg, then copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive.
Untar the MySQL source file, and `cd` to the source file directory.
Compile the library:
$ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library
$ make -j2
Copy the compiled libraries into MAMP:
$ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql
Copy the MYSQL headers into MAMP:
$ mkdir /Applications/MAMP/Library/include
$ cp -R include /Applications/MAMP/Library/include/mysql
Install the Ruby MySQL Gem, on Snow Leopard:
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
On Leopard:
$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Enjoy!
EDIT # 2009-11-23: If you’re still experiencing problems (perhaps with RVM), try adding “/Applications/MAMP/Library/bin/” to your $PATH in “~/.bash_profile”.
You should probably follow the tutorial in this link. It is updated for MAMP 1.9.5 with mysql2. A couple of changes have been made to the new MAMP version.
http://blog.mirotin.net/?p=35
Furthermore the tar file you need can be found at this link. Download the MAMP_components_1.9.5.dmg file.
http://sourceforge.net/projects/mamp/files/mamp/1.9.5/
Finally got through this with this blog post: http://newfangled.me/installing-mamp-and-rails-on-a-mac/
Here's the archived version of that incase it goes offline http://web.archive.org/web/20130728130916/http://newfangled.me/installing-mamp-and-rails-on-a-mac
The other answer's reference 404s for me. http://blog.mirotin.net/?p=35
I'd been struggling with this for a while myself.
I've been fighting with a Rails install on my Mac for some time. The error I'm getting (in my development log) says:
Status: 500 Internal Server Error no such file to load -- mysql
Here's some info:
I can successfully rake db:migrate my application.
I've installed the MySQL gem and it appears in the gem list: mysql (2.8.1).
I have Passenger installed.
The error comes from an existing rails app that works on our production server.
Creating a new Rails app, a new MySQL db (using mysqladmin -uroot create sampledb) works fine.
I've googled this and can't find anything specific to this error. There are a few related results where the solutions relate to paths when installing the MySQL gem. For example,
sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
Has anyone else experienced this issue or suggest a solution?
Thanks for the response - the good news is, the problem is solved.
The bad news - I'm not entirely sure what fixed it. I can tell you this: it had something to do with the mysql gem install and all the flags pointing to lib, include and config. There are probably a dozen different versions of the same command floating around out there for Mac OS X Leopard.
The odd thing was that ruby appeared to be connected to mysql on some level (it's ability to rake db for example) but broke when actually loading a page.
The gem install string that ended up working was this:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I'd love some clarification on the how's & why's of this. This worked for me, but doesn't include pointers to the app directory, the lib directory or the include directory.
Do you have multiple ruby installed? Try invoking this command to find out: whereis ruby
Which ruby version is you passenger using? You can check this from your apache or nginx configuration
Is the ruby version passenger is using the same as ruby you are using from the command line?
Is mysql gem installed on that ruby version?
Double check if the mysql bin path is in your $PATH system environment variable. If you execute
*echo $PATH*
there must be displayed something like
*/usr/local/mysql/bin*
You can also type
mysql and then the tab-key twice.
If if this doesn't bring up a list of mysql commands (like mysqladmin etc.) the mysql bin path is not set ccorrectly. You can set it by adding the correct directory to your bash profile file.
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
Please verify up front if
*/usr/local/mysql/bin*
really contains the mysql commands on your Mac. Important: close and reopen the terminal window to make changes work.
For the last several days, I've been struggling to get ruby on rails to work on my mac. The main culprit is MySQL. Every time I fix one thing, another error shows up. I upgraded/downgraded MySQL to play nice with ruby, rail and gems, but nothing. My latest error is:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
/!\ FAILSAFE /!\ Wed Aug 05 21:09:23 -0700 2009
Status: 500 Internal Server Error
dlopen(/usr/local/lib/ruby/site_ruby/1.8/i686-darwin9.7.0/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib...
I don't have libmysqlclient.16.dylib; just *.15.dylib. Tried all the techniques, even installed or tried to install ruby-mysql-0.2.6 posted at tmtm.org
FYI: Last error prior to the one stated above had to do with authentication.
Appreciate any help.
Well, this question is a bit old already, but since I got here after getting the same error (but on LINUX), I would like to post my solution for future reference.
I simply had to install ruby-mysql.i686
yum install ruby-mysql.i686
Hope it helps somebody else in the future... tnx
Have you installed Xcode Developer tools? You can download it for free at http://developer.apple.com/.
Whenever I have issues with Ruby and MySQL, I never had Xcode installed. Could be wrong.
Answering my own question.
I don't know why and I don't know how, but took #Garrett's advice and re-installed Xcode. That didn't do anything. Went ahead and upgraded MySQL after that, which I had done before, and voilá! it worked. I'm guessing both re-installations finally got it working somehow. Weird!
Try using the below command . Provide the location of the mysql directory in your Mac .
sudo gem install mysql -- --with-mysql-dir= /usr/local/mysql
It looks like you haven't specified the location of mysql directory .
Good luck !