Online update succeeds, but rebuild fails

Came across a curious issue which may highlight another difference between online updates and command line updates.

If I perform an online update with a plugin with the rmagick gem, it succeeds.

However, it fails with a cli rebuild with:

ERROR:  Error installing rmagick:
	ERROR: Failed to build gem native extension.

    current directory: /var/www/discourse/plugins/discourse-topic-previews-sidecar/gems/3.3.6/gems/rmagick-6.0.1/ext/RMagick
/usr/local/bin/ruby extconf.rb
checking for brew... no
checking for pacman... no
checking for Ruby version >= 3.0.0... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include=${opt-dir}/include
	--without-opt-include
	--with-opt-lib=${opt-dir}/lib
	--without-opt-lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
	--with-pkg-config
	--without-pkg-config
	--with-override-variables
	--without-override-variables
/var/www/discourse/plugins/discourse-topic-previews-sidecar/gems/3.3.6/gems/pkg-config-1.5.6/lib/pkg-config.rb:504:in `parse_pc': .pc doesn't exist: <MagickCore> (PackageConfig::NotFoundError)

Are gems only built during a full build? Or could it be there has been a Ruby version increment which is only performed on a full rebuild? (which then forces a remake of the gem?)

1 Like

@featheredtoast any idea if this might have impacted rmagick gem?:

was there a simultaneous imagemagick version bump?

2 Likes

We’ve updated our image so we’re compiling imagemagick separately and only including the final imagemagick binary, so we are no longer including compile-time libs for imagemagick in the image in an effort to reduce the size of our base images.

You could simply add an install script to install imagemagick libs, but I’d recommend removing the plugin’s dependency on the rmagick gem - I’m not sure I see where that gem is being called as it looks like it’s extending core Discourse’s optimize image calls, which just calls out to the imagemagick binary directly.

1 Like

I’m using it for processing an image.

Even if I’m able to find a worklaround, it would be a real shame to block the use of rmagick gem as the alternative is messing with system calls to ImageMagick, which is a bit … clunky … and much less developer friendly as opposed to using a convenient API in language.

You can do something like pull in the gem’s compile-time dependencies - something like the following:

hooks:
  after_code:
    - exec: apt-get update && apt-get install -y libmagickwand-dev

we aren’t blocking anything from being installed, we are just no longer including the static libs that the gem is dependent on in the base image.

1 Like

thanks Jeff!!

I’ll first see if this can be eliminated, then try that as an alternative.

The right form needs cmd: etc. But sorry, no go. I can’t confirm if the error is same, though. I used tmux and it doesn`t allow scrolling for me.

1 Like

To scroll in tmux you control-b then [ (left bracket). You can then scroll and use q to get out of scroll mode.

1 Like

I solved this ultimately by moving to the rather unfriendly command line api. :sweat_smile:

The plugin no longer relies on the rmagick gem. That’s a bit of a shame, but needs must.

3 Likes