YunoHost-Apps / mastodon_ynh

Free, open-source social network for YunoHost
https://joinmastodon.org/
GNU Affero General Public License v3.0
84 stars 33 forks source link

Ruby version mismatch #434

Closed yelvington closed 1 week ago

yelvington commented 5 months ago

Describe the bug

Ruby version mismatch

Context

I updated to 4.2.5 and everything seems to be working fine out of the box. However, while trying to restore some changes that were wiped by the upgrade, I hit a Ruby version issue. Following the instructions to increase post limit from here:

https://1010.gitlab.io/posts/customize-mastodon-character-limit/

After editing the live/app/validators/status_length_validator.rb, the next step is to recompile. Here is the command and the error.

mastodon@www:~/live$ RAILS_ENV=production bundle exec rails assets:precompile rbenv: version `3.2.3' is not installed (set by /var/www/mastodon/live/.ruby-version

Any advice appreciated.

panomaki commented 5 months ago

Could you check whether this command works?

cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/bundle exec rails assets:precompile

(It may have something to do with paths not being loaded correctly).

yelvington commented 5 months ago

Well, that definitely made a difference:

sh: 1: node: not found sh: 1: nodejs: not found Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/ Exiting!

Should I do the upgrade again, this time from main? Will that get the Ruby versions cleaned up?

panomaki commented 5 months ago

Probably not; if I look at main it'll give you the same files/versions. I don't understand exactly what's happening here but rather than that nodejs is not installed it seems not to be found (path problem?). I lack the time this weekend to help you out further but I've found a similar issue here - maybe it helps you out?

Zeitverschreib commented 5 months ago

I also encountered some problems when trying to rebuild the app after changing the max_toot_char settings.

After installing 3.2.3, there were several more errors like

<internal:/opt/rbenv/versions/3.2.3/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require': /lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block - /var/www/mastodon/live/vendor/bundle/ruby/3.2.0/gems/msgpack-1.7.1/lib/msgpack/msgpack.so (LoadError)

and

Webpacker requires Yarn ">=1 <4" and you are using Internal Error: EACCES: permission denied, mkdir '/root/.cache/node/corepack' Error: EACCES: permission denied, mkdir '/root/.cache/node/corepack' Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/

Until 4.2.0, I was able to make the chances and rebuild without any problems.

nschiwy commented 4 months ago

I encountered this issue also and wound up at this issue page upstream.

rbenv local 3.2.2 will at least allow you to run the commands using 3.2.2 but when I tried to run the upgrade command RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.3 I got a failure response and decided to table the issue.

nschiwy commented 4 months ago

Just an added note - I upgraded to 4.2.6 today just in time to get the notification for the newest critical security update (4.2.7). I saw in the high-level logging that it reinstalled Ruby 3.2.2 but it seems like there might be more to it if you look at the full logs https://paste.yunohost.org/raw/ucixeyaliw

Zeitverschreib commented 4 months ago

I found this in the debug of 4.2.7 and was able to recompile after changing the max char:

RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin:/opt/node_n/n/versions/node/16/bin:/opt/node_n/bin:/opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so bin/bundle exec rails assets:precompile

yelvington commented 4 months ago

Upgraded to 4.2.7, made my edits. I was able to recompile by using the path @Zeitverschreib specified, but removing the LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so (my server is an ARM Raspberry Pi).