Mastodon: docker latest (2.4.0) mastodon:setup -> rake error

Created on 24 May 2018  路  12Comments  路  Source: tootsuite/mastodon

I am trying to set up a fresh docker/mastodon environment using the bundled docker-compose-File as desribed in the Docker-Guide. While docker-compose build works as expected docker-compose run --rm web rake mastodon:setup aborts with the following message:

Starting mastodon_redis_1 ... done
Starting mastodon_db_1    ... done
rake aborted!
Gem::LoadError: You have already activated rake 12.0.0, but your Gemfile requires rake 12.3.1. Prepending `bundle exec` to your command may solve this.
/mastodon/config/boot.rb:3:in `<top (required)>'
/mastodon/config/application.rb:1:in `require_relative'
/mastodon/config/application.rb:1:in `<top (required)>'
/mastodon/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Full trace below

System info:

  • docker-compose version 1.21.2, build a133471
  • docker 18.03.1-ce

~/docker/mastodon# docker-compose run --rm web rake mastodon:setup --trace
Starting mastodon_db_1    ... done
Starting mastodon_redis_1 ... done
rake aborted!
Gem::LoadError: You have already activated rake 12.0.0, but your Gemfile requires rake 12.3.1. Prepending `bundle exec` to your command may solve this.
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:313:in `check_for_activated_spec!'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:31:in `block in setup'
/usr/local/lib/ruby/2.4.0/forwardable.rb:229:in `each'
/usr/local/lib/ruby/2.4.0/forwardable.rb:229:in `each'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:26:in `map'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:26:in `setup'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler.rb:107:in `setup'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/setup.rb:10:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/mastodon/config/boot.rb:3:in `<top (required)>'
/mastodon/config/application.rb:1:in `require_relative'
/mastodon/config/application.rb:1:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/mastodon/Rakefile:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:687:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:96:in `block in load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:95:in `load_rakefile'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:79:in `block in run'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
EXIT 1
~/docker/mastodon#

Most helpful comment

$ docker-compose run --rm web ./bin/rails mastodon:setup

rake -> ./bin/rails

All 12 comments

$ docker-compose run --rm web ./bin/rails mastodon:setup

rake -> ./bin/rails

Yes, using rails instead of rake worked to get the setup to start. Sadly it did only change .env.production inside the container and as such fail to execute db:setup (missing/empty SECRET_KEY_BASE, seems to use the hosts .env.production, see below). Manually generating and entering the keys lets the containers start as expected. Since there are several other things wrong (like uncommenting build, which wasn't commented for years as far as I can see) I would guess the whole guide is outdated...

---snip---

# docker-compose run --rm web ./bin/rails mastodon:setup
[...]
# Generated with mastodon:setup on 2018-05-25 13:42:42 UTC
[...]
SINGLE_USER_MODE=true
SECRET_KEY_BASE=fa47852b911295630a49fe4e202f43a61212d3e2f232fb4aacb4bd4d44afef9a704dc1fd401a0343e4abb29781f1dde8c06deea1080a75898ae3c556fc943024
OTP_SECRET=c33d82bb1014d5d03e8b578f96a50d47dadc0895c446d871d89712cddc07cd6003daf7c407dfb1db0a76af26590988e34b2cac2131be1112e64b3919d0243768
[...]
Now that configuration is saved, the database schema must be loaded.
If the database already exists, this will erase its contents.
Prepare the database now? Yes
Running `RAILS_ENV=production rails db:setup` ...

rails aborted!
ArgumentError: `secret_key_base` for production environment must be a type of String`
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application.rb:583:in `validate_secret_key_base'
[...]

Same issue here, except I'm updating from v2.3.3 to v2.4.1...

Any solution?

Hi guys,

I'm getting the exact same error when running mastodon:setup

ArgumentError: `secret_key_base` for production environment must be a type of String

Running on a brand new Ubuntu 18.04 VPS.

I'm wondering if it's something to do with the step "Set correct file-owner with chown -R 991:991 public"? On my new Ubuntu install there's no UID 991 listed in /etc/passwd

Thanks!

these issuses all caused by .env.production, the file is not automaticlly written.
open a new terminal window, copy the generated configuration text and paste it into .env.production manually.
then back to first window, run next step below "If the database already exists, this will erase its contents."

Just wanted to leave a note that I encountered the same issue. I just had to re-run the setup an extra time and the second time it ran the migrations without any problems.

Same problem here, using latest docker tag, following the docker guide to the letter except for trying rake -> ./bin/rails as suggested above (either way, it fails with the same error):

rails aborted!
ArgumentError: `secret_key_base` for production environment must be a type of String`
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:583:in `validate_secret_key_base'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:432:in `secret_key_base'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:176:in `key_generator'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:205:in `message_verifier'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activestorage-5.2.1/lib/active_storage/engine.rb:67:in `block (2 levels) in <class:Engine>'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!'
/mastodon/config/environment.rb:5:in `<top (required)>'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:337:in `require_environment!'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create => db:load_config => environment
(See full trace by running task with --trace)
That failed! Perhaps your configuration is not right

Note that if I try and power through the setup (which will continue despite the exception above), it ends up failing due to a problem with the database not being initialized (since the step above is supposed to do that):

rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "users" does not exist
LINE 8:                WHERE a.attrelid = '"users"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"users"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `async_exec'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'

...snip...

/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
./bin/rails:4:in `<main>'
Tasks: TOP => mastodon:setup
(See full trace by running task with --trace)

Simple enough to solve: problem was a secret key not being defined. I had to run the secrets task to generate a secret key string, and copy and paste that secret key into the .env.production file. I read through the .env.production comments but missed this, since there is too much information in that file to digest. Would be nice if this secret-generation step were mentioned in the Docker Guide, instead of incorrectly stating that the secrets will be generated for you:

This is an interactive wizard that will guide you through the basic and necessary options and generate new app secrets.

@charlesreid1 would you care to post what you did?

I had to run the secrets task to generate a secret key string,

what is this precisely

adding

    environment:
      - SECRET_KEY_BASE=$$(bin/rake secret)

under

services:
  db:

resolved this

adding

    environment:
      - SECRET_KEY_BASE=$$(bin/rake secret)

under

services:
  db:

resolved this

Actually, it should be under:

services:
  db:

Same issue here, except I'm updating from v2.3.3 to v2.4.1...

Any solution?

You should use "
Example:
SECRET_KEY_BASE="4f4f4f54f5f46f46d4f5464"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sturmen picture sturmen  路  67Comments

SelfsameSynonym picture SelfsameSynonym  路  96Comments

ashfurrow picture ashfurrow  路  73Comments

BrianPansky picture BrianPansky  路  69Comments

inmysocks picture inmysocks  路  128Comments