TracksApp / tracks

Tracks is a GTD™ web application, built with Ruby on Rails
https://www.getontracks.org/
GNU General Public License v2.0
1.18k stars 538 forks source link

Upgrading to newer Ruby in Ubuntu 20.04 fails #2630

Open habernal opened 3 years ago

habernal commented 3 years ago

I've been running Tracks on Ubuntu 18.04 LTS for a long time but now I have to upgrage do 20.04. It definitely comes with new Ruby versions (but I'm not a Ruby guy), which breaks Tracks.

The first issue was some missing javascript runtime, so I've added

gem "mini_racer"

to the Gemfile. After installing all gems, I get the following error when starting Tracks:

bundle exec rake db:migrate RAILS_ENV=production
rake aborted!
TypeError: superclass mismatch for class Command
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:2:in `<class:Thor>'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:1:in `<top (required)>'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:1:in `require_relative'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:1:in `<top (required)>'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/group.rb:1:in `require_relative'
/var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/group.rb:1:in `<top (required)>'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/railties-6.0.4/lib/rails/generators.rb:6:in `<top (required)>'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/coffee-rails-5.0.0/lib/coffee/rails/engine.rb:2:in `<top (required)>'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.7.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'
/var/lib/gems/2.7.0/gems/coffee-rails-5.0.0/lib/coffee-rails.rb:2:in `<top (required)>'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
/home/ubuntu/tracks/tracks-2.5.1/config/application.rb:7:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.1/Rakefile:4:in `require'
/home/ubuntu/tracks/tracks-2.5.1/Rakefile:4:in `<top (required)>'
/var/lib/gems/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)

What version of Ruby and other dependencies is required? Anyone installed Tracks succesfully from scratch on Ubuntu 20.04?

Update:

$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
habernal commented 3 years ago

OK, I found the issue described here in the wiki:

https://github.com/TracksApp/tracks/wiki/Ubuntu-bundler-broken-due-to-ruby-thor-dependency---explanation-and-workaround

habernal commented 3 years ago

I gave it a shot and installed on a clean Ubuntu 20.04 LTS in docer, here's the tutorial (including the workaround due to missing JS library and updating bundler):

https://github.com/TracksApp/tracks/wiki/Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support

ZeiP commented 3 years ago

Sorry for the delay here too. The Ruby versions currently being tested in the CI are 2.5, 2.6 and 2.7, so all of those should work.

Apparently, per the link you shared, the issue isn't with Ruby but with Debian/Ubuntu bundled version of Bundler. I think we could document this better and check that there's an actual upstream issue for fixing the issue – on a quick read the Ubuntu issue linked in the wiki page isn't about fixing the real issue.

habernal commented 3 years ago

Yes, this link ( https://github.com/TracksApp/tracks/wiki/Ubuntu-bundler-broken-due-to-ruby-thor-dependency---explanation-and-workaround ) is not really fixing the issue, it's a non-perfect patch/workaround.

But installing the upstream bundler through gem as I described here ( https://github.com/TracksApp/tracks/wiki/Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support ) should do the job regardless of the linux distro, right?

ZeiP commented 2 years ago

I couldn't reproduce this doing the following:

docker run -it ubuntu:focal
apt update
apt upgrade
apt install git-core nano wget ruby ruby-dev build-essential libsqlite3-dev shared-mime-info vim-nox
cd /srv
git clone https://github.com/TracksApp/tracks.git # (gets master)
cd /srv/tracks
bundler2.7 config set --local path 'vendor/bundle'
export RAILS_SERVE_STATIC_FILES=true
bundler2.7 install --without="mysql postgresql"
cp config/site.yml.tmpl config/site.yml
cp config/database.yml.tmpl config/database.yml
vi config/database.yml # Use the SQLite config instead
bundle2.7 exec rake db:migrate RAILS_ENV=production
bundle2.7 exec rake assets:precompile RAILS_ENV=production

Can you try again with the most recent codebase, ie. master? The last release is pretty old so this seems to be maybe already fixed there.

habernal commented 2 years ago

I'm sorry, still failing to compile even from master:

$ docker run -it ubuntu:20.04 bash
...
# apt-get update && apt-get dist-upgrade -y
# apt-get install git nano wget ruby ruby-dev build-essential libsqlite3-dev shared-mime-info -y
# gem install bundler
# wget https://github.com/TracksApp/tracks/archive/refs/heads/master.zip
# unzip master.zip
# cd tracks-master/
... config SQLite etc. as usual
# bundle config set --local path 'vendor/bundle'
# export RAILS_SERVE_STATIC_FILES=true
... instead of bundle install --without=mysql --without=postgresql -- it's deprecated and doesn't work anymore, run this:
# bundle config set --local without 'postgresql mysql'
# bundle install
# bundle exec rake assets:precompile RAILS_ENV=production
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/tracks-master/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in `autodetect'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs.rb:5:in `<module:ExecJS>'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/execjs-2.8.1/lib/execjs.rb:4:in `<top (required)>'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/coffee-script-2.4.1/lib/coffee_script.rb:1:in `<top (required)>'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/coffee-script-2.4.1/lib/coffee-script.rb:1:in `<top (required)>'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/coffee-rails-5.0.0/lib/coffee-rails.rb:1:in `<top (required)>'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:60:in `require'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:55:in `each'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:55:in `block in require'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:44:in `each'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler/runtime.rb:44:in `require'
/var/lib/gems/2.7.0/gems/bundler-2.2.31/lib/bundler.rb:175:in `require'
/tracks-master/config/application.rb:7:in `<top (required)>'
/tracks-master/Rakefile:4:in `require'
/tracks-master/Rakefile:4:in `<top (required)>'
/tracks-master/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
ZeiP commented 2 years ago

