반응형
ruby 사용 중 asciidoctor-pdf-cjk-kai_gen_gothic-install을 실행하여 asciidoctor-pdf-cjk-kai_gen_gothic 라이브러리를 설치하는 도중 아래와 같은 에러가 발생했다.

root@LYJ:/usr/local/rvm/gems# asciidoctor-pdf-cjk-kai_gen_gothic-install
[1/20] Downloading KaiGenGothicCN-Bold-Italic.ttf
/usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:34:in initialize': No such file or directory @ rb_sysopen - <https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/download/v0.1.0-fonts/KaiGenGothicCN-Bold-Italic.ttf> (Errno::ENOENT) from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:34:in open'
from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:34:in block (3 levels) in <top (required)>' from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:33:in open'
from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:33:in block (2 levels) in <top (required)>' from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:31:in each'
from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:31:in each_with_index' from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:31:in block in <top (required)>'
from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:30:in chdir' from /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install:30:in <top (required)>'
from /usr/local/rvm/gems/ruby-3.0.0/bin/asciidoctor-pdf-cjk-kai_gen_gothic-install:23:in load' from /usr/local/rvm/gems/ruby-3.0.0/bin/asciidoctor-pdf-cjk-kai_gen_gothic-install:23:in <main>'
vi로 /usr/local/rvm/gems/ruby-3.0.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/exe/asciidoctor-pdf-cjk-kai_gen_gothic-install 이걸 까보면 uri 정보가 https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/download/v0.1.0-fonts/#{name} 으로 되어있다.
링크가 잘못되었나 싶어서 https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/에서 안에 있는 파일의 링크를 확인해보니 asciidoctor-pdf-cjk-kai_gen_gothic-install 파일 안에 있는 주소와 동일했다.

uri로 인한 문제는 아니었던 것이다...
아래 문장에서 에러가 나는 것인데,
file.write open("https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/download/v0.1.0-fonts/#{name}").read
open 대신 URI.open을 사용해주었다. (기존 코드는 주석처리함)
#!/usr/bin/env ruby
require 'open-uri'
FontsDir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'fonts'))
Fonts = %w(
KaiGenGothicCN-Bold-Italic.ttf
KaiGenGothicCN-Bold.ttf
KaiGenGothicCN-Regular-Italic.ttf
KaiGenGothicCN-Regular.ttf
KaiGenGothicJP-Bold-Italic.ttf
KaiGenGothicJP-Bold.ttf
KaiGenGothicJP-Regular-Italic.ttf
KaiGenGothicJP-Regular.ttf
KaiGenGothicKR-Bold-Italic.ttf
KaiGenGothicKR-Bold.ttf
KaiGenGothicKR-Regular-Italic.ttf
KaiGenGothicKR-Regular.ttf
KaiGenGothicTW-Bold-Italic.ttf
KaiGenGothicTW-Bold.ttf
KaiGenGothicTW-Regular-Italic.ttf
KaiGenGothicTW-Regular.ttf
RobotoMono-Bold.ttf
RobotoMono-BoldItalic.ttf
RobotoMono-Italic.ttf
RobotoMono-Regular.ttf
)
Dir.chdir(FontsDir) do
Fonts.each_with_index do |name, index|
puts "[#{index + 1}/#{Fonts.count}] Downloading #{name}"
File.open(name, 'wb') do |file|
uri = "https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/download/v0.1.0-fonts/#{name}"
filewrite= file.write URI.open(uri).read
#file.write open("https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic/releases/download/v0.1.0-fonts/#{name}").read
end
end
end
puts "Done"
위의 내용으로 변경하니

다행히 이제 install이 정상적으로 된다!!!!!
반응형