Skip to content

RQRCode::QRCodeRunTimeError: code length overflow. (372>288) #15

meetme2meat opened this Issue Apr 3, 2012 · 12 comments

9 participants


When Generating "QRCode" the following above error was generated

The the string whose Qrcode is resulting in error


The Code"", :size => 4, :level => :h )
RQRCode::QRCodeRunTimeError: code length overflow. (540>288)
4poc commented Apr 11, 2012

+1 got the same error

plapinhh commented May 3, 2012

+1 the same.

i've fixed it by increasing the :size option's value ( url.to_s, :size => 10, :level => :l) ) and controlling my urls length...

but, i have not yet looked what the mean is...


@plapinhh Try a really long string and check does it break

j03w commented Sep 2, 2012

QR code version 4 with high level error correction give you maximum length of 50 alphanumeric characters

Follow the link to see full matrix of maximum capacity for each version:


Note that the chart gives some guidelines but it looks like the rqrcode library is not using any of the numeric or alphanumeric modes, only data.


irb(main):003:0> text = "a"*50
=> "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
irb(main):004:0> text.length
=> 50
irb(main):005:0> qr =, :size => 3, :level => :m)
RQRCode::QRCodeRunTimeError: code length overflow. (412>352)

It looks like I'm passing 50 characters, and at size 3 level m the chart says the limit is 61. Instead it errors and tells me that there are more data bits than allowed.


I'm hitting this same problem as well. My testing shows it only uses the binary mode. I thought passing message using str.encode("us-ascii") might trigger alphanumeric, but it doesn't.


FWIW, I ended up just putting my QR code generation inside a loop to find the best fit size. It is Not Great but functional. I post it as a way to illustrate what I'm talking about but please take a critical look before using it anywhere else.

  qr_size = 3
  qr = nil
  while qr == nil && qr_size < 10
      qr =, :size => qr_size, :level => :l)
    rescue RQRCode::QRCodeRunTimeError => e
      qr_size += 1

That's a good tip. Thanks!

Digging through the code, I've found there is no support for any mode except binary. I'm quite surprised by that. Check out QR8bitByte and QRCode classes. I was hoping to create a new QRAlphaByte class, but I'm not familiar enough with the code to create something that works.


Okay, this is the guy to use:

Lot's of progress on the code here, including the ability to encode alphanumeric.

haslo commented Oct 13, 2014

Very cool, thanks 👍 using the fixed version then 😄


I've had mostly great results with rqrcode-with-patches, with one exception.

You can view details here bjornblomqvist@whomwah:master...master

From my experience (and I encourage you to test this for yourself), fails, throwing 'code length overflow' when 194 < qr_text.length < 221

It's a bizarre bug -- normally it auto-selects the proper size very well. Can anyone else confirm / comment on this?

@wallace wallace added a commit to wallace/secret_santa that referenced this issue Mar 20, 2015
@wallace wallace Switches to rqrcode-with-patches
from whomwah/rqrcode#15 (comment)

it seems that rqrcode has been abandoned so i'm using the recommended one:
@bdewater bdewater referenced this issue in samvincent/rqrcode-rails3 Apr 10, 2015

Consider the rqrcode-with-patches gem #18


I have added a hint in the error on how to fix it.

RQRCode::QRCodeRunTimeError: code length overflow. (540>288) (Try a larger size!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.