# Online update succeeds, but rebuild fails

**URL:** https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158
**Category:** Development
**Created:** [January 8, 2025, 11:14am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158 "2025-01-08T11:14:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 8, 2025, 11:14am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/1 "2025-01-08T11:14:00Z")

</div>

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](https://github.com/rmagick/rmagick), it succeeds.

However, it fails with a cli rebuild with:

```plaintext
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?)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 8, 2025, 11:45am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/3 "2025-01-08T11:45:12Z")

</div>

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

[https://github.com/discourse/discourse\_docker/commit/5ed07ecc93309003eeca589f7e526f872a098d4a](https://github.com/discourse/discourse_docker/commit/5ed07ecc93309003eeca589f7e526f872a098d4a)

was there a simultaneous imagemagick version bump?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [January 10, 2025, 12:32am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/4 "2025-01-10T00:32:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 10, 2025, 7:53am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/5 "2025-01-10T07:53:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [January 10, 2025, 5:53pm UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/6 "2025-01-10T17:53:11Z")

</div>

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

```plaintext
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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 10, 2025, 5:53pm UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/7 "2025-01-10T17:53:52Z")

</div>

thanks Jeff!!

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

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [January 10, 2025, 6:55pm UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/8 "2025-01-10T18:55:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 11, 2025, 2:56am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/9 "2025-01-11T02:56:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 21, 2025, 9:09am UTC](https://meta.discourse.org/t/online-update-succeeds-but-rebuild-fails/346158/10 "2025-01-21T09:09:06Z")

</div>

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

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