Heroku gets error with Ruby Mongrel gem - ruby-on-rails

Can't quite find the answer for my error in related posts.
I'm working my way through the on-line version of the Ruby on Rails Tutorial, Chapter 2
http://ruby.railstutorial.org/chapters/a-demo-app#top
and I'm near the bottom where I've created a small 2-table database and committed it to git. But it fails when I try to deploy with 'git push heroku master'. The same command worked previously before I added the tables to the app (and before I got Mongrel to work on the demo_app, I think).
My bundle includes Ruby 1.8.7, Mongrel 1.1.5 and sqlite3 1.3.3. I'm getting the line:
Installing mongrel (1.1.5) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions':ERROR: Failed to build gem native extension. (Gem:Installer::ExtensionBuildError).
How do I get around this problem? Can Heroku handle Mongrel at all? Or is it due to having a sqlite3 database? Why does the error mention Ruby1.9.2 when that's not in my bundle?

You don't need to use mongrel at all, and should simply remove it from your Gemfile. Whenever you see a reference to starting mongrel in your tutorial, just use ./script/server instead (or rails server if you're on Rails 3). It will run WebBrick, and that's good enough for development work.
If you really want to retain mongrel for local use you can group it as follows in Gemfile.
group :development do
gem "mongrel"
end
Note that you will likely still have to tell Heroku to not bundle your development gems or you'll run into the same error. If you're on the Cedar stack, then just get rid of the mongrel gem entirely.

Related

How to use mysql2 0.3.16 with Ruby 1.9.3? (uninitialized constant Mysql2::Client::SECURE_CONNECTION)

I'm trying to set up my local dev environment to match my team's. I can't upgrade Ruby/Rails/mysql2 (for the time being).
I know my local MySQL config is good (enough?) because I can create a new Rails project and run it just fine. I'm getting the same error if I run rake db:create or rails s or even start IRB and run require 'mysql2'.
I've googled the hell out of this. I was initially using MariaDB as my MySQL implementation locally, so I thought that might be screwing with the mysql2 gem. So I ripped out MariaDB and finally got MySQL 5.6 working (another team version we're locked into at the moment). After successfully upgrading to MySQL 5.6, I'm confident that's 100% not the issue.
I would expect if I had the wrong password for it to complain about the config somehow, but it's always the same.
uninitialized constant Mysql2::Client::SECURE_CONNECTION
Ruby (RVM): ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
Mysql2: 0.3.16
There have been some other version-related struggles, but nothing this strong. The only thing I've encountered that I haven't actually tried is building the mysql2 gem locally.
I would expect require 'mysql2' to at least load the gem. Neither Rails nor Rake will work with the gem at all. It's almost like it's missing some internal file.
following as discussion about this error in official gem, you should update version as
From
gem 'mysql2', '0.3.16'
to
gem 'mysql2', '0.3.17'
if you still met an error after you update version to 0.3.17, i think that you should update to 0.2.24
https://github.com/brianmario/mysql2/issues/603

Can't boot WEBrick, the folder for Rails gem is empty

I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.

Production not finding certain gem methods

I've added added the gem simple-navigation 3.9.0 to my gemfile in rails 3.2.11 and it runs fine in development. However, when I deploy to my production server and try to open a page with the method I get the following error:
undefined method `render_navigation'
I don't believe it's specific to that one gem though, as I had the same problem earlier when I used the uuid gem.
Using $LOADED_FEATURES I find "simple_navigation", so it seems to be loaded.
Info about the production server
nginx 1.2.6
Unicorn 4.5.0
Rubygems 1.8.23
Ubuntu 12.04 LTS
rbenv 0.4.0-9-g045f6c1
EDIT
Other gems work, the server runs fine, except for the above problem.
Make sure your gem is not declared inside the development group in the Gemfile
The gems in the development group are not be loaded in production.
group :development do
gem "simple-navigation"
end
Also, if you have a <APP_HOME>/.bundle/config file, ensure that it doesn't have the BUNDLE_WITHOUT option.
Gemfile
group :ui do
gem "simple-navigation"
end
.bundle/config
---
BUNDLE_WITHOUT: ui
In the above example, the gem group ui will not be loaded.
Having said that I had very-very limited exposure to Rails, I saw similar behavior when Gemfile.lock wasn't committed into repository. As result when project was pushed to production envinronment there was some screw ups with dependency resolution.
Have you try RAILS_ENV=production bundle install ?
While technically not an answer, I decided to switch over to Linode as my host. This involved a complete re-install of my server setup and it's working now. I did the exact same steps installing the server this time as last, so I'm still not sure what was wrong, or if it would have been easily fixable. Since I no longer have the old server available it would be impossible to confirm any solutions proposed from now on.
I'm going to mark this answer as the solution unless there are any objections within the next 48 hours.

undefined method `action_mailer' during Capistrano deployment

