2018-06-10

ArgumentError: path name contains null byte

bundle gemしたディレクトリ内でbundle installしようとしたら以下のエラーが発生した

--- ERROR REPORT TEMPLATE -------------------------------------------------------
# Error Report

...

ArgumentError: path name contains null byte

...

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

First, try this link to see if there are any existing issue reports for this error:
https://github.com/bundler/bundler/search?q=path+name+contains+null+byte&type=Issues

If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
https://github.com/bundler/bundler/issues/new

原因は以下のようにgemspecのspec.filesのsplit(“\x0”) を本来ダブルクォートで囲うべきなのにシングルクォートで囲ってしまったため。

Gem::Specification.new do |spec|
# ...
  spec.files         = `git ls-files -z`.split('\x0').reject do |f|
    f.match(%r{^(test|spec|features)/})
  end
# ...
end

bundle gemしたあとのgemspecのダブルクォートをシングルクォートで一括置換するとやりがちなやつ…orz

このエントリーをはてなブックマークに追加