I've been running Rails application on Unicorn 5.5.5 and on certain environments it throws an exception which reads
bundler: failed to load command: unicorn (/usr/local/bundle/bin/unicorn)
Errno::EPERM: Operation not permitted
/usr/local/bundle/gems/unicorn-5.5.0/lib/unicorn.rb:123:in `fcntl'
/usr/local/bundle/gems/unicorn-5.5.0/lib/unicorn.rb:123:in `block in pipe'
/usr/local/bundle/gems/unicorn-5.5.0/lib/unicorn.rb:116:in `each'
/usr/local/bundle/gems/unicorn-5.5.0/lib/unicorn.rb:116:in `pipe'
/usr/local/bundle/gems/unicorn-5.5.0/lib/unicorn/http_server.rb:126:in `start'
/usr/local/bundle/gems/unicorn-5.5.0/bin/unicorn:128:in `<top (required)>'
/usr/local/bundle/bin/unicorn:23:in `load'
/usr/local/bundle/bin/unicorn:23:in `<top (required)>
I'd like to understand what fcntl does and why is this patch added. I don't really understand the internals around IO pipes and the code described here https://github.com/defunkt/unicorn/blob/master/lib/unicorn.rb#L115 and here https://bogomips.org/unicorn-public/20180820203038.25464-1-e#80x24.org/T/
Could someone explain why this is needed and what it actually does?
We have downgraded unicorn to v5.4.1 and all is back to normal. I know that is not the solution but it helps to solve the problem for the moment.
Related
I'm new on Ruby on Rails (actualy I'm new programming in general) and I tried to start a new server for my web app. I followed all the rules that were in the book, installed everything required (I hope I've installed it correctly), but it keeps giving me the following error:
My command ->
C:\Users\Júlia\work\demo>ruby bin/rails server
C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:50:in `match?': invalid byte sequence in UTF-8 (ArgumentError)
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:50:in `chop_basename'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:374:in `plus'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:354:in `+'
from C:/Ruby30-x64/lib/ruby/3.0.0/pathname.rb:420:in `join'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/settings.rb:444:in `global_config_file'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/settings.rb:93:in `initialize'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:330:in `new'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:330:in `settings'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:99:in `configured_bundle_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:95:in `bundle_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:639:in `configure_gem_home_and_path'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:81:in `configure'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:194:in `definition'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler.rb:143:in `setup'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/setup.rb:10:in `block in <top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/ui/shell.rb:136:in `with_level'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/ui/shell.rb:88:in `silence'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/lib/bundler/setup.rb:10:in `<top (required)>'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from C:/Users/Júlia/work/demo/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
I'm so frustrated right now, I keep doing things apparently right but something always has to go wrong! Anyways, I hope someone will be able to help me here :(
You can follow GoRails guide to install RoR on windows it will be much easier.
Here it is: Install Ruby On Rails on Windows 10
Also after installing it you may face some other issues related to your database ( whatever database you use) like you may have installed Postgresql on windows, so when after installing it on WSL you need to kill the one running on the port that WSL will use, and similar issues, all solved across the internet
I am new to Rails and I'm having trouble just starting. I consistently get an error that a fork failed due to allocation problems. This is the code:
root#shotgunrides:/home/rails/rails_project# rails g model post email:string
/usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application.rb:156:in `fork': Cannot allocate memory - fork(2) (Errno::ENOMEM)
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application.rb:156:in `serve'
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application.rb:131:in `block in run'
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application.rb:125:in `loop'
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application.rb:125:in `run'
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.6.2/lib/spring/application/boot.rb:18:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
Typically, when you see ENOMEM it means your system does not have enough memory available to accomplish whatever it was you were attempting to do. In this case it looks like your system doesn't have enough memory to handle your rails command, and just explodes.
If you could post some system specs that would be helpful, but killing running processes is pretty much the solution (aside from just adding more RAM).
After finishing the official getting started guide for RoR I played with it so much that I ruined the blog so I decided just to scrap everything and start again.
Now that I'm trying to run the rails server I get this error
/home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `destination_root='
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:85:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:17:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `new'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `dispatch'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/base.rb:440:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:10:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `block in <top (required)>'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `<top (required)>'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `load'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `<main>'
in the gemfile I have added
gem 'railties', '~>4.0.2'
then
$ bundle install
to try and resolve the issue. However it still hasn't work. I'm fairly new so I'm not actually sure what the error is.
Any thoughts would be appreciated.
I'm also running rails v4.0.2 if that helps
This is a pretty weird thing to see:
No such file or directory - getcwd (Errno::ENOENT)
Are you trying to run this application from a directory you maybe moved, or even deleted? That error implies that it can't determine the current directory.
Define rails in gem file like this
gem 'rails', '4.0.2'
And then bundle install.
Whoops. I derped. All sorted now. I was simply trying to run it from the wrong directory.
Should have seen it earlier.
I get intermittent errors when working with the MailChimp gem from the Rails console.
Here's the error:
Excon::Errors::SocketError: EOFError (EOFError)
from /Users/me/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/openssl/buffering.rb:246:in `readline'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/excon-0.26.0/lib/excon/response.rb:39:in `parse'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/excon-0.26.0/lib/excon/middlewares/response_parser.rb:6:in `response_call'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/excon-0.26.0/lib/excon/connection.rb:349:in `response'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/excon-0.26.0/lib/excon/connection.rb:252:in `request'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/excon-0.26.0/lib/excon/connection.rb:290:in `post'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/mailchimp-api-2.0.3/lib/mailchimp.rb:40:in `call'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/mailchimp-api-2.0.3/lib/mailchimp/api.rb:861:in `member_info'
from (irb):5
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/railties-3.2.14/lib/rails/commands/console.rb:47:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/railties-3.2.14/lib/rails/commands/console.rb:8:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p448#launchsoon/gems/railties-3.2.14/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I did a little searching on Excon::Errors::SocketError: EOFError (EOFError), and I came across this carrierwave issue, which seems to line up with my experiences.
I was able to reproduce this behavior - If I let my console sit there for a little while, then make a call to MailChimp's API, it fails once with the error above. If I retry the same call it succeeds.
So the issue seems to be caused by leaving the socket open beyond the keep-alive value. Unfortunately, I'm not aware of a fix/workaround other than "don't do that".
Just for the record, and if someone ends up here: version 0.44.4 of excon seems to have fixed this issue. Add
gem 'excon', '~> 0.44.4'
to your Gemfile and run
bundle update excon
I'm running a Rails 3 app with delayed_job. The issue I've come across is that though the app is correctly adding jobs to the queue, they are never being processed.
My Class
class User < ActiveRecord::Base
after_create :send_welcome_email
private
def send_welcome_email
UserMailer.delay.welcome_email(self)
end
end
Inspecting things through the Rails console I can see that there are jobs in the queue. I can also see that there have been 0 attempts to perform the jobs. Spinning up a Heroku worker doesn't cause the jobs to be processed.
Any ideas?
Thanks!
Edit: Trying to clear the jobs queue as suggested below I ran rake jobs:clear and received the following error
rake aborted!
uninitialized constant Rake::DSL
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:6:in `<module:Rake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:3:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/rdoctask.rb:20:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (requ
ired)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>
'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:214:in `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
In the end, the problem turned out to be a bug in Rake 0.9.0. As Rails depends on Rake, running bundle install after this release of Rake broke my delayed jobs.
The fix is to add gem 'rake', '0.8.7' to your gemfile.
More details can be found below...
DHH's tweet: http://twitter.com/dhh/status/71966528744071169
Discussion in rails_admin's issue tracker: https://github.com/sferik/rails_admin/issues/428
Two options for you:
These two gems watch delayed_jobs queue and automatically 'hires' background workers to process the thread:
Option 1: https://github.com/michelson/hirefire (This is what I am using because it supports mongoid)
Option 2: This branch of delayed_job developed by a heroku engineer has a similar autoscale feature: https://github.com/pedro/delayed_job/tree/autoscaling
Good luck
Are you running the delayed_job daemon in the same environment in which the application is running?
Try working the jobs manually using:
rake RAILS_ENV=development jobs:work
If you are running your app in production mode then you need to start delayed_job daemon as:
RAILS_ENV=production script/delayed_job start
This is kinda a long shot but make sure you are using the same Ruby version on Heroku as you are on your local machine. I had a problem with delayed jobs on Heroku before because of this.