Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Rails 3 Engine Throwing Gem::Package::TooLongFileName Error

I'm trying to build my engine using gem build myengine but I keep getting the following error:

ERROR:  While executing gem ... (Gem::Package::TooLongFileName)
    Gem::Package::TooLongFileName

I wouldn't expect myengine not to be too long of a name. Any idea what might be going on here?

like image 554
John Avatar asked Dec 12 '22 18:12

John


2 Answers

I solved this issue by finding the exact file that was causing the issue - it was a migration file with a long name.

For those who are interested, the error is thrown from the split_name method of TarWriter class of the rubygems source code. This error will bet thrown if:

  1. The relative path of a file, include the file name itself, is greater than 256 characters
  2. The file name is greater than 100 characters
  3. The file prefix is greater than 155 characters

I hope this helps. I've attached the source code for the split_name method below for review.

def split_name(name) # :nodoc:
  raise Gem::Package::TooLongFileName if name.size > 256

  if name.size <= 100 then
    prefix = ""
  else
    parts = name.split(/\//)
    newname = parts.pop
    nxt = ""

    loop do
      nxt = parts.pop
      break if newname.size + 1 + nxt.size > 100
      newname = nxt + "/" + newname
    end

    prefix = (parts + [nxt]).join "/"
    name = newname

    if name.size > 100 or prefix.size > 155 then
      raise Gem::Package::TooLongFileName
    end
  end

  return name, prefix
end
like image 189
John Avatar answered May 14 '23 02:05

John


I solved this Problem by updateing rubygems to 1.8.25 (gem update --system)

-edit-

check your project.gemspec file: comment out

s.files = ... or s.test_files = ...

if there is any file in your project with a name too long

like image 20
marco Avatar answered May 14 '23 01:05

marco