Failed to upgrade - syntax error, unexpected << js << <<~JS

AI-generated summary

naveedahmada036 encountered a SyntaxError while attempting to upgrade Discourse and Docker Manager, specifically citing an unexpected << operator in lib/plugin/instance.rb. After sam inquired about active plugins, naveedahmada036 listed several installed plugins, including Audio Onebox and Babble. cpradio suggested running ./launcher rebuild app to handle core changes and plugin updates. eviltrout noted the error might stem from Ruby 2.3 syntax usage, while Falco clarified that the user was not on the latest Docker image which enforces Ruby 2.3. Falco and cpradio reiterated that a standard git pull followed by a rebuild should resolve the issue, as Docker Manager is not required for this specific upgrade path. tgxworld expressed confusion regarding the error, noting a check was added to prevent such issues if Ruby 2.3 was not detected, and later located the syntax in the codebase but struggled to reproduce it tgxworld. Ultimately, naveedahmada036 confirmed that executing cd /var/discourse, git pull, and ./launcher rebuild app successfully resolved the upgrade failure.

Trying to upgrade discourse to latest version, but before that I need to upgrade docker manager and
getting following exception while upgrading:

Bundled gems are installed into ./vendor/bundle.
$ bundle exec rake multisite:migrate
rake aborted!
SyntaxError: /var/www/discourse/lib/plugin/instance.rb:273: syntax error, unexpected <<
      js << <<~JS
              ^
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:457:in `load'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:457:in `block in load_file'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:647:in `new_constants_in'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:456:in `load_file'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:354:in `require_or_load'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:317:in `depend_on'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:233:in `require_dependency'
/var/www/discourse/lib/discourse.rb:2:in `'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:240:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.7/lib/active_support/dependencies.rb:274:in `require'
/var/www/discourse/config/application.rb:31:in `'
/var/www/discourse/config/application.rb:19:in `'
/var/www/discourse/config/application.rb:18:in `'
/var/www/discourse/Rakefile:5:in `require'
/var/www/discourse/Rakefile:5:in `'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rake-11.2.2/exe/rake:27:in `'
(See full trace by running task with --trace)

Current versions:
docker_manager(9b59950)
discourse (11e303e)

Are you 100% sure you are not running any plugins except for docker_manager?

Sorry I should have included list of other plugins as well, using following plugins:

You are probably better off letting it upgrade all of them by logging into the server and running

./launcher rebuild app

Especially if you are following tests-pased, as a lot of those plugins have had changes due to recent Core changes.

1 Like

The problem here is the ruby 2.3 syntax - @tgxworld told it was safe to use, but perhaps it is not?

3 Likes

The guy isn’t running the latest docker image, the latest enforce ruby 2.3.

Yeah and I’m getting this exception while upgrading docker_manager.

Doesn’t a simple:

cd/ var/discourse
git pull
./launcher rebuild app

works?

The docker manager isn’t used to update the launcher, and is need on the big transition upgrade (ruby, pg, nginx, etc update from earlier this month).

5 Likes

That was my questioning too. In theory, I would think that would solve his issue.

2 Likes

Hmmm this is odd. I added a check to make docker manager raise an error and make the user rebuild if Ruby is not 2.3. Will have a look next week.

3 Likes

Hmm I can’t find a <<~JS ` heredoc anywhere (including your plugins).

Have you resolved the issue?

Otherwise, can you run the following commands and provide the output here?

./launcher enter app
ruby -v 
cat /VERSION
4 Likes

Ah I found it but the syntax we’re using is different and I’m not sure how to reproduce yet.

2 Likes
cd/ var/discourse
git pull
./launcher rebuild app

Did the trick. Thanks :slight_smile:

2 Likes