Db:migrate fails (1.5.4 to 1.6.4)

I’m running a multi-site instance and running either:

$ sudo -u discourse -g discourse -H RAILS_ENV='production' bundle exec rake multisite:migrate

or

$ sudo -u discourse -g discourse -H RAILS_ENV='production' bundle exec rake db:migrate

Fails. here is the output:

rake aborted!
SyntaxError: /usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:13: syntax error, unexpected <<
            <<~TEXT
              ^
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:14: syntax error, unexpected keyword_in, expecting keyword_end
            Report is only available in latest image, please run:
                                       ^
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:14: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:19: syntax error, unexpected tXSTRING_BEG, expecting keyword_end
            ```
              ^
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `load'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `block in load'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `load'
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/plugin.rb:7:in `block in activate!'
/usr/home/discourse/discourse/lib/plugin/instance.rb:197:in `call'
/usr/home/discourse/discourse/lib/plugin/instance.rb:197:in `block in notify_after_initialize'
/usr/home/discourse/discourse/lib/plugin/instance.rb:195:in `each'
/usr/home/discourse/discourse/lib/plugin/instance.rb:195:in `notify_after_initialize'
/usr/home/discourse/discourse/config/application.rb:173:in `block (2 levels) in <class:Application>'
/usr/home/discourse/discourse/config/application.rb:173:in `each'
/usr/home/discourse/discourse/config/application.rb:173:in `block in <class:Application>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:36:in `call'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:30:in `instance_exec'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:30:in `run'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:54:in `run_initializers'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:352:in `initialize!'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/railtie.rb:194:in `public_send'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/railtie.rb:194:in `method_missing'
/usr/home/discourse/discourse/config/environment.rb:5:in `<top (required)>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `block in require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:328:in `require_environment!'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => multisite:migrate => environment
(See full trace by running task with --trace)

You need to do a rebuild first to upgrade to Ruby 2.3

1 Like

Thank you so much for the quick reply.

Actually, I’m not using the Docker image. I did a manual install on FreeBSD (Docker is experimental on FreeBSD).

Is the new version only works with ruby 2.3 ?

1 Like

Yup The minimum Ruby version has been bumped to 2.3

5 Likes

Thank you so much. I’ll try it with 2.3.

1 Like

Well, I installed chruby and Ruby 2.3.1:

$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-freebsd11.0]

Unfortunately, I still get the same error when I do:

$ RAILS_ENV='production' bundle exec rake multisite:migrate

or even:

$ RAILS_ENV=production bundle exec rake db:migrate

I’m maintaining this guid: https://www.babaei.net/blog/discourse-as-a-blog-comment-service-on-freebsd-without-docker/ and everything is done according to that, if that helps.

Here is the output with Ruby 2.3.1:

rake aborted!
SyntaxError: /usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:13: syntax error, unexpected <<
            <<~TEXT
              ^
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:14: syntax error, unexpected keyword_in, expecting keyword_end
            Report is only available in latest image, please run:
                                       ^
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:14: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/app/jobs/scheduled/daily_performance_report.rb:19: syntax error, unexpected tXSTRING_BEG, expecting keyword_end
            ```
              ^
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `load'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `block in load'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:268:in `load'
/usr/home/discourse/discourse/plugins/discourse-nginx-performance-report/plugin.rb:7:in `block in activate!'
/usr/home/discourse/discourse/lib/plugin/instance.rb:197:in `call'
/usr/home/discourse/discourse/lib/plugin/instance.rb:197:in `block in notify_after_initialize'
/usr/home/discourse/discourse/lib/plugin/instance.rb:195:in `each'
/usr/home/discourse/discourse/lib/plugin/instance.rb:195:in `notify_after_initialize'
/usr/home/discourse/discourse/config/application.rb:173:in `block (2 levels) in <class:Application>'
/usr/home/discourse/discourse/config/application.rb:173:in `each'
/usr/home/discourse/discourse/config/application.rb:173:in `block in <class:Application>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:36:in `call'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:30:in `instance_exec'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:30:in `run'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/initializable.rb:54:in `run_initializers'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:352:in `initialize!'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/railtie.rb:194:in `public_send'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/railtie.rb:194:in `method_missing'
/usr/home/discourse/discourse/config/environment.rb:5:in `<top (required)>'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `block in require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:328:in `require_environment!'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/railties-4.2.7/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/home/discourse/discourse/vendor/bundle/ruby/2.2/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => multisite:migrate => environment
(See full trace by running task with --trace)
(

I believe I found the culprit:

$ bundle env
Environment

    Bundler   1.13.2
    Rubygems  2.6.4
    Ruby      2.2.5p319 (2016-04-26 revision 54774) [amd64-freebsd11]
    GEM_HOME  /home/discourse/.gem/ruby/2.3.1
    GEM_PATH  /home/discourse/.gem/ruby/2.3.1:/home/discourse/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0
    Git       2.9.2


$ which ruby
/home/discourse/.rubies/ruby-2.3.1/bin/ruby

$ which bundle
/home/discourse/.gem/ruby/2.3.1/bin/bundle

$ which gem
/home/discourse/.rubies/ruby-2.3.1/bin/gem

$ echo $PATH
/home/discourse/.gem/ruby/2.3.1/bin:/home/discourse/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/bin:/home/discourse/.rubies/ruby-2.3.1/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin

The culprit is bundle, it picks the wrong Ruby (2.2.5) which is what shipped with FreeBSD not what I installed using chruby.

Any ideas?

2 Likes

I would recommend using rbenv to manage your Ruby versions.

2 Likes

Thanks for the suggestion. I got it to work. It required a reboot.

3 Likes