I didn't run assets:precompile before in the command sequence I suggested, but I retried it and it still works. Can you try the commands I mentioned in my previous comment and let me know if those work? It seems the only meaningful difference is that you install a separate bundler while my version uses the bundler from APT repository.

habernal commented 2 years ago

So the only difference I see is the package vim-nox - but it comes with some suspicious dependencies including ruby libraries !?

root@a9bd966065aa:/# apt-get install vim-nox
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  alsa-topology-conf alsa-ucm-conf ca-certificates file fonts-lato javascript-common libasound2 libasound2-data libcanberra0 libexpat1 libgdbm-compat4 libgdbm6 libgpm2 libjs-jquery libltdl7 liblua5.2-0 libmagic-mgc
  libmagic1 libmpdec2 libogg0 libperl5.30 libpython3.8 libpython3.8-minimal libpython3.8-stdlib libreadline8 libruby2.7 libsqlite3-0 libssl1.1 libtcl8.6 libtdb1 libvorbis0a libvorbisfile3 libyaml-0-2 mime-support netbase
  openssl perl perl-modules-5.30 rake readline-common ruby ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby-xmlrpc ruby2.7 rubygems-integration sound-theme-freedesktop tzdata unzip vim-common
  vim-runtime xxd xz-utils zip

So it would be nice to disect what are the actual minimal dependencies for Tracks (I suppose it doesn't run on top of vim, or does it? :)

habernal commented 2 years ago

Anyway, the difference in the installed packages regarding Ruby turned out to be zero. So vim-nox is definitely not a prerequisite.

habernal commented 2 years ago

OK, I'm confirming success of the following

docker run -it ubuntu:20.04
apt-get update && dist-upgrade -y
apt-get install git-core nano wget ruby ruby-dev build-essential libsqlite3-dev shared-mime-info
cd /srv
git clone https://github.com/TracksApp/tracks.git  # master
cd /srv/tracks
bundler2.7 config set --local path 'vendor/bundle'
export RAILS_SERVE_STATIC_FILES=true
bundle config set --local without 'postgresql mysql'
bundle install
cp config/site.yml.tmpl config/site.yml
cp config/database.yml.tmpl config/database.yml
nano config/database.yml    # Use the SQLite config instead
bundle2.7 exec rake db:migrate RAILS_ENV=production
bundle2.7 exec rake assets:precompile RAILS_ENV=production

Maybe one difference to my installation procedure was that you didn't remove Gemfile.lock (and I did). With keeping the file, this warning pops up

Warning: the running version of Bundler (2.1.2) is older than
the version that created the lockfile (2.2.22). We suggest you
to upgrade to the version that created the lockfile by
running `gem install bundler:2.2.22`.
habernal commented 2 years ago

OK, I finally gave it a go on a "real" Ubuntu 20.04 LTS (not clean docker), and after fiddling around with sassc installation (which eventually worked), the upgrade failed on migrating the database, namely

$ bundle2.7 exec rake db:migrate RAILS_ENV=production
rake aborted!
TypeError: superclass mismatch for class Command
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:2:in `<class:Thor>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:1:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:1:in `require_relative'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:1:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/group.rb:1:in `require_relative'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/group.rb:1:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.1/lib/rails/generators.rb:6:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/coffee-rails-5.0.0/lib/coffee/rails/engine.rb:2:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/coffee-rails-5.0.0/lib/coffee-rails.rb:2:in `<top (required)>'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
/home/ubuntu/tracks/tracks-2.5.2/config/application.rb:7:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/Rakefile:4:in `require'
/home/ubuntu/tracks/tracks-2.5.2/Rakefile:4:in `<top (required)>'
/home/ubuntu/tracks/tracks-2.5.2/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)

when I copied the sqldb from 2.5.1 to 2.5.2 and ran the db:migrate command.

I don't know ruby but the whole ruby ecosystem looks like a big mess. Maybe finally time to say Tracks good bye for good :/

ZeiP commented 2 years ago

The error you're getting sounds quite familiar, but I can't remember right away why it's happening. I think it's a version mismatch, so I wonder if you have the correct versions of the packages available.

The easiest way by far is by running it on Docker, that way you get a ready-to-use image instead of having to install all of the stuff yourself. Is there a particular reason you're not going that way?

habernal commented 2 years ago

The extra layer of Docker on AWS micro instance looked like an overkill to me (it definitely eats some resources) - I'd be running dockerized Ubuntu 18.04 (or 20.04, if I get this nasty error fixed) in AWS Ubuntu 20.04, makes little sense to me.

habernal commented 2 years ago

After some further hacking, I was finally able to get it work on Ubuntu 20.04 LTS on AWS... So here's a quick summary:

$ apt list --installed | grep ruby
$ sudo apt-get remove --purge bundler rubygems-integration
$ sudo apt-get autoremove --purge
$ sudo apt-get install ruby-dev build-essential libsqlite3-dev shared-mime-info

It installs bundler2.7:

$ bundler2.7 --version
Bundler version 2.1.2
edit Gemfile and change to
gem 'sassc-rails', '2.1.0'

edit Gemfile.lock and change to
    sassc (2.1.0)
...
    sassc-rails (2.1.0)

... takes time ...

cp config/site.yml.tmpl config/site.yml cp config/database.yml.tmpl config/database.yml nano config/database.yml # Use the SQLite config instead ... or copy from previous..

bundler2.7 exec rake db:migrate RAILS_ENV=production bundler2.7 exec rake assets:precompile RAILS_ENV=production

* Run tracks with SSL

```plain
$ bundler2.7 exec puma -e production -b 'ssl://0.0.0.0:3000?key=/etc/letsencrypt/live/serverprivkey.pem&cert=/etc/letsencrypt/live/servercert.pem'