我想在 Active Storage 中启用 PDF 预览: https://api.rubyonrails.org/classes/ActiveStorage/Preview.html
为了做到这一点,我使用
brew install poppler
在我的 Mac 上安装了 Poppler。我还在我的 gemfile 中安装了 Poppler gem。预览功能可以在本地计算机上按照我想要的方式工作。
当我部署到 Heroku 时,构建失败并收到以下错误:
An error occurred while installing gobject-introspection (4.0.5), and Bundler
cannot continue.
In Gemfile:
poppler was resolved to 4.0.5, which depends on
gio2 was resolved to 4.0.5, which depends on
gobject-introspection
我尝试使用以下构建包,但没有成功: https://github.com/amitree/heroku-buildpack-poppler.git
有人在 Heroku 上成功安装 Poppler 吗?理想情况下是在较新的 Heroku 堆栈上,而不是较旧的堆栈上。
我通过以下方式解决了这个错误
https://github.com/ruby-gnome/ruby-gnome/issues/1476#issuecomment-1147859975
它说要在根部制作一个
Aptfile
gir1.2-poppler-0.18
gir1.2-rsvg-2.0
gir1.2-gdkpixbuf-2.0
gir1.2-freedesktop
gir1.2-glib-2.0
libgirepository-1.0-1
libgirepository1.0-dev
libpoppler-dev
libpoppler-glib-dev
libcairo-gobject2
poppler-utils
添加宝石到
Gemfile
gem 'rsvg2'
gem 'glib2'
gem 'gobject-introspection'
gem "mini_magick"
奔跑
bundle install
设置
GI_TYPELIB_PATH = /app/.apt/usr/lib/x86_64-linux-gnu/girepository-1.0
现在我只需修复最后一个错误
GObjectIntrospection::RepositoryError::TypelibNotFound: Typelib file for namespace 'Poppler' (any version) not found (GObjectIntrospection::RepositoryError::TypelibNotFound)