I'm having this error message come up during Capistrano deployment. It implies to me that something's wrong with Rails being installed or something? Rails is not currently installed on the server side, but it's in my Gemfile (and my Gemfile.lock), so I'm assuming it should be installed during the bundle install command that gets executed before this line.
The actual command that's giving the error is:
bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile
I guess the problem is just that Rails is not being installed during the bundle install. Am I missing something?
Thanks!
UPDATE 1: Rails appears to be installing correctly via the bundle install command. If I check out the directory .../shared/bundle/ruby/1.9.1/gems, I can see action mailer in there.
UPDATE 2: Running the command rake assets:precompile actually fails locally as well, so this doesn't have anything to do with Capistrano it would appear. Now I just have to figure out why the config object doesn't know anything about action mailer?
UPDATE 3: Hot on the trail. It looks like my installed version of actionmailer is 0.6.1 (?!), meanwhile all the rest of my Rails stuff is up at 3.2.9. bundle update refuses to update actionmailer past this version. I'm going to remove all of my gems and start fresh.
UPDATE 4: Deleted my entire gemset using rvm gemset empty. Then tried to run bundle again, and again it tries to get actionmailer 0.6.1. I think something is screwed up with bundler or something...
The problem ended up being that I had removed a dependency upon a specific version of Rails in my Gemfile. I just had gem "rails" in there. That seemed to completely botch the dependency calculations, because it was getting super-old versions of action mailer rather than getting a consistent version from all gems. Guess it's a bad idea to not specify an exact Rails version. Yikes!
#aardvarkk,
Thanks for posting this issue, I was having the same error with my installation of Rails 4.0.0 and the error was preventing me from running my rails server
This is while I'm trying to follow the Hartl Tutorial for RoR.
I added gem "rails", '4.0.0' to my gem file and now I'm able to run my rails server.
Thank you

Rails s doesn't boot mongrel by default

I'm developing rails app on
Mac OSX 10.7
RVM
Ruby 1.8.7
Rails 3.2.0
But, when I run rails s, Webrick will be booted by default.
Note that
I can boot into Mongrel by rails s mongrel. But as I start and stop the server for like every few minutes, it will be great if I can avoid typing 8 extra characters. And yes, I can do linux command to run specific previous command (something like !200). But, I'd be glad to solve this problem
This project used to develop with Rails 311rc2 and Ruby 1.9.3 (By previous developer) but with a lot of problems. So, I decided to switch to Ruby 1.8.7 and Rails 3.2.0
I need to use Ruby 1.8.7 as it's the same version as my company production server and all other projects/developers are using 1.8.7 too
I've been looking for a solution for almost two hours, visit a lot of site, tried all suggestion I found. But, none of them works
Here's my gem file
group :development do
gem 'mongrel', '>= 1.2.0.pre2'
gem 'ruby-debug'
end
What I tried,
1. uninstall and reinstall rvm 1.8.7
2. remove and reinstall gemset
3. remove all gem and run bundle install
Do you have any suggestion ?
It's not rails related but Rack related.
Before, rack by default launch a mongrel server if you have mongrel install. Now, this behavior change in prior of Thin. So if you have thin install, rack launch it instead of webrick.
If you want allways launch by Mongrel. specify it.

Resources