# Changes Requested to Support Discourse on TruffleRuby

**URL:** https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578
**Category:** Development
**Created:** [April 28, 2022, 5:06pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578 "2022-04-28T17:06:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bjfish](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bjfish/32/188318_2.png) [@bjfish](https://meta.discourse.org/u/bjfish)
#### Post date: [April 28, 2022, 5:06pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/1 "2022-04-28T17:06:17Z")

</div>

I would like to request the following 3 changes to help support running Discourse on TruffleRuby:

**Change Requested**  
Update bin/rails to disable unicorn when fork is not supported.

**Error**

```plaintext
<internal:core> core/kernel.rb:764:in `fork': fork is not available (NotImplementedError)

```

**Files**  
bin/rails

> <https://github.com/discourse/discourse/blob/b266a36967533105215e6848e475c69cb9e36e3e/bin/rails>

**Why**  
TruffleRuby do not support forking.

**Suggestion**  
Disable unicorn if !Process.respond\_to?(:fork)

========================================================

**Change Requested**  
Disable mini\_profiler for TruffleRuby

**Error**

```plaintext
<internal:core> core/kernel.rb:236:in `gem_original_require': cannot load such file -- stackprof (LoadError)

```

**Files**  
config/initializers/006-mini\_profiler.rb

> <https://github.com/discourse/discourse/blob/b266a36967533105215e6848e475c69cb9e36e3e/config/initializers/006-mini_profiler.rb>

**Why**  
Stackprof is not currently supported on TruffleRuby

**Suggestion**  
Disable mini\_profiler loading when RUBY\_ENGINE is “TruffleRuby”

========================================================

**Change Requested**  
Prevent rbtrace from loading

Similar usages already preventing rb\_trace from loading:

> <https://github.com/discourse/discourse/blob/b266a36967533105215e6848e475c69cb9e36e3e/config/application.rb#L264>

> <https://github.com/discourse/discourse/blob/b266a36967533105215e6848e475c69cb9e36e3e/config/environments/development.rb#L80>

**Error**  
Failure/Error: require ‘rbtrace’

**Suggestion**  
Use one of the methods in the above links to prevent loading rbtrace

**Files**  
spec/rails\_helper.rb

> <https://github.com/discourse/discourse/blob/b266a36967533105215e6848e475c69cb9e36e3e/spec/rails_helper.rb#L16>

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [April 29, 2022, 12:12pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/5 "2022-04-29T12:12:41Z")

</div>

Those seem like reasonable requests.

BTW: Has anything changed about `mini_racer` not being supported on TruffleRuby? That’s a major blocker.

> [@Update Gemfile fast\_xor platform to :ruby](https://meta.discourse.org/t/update-gemfile-fast-xor-platform-to-ruby/159064/2):
>
> Sure I just too care of this there are a few others I left which I am unsure about, what should I do with them? (byebug, ruby-prof, better\_errors, rbtrace, gc\_tracer, stackprof, memory\_profiler) That said we are totally blocked on truffle till we get mini\_racer working per: [https://github.com/oracle/truffleruby/issues/1827](https://github.com/oracle/truffleruby/issues/1827) Discourse is not really properly functional if you can not cook Markdown to HTML on the server.

---

<div class="post-metadata">

### Author: ![bjfish](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bjfish/32/188318_2.png) [@bjfish](https://meta.discourse.org/u/bjfish)
#### Post date: [April 29, 2022, 6:55pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/6 "2022-04-29T18:55:55Z")

</div>

> BTW: Has anything changed about `mini_racer` not being supported on TruffleRuby? That’s a major blocker.

I have a branch with most of the mini\_racer functionality passing the test suite using using GraalJS for TruffleRuby. I believe it handles all of the functionality needed for Discourse. It just needs to be reviewed and I’ll then I’ll try to get it merged. This is how I’ve been running it locally: [https://twitter.com/brandonfish/status/1486755128577253376](https://twitter.com/brandonfish/status/1486755128577253376)

---

<div class="post-metadata">

### Author: ![bjfish](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bjfish/32/188318_2.png) [@bjfish](https://meta.discourse.org/u/bjfish)
#### Post date: [May 2, 2022, 3:44pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/7 "2022-05-02T15:44:49Z")

</div>

> [@bjfish](#):
>
> **Suggestion**  
> Disable mini\_profiler loading when RUBY\_ENGINE is “TruffleRuby”

**Correction:**  
Disable mini\_profiler loading when RUBY\_ENGINE is “truffleruby”

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 3, 2022, 5:04am UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/8 "2022-05-03T05:04:01Z")

</div>

mini\_profiler should still be fine, I would recommend just having us not load rbtrace / stackprof etc. There are loose dependencies.

mini\_profiler can still provide plenty value in truffle world, nothing MRI specific about this.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/f/8/9f816b1d085cec79918f62741b828d15484e8d22.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/6/6/c/66cbfb1a45b0379a25a6bd208b2fe5e589a2592d.png)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 4, 2022, 8:10pm UTC](https://meta.discourse.org/t/changes-requested-to-support-discourse-on-truffleruby/225578/9 "2022-05-04T20:10:33Z")

</div>

Here’s a PR with the requested changes.

[https://github.com/discourse/discourse/pull/16641](https://github.com/discourse/discourse/pull/16641)

I still couldn’t get it to run successfully, there was a `java.lang.NullPointerException`, but that might be just me crudely disabling mini\_racer. I’m really looking forward to seeing a fully functional Discourse running on TruffleRuby.

> [@sam](#):
>
> mini\_profiler can still provide plenty value in truffle world, nothing MRI specific about this.

I didn’t look into this any further, but I noticed an error when I only disabled loading of stackprof and memory\_profiler. So I completely disabled mini\_profiler for now.

```plaintext
2022-05-04 21:48:13 +0200 Rack app ("POST /mini-profiler-resources/results" - (127.0.0.1)): #<SystemStackError: stack level too deep
        from StackOverflowCheckImpl.java:328:in `com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.newStackOverflowError0'>

```

It might have been a side effect of other problems. I guess we could investigate when other problems are solved.
