I'm doing a tutorial on Ruby on Rails from Lynda, and everything has gone the way it should. All installations and everything has worked flawless.
But after creating a project, when I try to start the server (cmd: rails server) I get the error message:
LoadError: cannot load such file -- nokogiri/nokogiri
I have
* Windows 7 x64
* Rails 4.2.4,
* Gem 2.4.8.
I'm in the directory of the project. All files are there, everything looks ok. I created my project like this: ruby new test_cms and I also tried this: ruby new my_cms -d mysql . Same result.
Any ideas?
It looks as though nokogiri isn't be loaded, so you need it. So first think to do is check that it is in your Gemfile. If it is - move it to the top (I know - strange but it sometimes sorts out similar issues). If it's not, add it:
gem 'nokogiri'
Then run bundle install again.
Then try running bundle exec rails server to run the server with your bundle. You may be running it out of context.
If 'nokogirl' is located in your Gemfile maybe try updating your gems. try $ gem update --system.
Related
I've been following along with the Lynda.com's Ruby on Rails course. I did everything just as mentioned inside the videos.
I am trying to run the rails server command, which should default to WEBrick, correct?
I run the command and it has an issue in the nokogiri.rb file and on line 29 where the error is happening this is what is read:
require 'nokogiri/nokogiri'
Which is what my command prompt is throwing up on when running the rails server command. Any idea what could be causing this? If so, what commands do I need to run to settle this? To me it sounds like something was missed when installing MySQL.
I am not sure what nokogiri is and why rails server won't run and points to that line of code.
The path to this file is (Wherever you installed the folder to)\lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2-x64-mingw32\lib
EDIT**: I have a chain of errors, like it goes from -long path-, from -longpath- etcetera. I tried installing the latest gem, and it wasn't successful. Is there a log file I can get to share with you guys to help figure out the issue.
nokogiri is a Ruby "gem" (library) for parsing XML and HTML.
Your Rails project should have a Gemfile which specifies the name and version of each gem needed to run the project. To install the gems listed in the gemfile:
bundle install
After that install completes successfully, Rails should be able to find the nokogiri gem.
Try this
$ sudo apt-get install libxslt-dev libxml2-dev zlib1g-dev
$ sudo gem install nokogiri -v '1.5.11'
According to \lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2-x64-mingw32\lib, which means that you are running it on Windows platform. You are using ruby 2.2.0.
I know that nokogiri conflicts with 2.2.* versions of ruby in Windows. I have already encountered this problem. I think it is because of mingw32.
You need to install 2.1.* version of Ruby in order to make Nokogiri work.
I am new to this so please be lenient if I am not asking in a good way.
I have seen some similar questions such as: Can't start rails server mysql2 gem?
however I have not been able to solve this problem through their answers.
I am trying to start a ruby on rails server, I have installed MySQL, ruby, rails, and the gems successfully. I have also installed the sql2 gem successfully. I have created a project and changed to its directory. When I type:
rails server
to create a server, I get the following message in the terminal:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysql2.rb:2:in 'require': cannot load such file -- mysql2/2.2/mysql2 (LoadError)
followed by a lot more text but I believe this line is the root of the problem.
This is what is in the mysql2.rb file:
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql2/#{$1}/mysql2"
In the error it says it cannot load mysql2/2.2/mysql2,
when I navigate to the mysql2 folder, there is only a 2.0 and a 2.1 folder, no 2.2 folder. Is this the problem? If so do you know how I fix it?
Change require "mysql2/#{$1}/mysql2" to require "mysql2/2.1/mysql2" in your mysql2.rb file, I think the issue is that it's looking for the version that doesn't exist, give that a try and get back to us if it doesn't work.
Regards,
Grant
I am running through the Rails blog in 15 minutes tutorial and want to use MySQL instead of Sqlite. I have MySQL installed. And I created the app with the -d mysql switch.
Here is my error message when I attempt to scaffold:
"Incorrect MySQL client library version! This gem was compiled for 5.5.27 but the client library is 5.6.23. (RuntimeError)"
Based on this I believe I have the incorrect gemfile. I cannot seem to find the one that I need to use however. I used the command (gem install mysql2). Surely this is simple, no?
Yes #Daniel Clukier is correct it seems that your Mysql client version doesn't match with your mysql client gem version. Try this command
bundle update
Try adding gem 'sqlite3' to your Gemfile and run bundle in your terminal and see if that fixes it.
Edit:
Try what Daniel said, gem install mysql2 and then bundle and see if that fixes it. If not, try following this RichOnRails link here. It walks through making an app using the MySQL2 library.
I have a problem that seems very related to that in another post, but I don't understand the solution that was arrived at. I am new to Rails, and have put together a Rails 3 app. I am developing in Windows am trying to deploy it to my (shared) Redhat Linux server via git and capistrano, and using Passenger to serve the pages. The deployment process goes fine, but when I try to look at the webpage I get a Passenger error:
!!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'.
In fact, I have added the corresponding line to my Gemfile, and doing a 'gem list' on the server shows that it is there.
In this post, the user helpfully noted exactly the same problem and observed that the Gemfile.lock has the gem for Windows, i.e.
mysql (2.8.1-x86-mingw32).
This is exactly the same in my Gemfile.lock, and so I imagine the same issue is happening for me; one can see that this is the gem in vendor/cache and vendor/bundle.
However, I don't understand how the proposed fix from that post is supposed to work. I can edit the mysql line in Gemfile.lock to be mysql (2.8.1), but then I get a different Passenger error that says
Can't find mysql-2.8.1 in any of the sources.
How can I fix this?
In case someone encounters the same problem, here are some things I did that made it work. I don't understand enough of what was going on to know exactly what did the trick.
First, in the Gemfile, I specified that we wanted both ruby and windows versions of the relevant gems.
gem 'sqlite3-ruby', "~> 1.2.5", :platforms => [:mswin, :ruby_18]
gem 'mysql', "2.8.1", :platforms => [:mswin, :ruby_18]
Then on the production server, after using "cap deploy", I removed the gem mysql-2.81-x86-mingw32 from both vendor/bundle and vendor/cache. My production server lets me 'gem install mysql' and 'gem install sqlite3-ruby' but puts it elsewhere in my home directory; I copied these into vendor/bundle and vendor/cache. I edited the Gemfile.lock to change the line 'mysql (2.8.1-x86-mingw32)' to 'mysql (2.8.1)'. 'bundle install' on the production server then seems to install the linux native gems (at least it says 'building native extensions').
After all this, it seems to work.
Run the command bundle install. I'm sure this will fix your issue.
Also, do not edit or move over the Gemfile.lock. Let bundler take care of that.
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.