During a running task this exception is raised by the Curb gem (https://github.com/taf2/curb).
failed to allocate memory
It's strange because before the Exception the gem works properly (with others curl calls).
Any ideas?
I'm using Ruby 1.9.3 on Ubuntu server (and same error in dev mode locally - Mac OS X)
EDIT
In my task I do very much (+10k) calls like this
req = Curl::Easy.new do |curl|
curl.ssl_verify_peer = false
curl.url = url
curl.headers['Content-type'] = 'application/json'
end
req.perform
Related
Newbie to Ruby on Rails here, I just did a fresh install of Ruby & Rails on Windows 10 (Bash on Ubuntu shell). I seems to having issues on starting the Rails server. Already checked the other threads on the issue, but everyone else is using OSX. :( Hope someone can help!
When running rails s,
root#TEAMROCKETHQ:~/newapp# rails s
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/app_loader.rb:40: warning: Insecure world writable dir /root/.rbenv/versions in PATH, mode 040777
=> Booting Puma
=> Rails 5.0.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.8.0 (ruby 2.4.0-p0), codename: Sassy Salamander
* Min threads: 5, max threads: 5
Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
For the first line issue, I tried:
sudo chmod 775 /usr/local
it seems it didn't do anything. Maybe I'm reading the error wrong, but I don't know... When I go to localhost:3000, it returns this error:
=> Booting Puma
=> Rails 5.0.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.8.0 (ruby 2.4.0-p0), codename: Sassy Salamander
* Min threads: 5, max threads: 5
Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
2017-03-09 23:17:26 -0600: Read error: #<Errno::EINVAL: Invalid argument - getsockopt(2)>
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/server.rb:124:in `getsockopt'
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/server.rb:124:in `closed_socket?'
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/server.rb:563:in `handle_request'
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/server.rb:425:in `process_client'
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/server.rb:289:in `block in run'
/root/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.8.0/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Webpage:
The localhost page isn't working
localhost is currently unable to handle this request.
HTTP ERROR 500
It is because puma 3.8.0.
Put gem 'puma', '3.7.1' in your gem file, and bundle install again.
And gem uninstall puma at version 3.8.0, wait until there is a fix.
I'm trying to get Jasmine to run in the command line (headless), but have had no success. With our current configuration:
Gemfile:
gem 'jasmine', :git => "git://github.com/pivotal/jasmine-gem.git"
gem 'jasmine-headless-webkit', :git => "git://github.com/johnbintz/jasmine-headless-webkit.git"
My current configuration of jasmine specs runs in the browser. rake jasmine:ci, however, opens a browser, and then aborts shortly thereafter with this error message:
/Users/`<me>`/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
I looked at the github page for jasmine-headless-webkit, and saw that the project is listed as dead. So! I tried to replace the jasmine & jasmine-headless-webkit gem with jasmine-rails, and I got this error:
ERROR: TypeError: 'undefined' is not an object (evaluating 'jasmine.Matchers.prototype')
TRACE:
-> file:///Users/<me>/<myapp>/tmp/jasmine/assets/jasmine-specs.js: 711
-> file:///Users/<me>/<myapp>/tmp/jasmine/assets/jasmine-specs.js: 736
-> file:///Users/<me>/<myapp>/tmp/jasmine/assets/jasmine-specs.js: 738
-> file:///Users/<me>/<myapp>/tmp/jasmine/assets/jasmine-specs.js: 862
rake aborted!
Error executing command: "/Users/<me>/.phantomjs/1.9.7/darwin/bin/phantomjs" "/Users/<me>/.rvm/gems/ruby-2.0.0-p353/gems/jasmine-rails-0.9.0/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/Users/<me>/<myapp>/tmp/jasmine/runner.html?spec="
Since most users seemed to want to run their jasmine specs using phantom, as part of the 2.0 release we made that the default. The ability to run jasmine:ci with selenium was extracted into its own gem.
I'm unable to get Mechanize to load a page that used to work -- it's reliably failing with a Errno: ECONNRESET: Connection reset by peer - SSL_connect message. Any suggestions as to what I should try or details I should look at? (Please see "what I've tried" below...)
Update 1
Taking a hint from a related S.O. post, I tried accessing the site directly with Net::HTTP. When I set http.ssl_version = :TLSv1, I get a redirect rather than an error (as it should be). So my question becomes: how can I configure Net::HTTP's underlying ssl_version parameters from within Mechanize?
Thanks...
The symptoms:
$ rails console
>> a = Mechanize.new
=> #<Mechanize:0x007fd26789b8e0 ...>
>> p = a.get("http://sce.com")
# (...after a long pause...)
Errno::ECONNRESET: Connection reset by peer - SSL_connect
from /sandbox/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
from /sandbox/usr/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
from /sandbox/usr/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /sandbox/usr/lib/ruby/2.0.0/net/http.rb:918:in `connect'
from /sandbox/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /sandbox/usr/lib/ruby/2.0.0/net/http.rb:857:in `start'
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:691:in `start'
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:631:in `connection_for'
...
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:257:in `fetch'
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:974:in `response_redirect'
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:298:in `fetch'
from /sandbox/usr/lib/ruby/gems/2.0.0/gems/mechanize-2.7.2/lib/mechanize.rb:432:in `get'
from (irb):3
The environment:
$ rake about
About your application's environment
Ruby version 2.0.0 (x86_64-darwin12.4.0)
RubyGems version 2.1.9
Rack version 1.5
Rails version 4.0.0
JavaScript Runtime JavaScriptCore
Active Record version 4.0.0
Action Pack version 4.0.0
Action Mailer version 4.0.0
Active Support version 4.0.0
Middleware ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd423c50e0>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /Users/me/MyProject
Environment development
Database adapter postgresql
Database schema version 20131017201057
$ openssl version
OpenSSL 1.0.1e 11 Feb 2013
$ system_profiler -detailLevel mini SPSoftwareDataType
System Software Overview:
System Version: OS X 10.8.5 (12F45)
Kernel Version: Darwin 12.5.0
Time since boot: 8 days 7:40
What I've tried:
I've tried the same URL from a Firefox web browser. It works.
I've explicitly set the Mechanize request_headers to exactly mimic the Firefox browser. No change.
I've updated my ssl/cert.pem file (a second time) as described in this S.O post. No change.
I've tried different sites: www.pge.com and www.sdge.com. Both work. There's something different about the www.sce.com site.
Success with Net::HTTP
Here's an example of Net::HTTP working:
$ irb
>> require 'net/https'
=> true
>> require 'uri'
=> false
>> uri = URI.parse("https://www.sce.com/")
=> #<URI::HTTPS:0x007facab8f6ba0 URL:https://www.sce.com/>
>> http = Net::HTTP.new(uri.host, uri.port)
=> #<Net::HTTP www.sce.com:443 open=false>
>> http.use_ssl = true
=> true
>> http.ssl_version = :TLSv1 # <= this line makes all the difference
=> :TLSv1
>> r = http.start { |agent| p agent.get(uri.path) }
=> #<Net::HTTPFound 302 Found readbody=true>
>> r.to_hash
=> {"content-language"=>["en-US"], "date"=>["Fri, 18 Oct 2013 01:00:07 GMT"], "location"=>["https://www.sce.com/wps/portal/home/!ut/p/b1/04_Sj9CPykssy0xPLMnMz0vMAfGjzOIt3Q1cPbz8DTzdQwKNDTyNAw38gh0djQ0MzIAKIoEKDHAARwNC-sP1o8BK8Jjg55Gfm6pfkBthoOuoqAgAgIrzaA!!/dl4/d5/L2dBISEvZ0FBIS9nQSEh/"], "p3p"=>["CP=\"NON CUR OTPi OUR NOR UNI\""], "server"=>["IBM_HTTP_Server"], "transfer-encoding"=>["chunked"], "x-powered-by"=>["Servlet/3.0"], "set-cookie"=>["PD_STATEFUL_d55ece64-8d9a-11e2-84a1-0050560010d6=%2Fwps; Path=/", "session_www=740796608.47873.0000; path=/"]}
The folks on the Mechanize mailing list kindly provided the answer:
agent = Mechanize.new do |a|
a.ssl_version = :TLSv1
end
I created an rvm gemset name that includes a colon, let's say project:marklar, then I do gem install rails inside that gemset. Everything goes well until it reaches json gem and throw this error:
Fetching: json-1.7.5.gem (100%)
Building native extensions. This could take a while...
/Users/username/.rvm/rubies/ruby-1.9.3p0/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/mysql/bin in PATH, mode 040777
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
creating Makefile
make
Makefile:158: *** target pattern contains no `%'. Stop.
I thought it was the ruby version that causes the problem, but when I changed into 1.9.2, it still throw the same error.
I used mac osx 10.8 mountain lion, surprisingly, when I removed the colon in the gemset name, let's say we changed it to marklar, everything goes well. Anyone noticed this behavior? Is this behavior expected or is it a bug in rvm, or in the json gem, or else?
I have compared Makefile defined in 1.9.3 and in 1.9.3#some:colon - there is no difference except the paths:
127,128c127,128
< RUBYLIBDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib$(target_prefix)
< RUBYARCHDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib$(target_prefix)
---
> RUBYLIBDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194#some:colon/gems/json-1.7.5/lib$(target_prefix)
> RUBYARCHDIR = /home/mpapis/.rvm/gems/ruby-1.9.3-p194#some:colon/gems/json-1.7.5/lib$(target_prefix)
after further checking I found that space and colon are not allowed in file names: Escaping colons in filenames in a Makefile => http://www.mail-archive.com/bug-make#gnu.org/msg03318.html
for some reason whenever i try to spawn a server with rubber it gets stuck after compiling ruby-1.9.2.
If I SSH into the server, I see that before it finishes compiling, almost at the very end, the rubber script disconnects the connection.
** [out :: stageone.foo.com] ruby-1.9.2-p0 - #compiling
If I try to do cap rubber:bootstrap it fails at trying to install mongrel citing that my ruby installation might not be complete.
Fetching: mongrel-1.1.5.gem (100%)39%)
** Building native extensions. This could take a while...
** ERROR: Error installing mongrel:
** ERROR: Failed to build gem native extension.
**
** /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
I'm trying to create a staging server using the "complete_mongrel_mysql" script.
any ideas?
Explanation is on the mailing list:
https://groups.google.com/d/msg/rubber-ec2/K-ahRFZpAAk/2fTJI5EeURwJ
Workaround checked into code for next release at:
https://github.com/wr0ngway/rubber/commit/64299e2005dcae9006273a6f915bf01dd8c87192