Mastodon: rails Error,and “HTTP ERROR 500”

Created on 20 Oct 2017  ·  27Comments  ·  Source: tootsuite/mastodon

When I run the step:
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup
Database 'mastodon_production' already exists
rails aborted!
Set SAFETY_ASSURED=1 to run this task in production
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/strong_migrations-0.1.9/lib/tasks/strong_migrations.rake:5:in block (2 levels) in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:inblock (3 levels) in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in block in perform' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:inperform'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:in invoke' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:inrequire'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in block in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:inload_dependency'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in require' bin/rails:4:in

'
Tasks: TOP => db:schema:load => strong_migrations:safety_assured
(See full trace by running task with --trace)

How do i do?Can U help me?

Most helpful comment

@hugogameiro Ok i do not think it is the reason for the database to be repeated I thought it was rails wrong, i now delete the database, run once

All 27 comments

Are you trying to do an install or an upgrade?

The command to upgrade is:
RAILS_ENV=production bundle exec rails db:migrate

@hugogameiro No no,just first install

Well, the script mentions that the database 'mastodon_production' already exists.

When you run the migrate command:
RAILS_ENV=production bundle exec rails db:migrate

If there is a blank database it will do the same as the install command.
If there is a database with an older version of Mastodon it will upgrade it to the version you are running the command with.
If there is some other data on the database, then it should just return an error but it can also break the data (be careful if this is the case)

So, if you are sure there is nothing that you need from the database 'mastodon_production' (or it is blank or an older version) then you can just try running the migrate and see what happens.

@hugogameiro Ok i do not think it is the reason for the database to be repeated I thought it was rails wrong, i now delete the database, run once

@hugogameiro ok,see it, or fail, this information looks like saying Rails code error

postgres=# drop database mastodon_production;
DROP DATABASE
postgres=# l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
xxx@ubuntu:~$ sudo su - mastodon
mastodon@ubuntu:~$ cd ~/live/
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup
Created database 'mastodon_production'
rails aborted!
Set SAFETY_ASSURED=1 to run this task in production
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/strong_migrations-0.1.9/lib/tasks/strong_migrations.rake:5:in block (2 levels) in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:inblock (3 levels) in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in block in perform' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:inperform'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:in invoke' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:inrequire'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in block in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:inload_dependency'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in require' bin/rails:4:in

'
Tasks: TOP => db:schema:load => strong_migrations:safety_assured
(See full trace by running task with --trace)

What version of Ruby do you have installed? I see 2.4.0 but you need minimum of 2.4.1

To upgrade:

su - mastodon
rbenv install 2.4.1
gem install bundler --no-ri

do it

but,Why do I look like this is 2.4.2?You see I use Ctrl + C interrupted the upgrade itself is 2.4.2
mastodon@ubuntu:~$ rbenv install 2.4.1
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2 ^C
mastodon@ubuntu:~$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

@hugogameiro I seem to understand that he acquiescence is 2.4.0, how should I make it use my 2.4.2 version,Now,i use rbenv install 2.4.1 updateingm try

you can try
rbenv global 2.4.2

understood! I encountered such a problem before the use of rvm re-installed ruby2.4.2, now, I use rbenv install 2.4.1, because I directly use rbenv global 2.4.2 will be prompted:

mastodon@ubuntu:~$ RAILS_ENV=production bundle exec rails db:setup
Could not locate Gemfile or .bundle/ directory

Did you run run:
gem install bundler --no-ri

no,I'm so stupid, because I feel it is going to be successful, very excited, and my English is not good, sorry, doing,Well, that's still the case
mastodon@ubuntu:~$ rbenv global 2.4.2
mastodon@ubuntu:~$ gem install bundler --no-ri
Successfully installed bundler-1.15.4
1 gem installed
mastodon@ubuntu:~$ RAILS_ENV=production bundle exec rails db:setup
Could not locate Gemfile or .bundle/ directory

SO,I still run "rbenv install 2.4.1" try it

You are not stupid. You are doing great.
Do an exit from the user mastodon and do follow these steps:

su - mastodon
cd live
gem install bundler
bundle install
npm upgrade yarn
yarn install

doing,Because it is in China, the installation is very slow

@hugogameiro It seems still did not change the results, I try to install ruby2.4.1 root and then set the global, try

xxx@ubuntu:~$ su - mastodon
Password:
mastodon@ubuntu:~$ cd live
mastodon@ubuntu:~/live$ gem install bundler
Successfully installed bundler-1.15.4
Parsing documentation for bundler-1.15.4
Done installing documentation for bundler after 17 seconds
1 gem installed
mastodon@ubuntu:~/live$ bundle install

balabala......................................

Bundle complete! 96 Gemfile dependencies, 162 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
mastodon@ubuntu:~/live$ npm upgrade yarn
mastodon@ubuntu:~/live$ yarn install
yarn install v1.2.1
[1/5] Resolving packages...
success Already up-to-date.
$ npm rebuild node-sass

[email protected] install /home/mastodon/live/node_modules/node-sass
node scripts/install.js

node-sass build Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node

[email protected] postinstall /home/mastodon/live/node_modules/node-sass
node scripts/build.js
Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
mastodon@ubuntu:~/live$ rbenv install 2.4.1
Installing ruby-2.4.1...
Installed ruby-2.4.1 to /home/mastodon/.rbenv/versions/2.4.1

mastodon@ubuntu:~/live$ rbenv global 2.4。1
rbenv: version 2.4。1' not installed mastodon@ubuntu:~/live$ rbenv global 2.4.1 mastodon@ubuntu:~/live$ ruby -v ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup Database 'mastodon_production' already exists rails aborted! Set SAFETY_ASSURED=1 to run this task in production /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/strong_migrations-0.1.9/lib/tasks/strong_migrations.rake:5:inblock (2 levels) in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:in block (3 levels) in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:inblock in perform'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in perform' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:ininvoke'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:inrequire'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:inblock in require'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in load_dependency' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:inrequire'
bin/rails:4:in `

'
Tasks: TOP => db:schema:load => strong_migrations:safety_assured
(See full trace by running task with --trace)

There is a strange character in "2.4。1" it needs to be exactly "2.4.1".
Also, you shouldn't change the ruby version after bundle install, it needs to be before.

Let me try and give you a the full steps you need and do them in this exact order.

First, delete the database 'mastodon_production'.

Then:

su - mastodon
cd ~
rbenv install 2.4.1
rbenv global 2.4.1
gem install bundler --no-ri
cd live
nano .ruby-version

what version is on the file .ruby-version? If it is 2.4.2, change to 2.4.1 and save.
Check the changes you made were saved: nano .ruby-version again. If the .ruby-version is now 2.4.1 continue:

cd live
gem install bundler
bundle install
npm upgrade yarn
yarn install
RAILS_ENV=production bundle exec rails db:setup

doing,If this fails again, I will use a brand new and clean environment on the virtual machine from scratch

Oh no:
postgres=# drop database mastodon_production;
DROP DATABASE
postgres=# l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)

postgres=# exit
postgres-# q
xxx@ubuntu:~$
xxx@ubuntu:~$ su - mastodon
mastodon@ubuntu:~$ cd ~
mastodon@ubuntu:~$ rbenv install 2.4.1
rbenv: /home/mastodon/.rbenv/versions/2.4.1 already exists
continue with installation? (y/N) y
Installing ruby-2.4.1...
Installed ruby-2.4.1 to /home/mastodon/.rbenv/versions/2.4.1

mastodon@ubuntu:~$ rbenv global 2.4.1
mastodon@ubuntu:~$ gem install bundler --no-ri
Fetching: bundler-1.15.4.gem (100%)
Successfully installed bundler-1.15.4
1 gem installed
mastodon@ubuntu:~/live$ vim .ruby-version
mastodon@ubuntu:~/live$ cat .ruby-version
2.4.1
mastodon@ubuntu:~/live$ npm upgrade yarn
mastodon@ubuntu:~/live$ yarn install
yarn install v1.2.1
[1/5] Resolving packages...
success Already up-to-date.
$ npm rebuild node-sass

[email protected] install /home/mastodon/live/node_modules/node-sass
node scripts/install.js

node-sass build Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node

[email protected] postinstall /home/mastodon/live/node_modules/node-sass
node scripts/build.js

Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
[email protected] /home/mastodon/live/node_modules/node-sass
Done in 13.67s.
mastodon@ubuntu:~/live$ bundle install
The latest bundler is 1.16.0.pre.3, but you are currently running 1.15.4.
To update, run gem install bundler --pre
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Using rake 12.1.0

balalabalabalba。。。。。。。。。。。。。。。。。。。。。。。。。

Bundle complete! 96 Gemfile dependencies, 162 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup
Created database 'mastodon_production'
rails aborted!
Set SAFETY_ASSURED=1 to run this task in production
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/strong_migrations-0.1.9/lib/tasks/strong_migrations.rake:5:in block (2 levels) in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:inblock (3 levels) in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in block in perform' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:inperform'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:in invoke' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:inrequire'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in block in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:inload_dependency'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in require' bin/rails:4:in

'
Tasks: TOP => db:schema:load => strong_migrations:safety_assured
(See full trace by running task with --trace)

Yep, maybe it's easier to just start with a clean install, really can't think of something that could be causing this.

Ok, this is a whole new environment Ubuntu Server 16.0.4, and all in accordance with the git process to do, here are all my steps, you can see which one you think there is a problem:start!

xxx@ubuntu:~$ su -
Password:
root@ubuntu:~# apt -y install curl
balabalabala。。。。。。。。。。
success!
root@ubuntu:~# cd /
root@ubuntu:/# curl -sL https://deb.nodesource.com/setup_6.x | bash -
balabalabalabala。。。。。。。。
Done!
root@ubuntu:/# adduser mastodon
balabalabala。。。。。。。。。。

root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
mastodon@ubuntu:~$ cd ~/.rbenv && src/configure && make -C src
warning: gcc not found; using CC=cc
aborted: compiler not found: cc

mastodon@ubuntu:~/.rbenv$ exit
logout
root@ubuntu:/# apt install gcc
balabalabala。。。。。。。。。。
success!

mastodon@ubuntu:~$ cd ~/.rbenv && src/configure && make -C src
The program 'make' can be found in the following packages:

  • make
  • make-guile
    Ask your administrator to install one of them
    mastodon@ubuntu:~/.rbenv$ exit
    logout
    root@ubuntu:/# apt install make
    balabala。。。。。。。。。。。

root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ cd ~/.rbenv && src/configure && make -C src
make: Entering directory '/home/mastodon/.rbenv/src'
gcc -fPIC -c -o realpath.o realpath.c
gcc -shared -Wl,-soname,../libexec/rbenv-realpath.dylib -o ../libexec/rbenv-realpath.dylib realpath.o
make: Leaving directory '/home/mastodon/.rbenv/src'
mastodon@ubuntu:~/.rbenv$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
mastodon@ubuntu:~/.rbenv$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
mastodon@ubuntu:~/.rbenv$ exec bash
mastodon@ubuntu:~/.rbenv$ type rbenv
rbenv is a function
rbenv ()
{
local command;
command="$1";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
mastodon@ubuntu:~/.rbenv$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
balabala。。。。。。。。。

mastodon@ubuntu:~/.rbenv$ rbenv install 2.4.2
Downloading ruby-2.4.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.bz2^C
So slow,i use VPN download it and remove to ~/.rbenv/cache/
mastodon@ubuntu:~/.rbenv$ mkdir cache && mv ruby-2.4.2.tar.bz2 cache/
mastodon@ubuntu:~/.rbenv$ rbenv install 2.4.2
Installing ruby-2.4.2...
Installed ruby-2.4.2 to /home/mastodon/.rbenv/versions/2.4.2
mastodon@ubuntu:~/.rbenv$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

mastodon@ubuntu:~/.rbenv$ cd ~
mastodon@ubuntu:~$ git clone https://github.com/tootsuite/mastodon.git live
balabalabalabala。。。。。。。。。。

mastodon@ubuntu:~$ cd ~/live/
mastodon@ubuntu:~/live$ git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
Note: checking out 'v2.0.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

HEAD is now at 09d81de... Suppress type error(not a function) on calling fastSeek (#5452)

I think the Error is no problem,carry on

mastodon@ubuntu:~/live$ gem install bundler
Fetching: bundler-1.15.4.gem (100%)
Successfully installed bundler-1.15.4
Parsing documentation for bundler-1.15.4
Installing ri documentation for bundler-1.15.4
Done installing documentation for bundler after 6 seconds
1 gem installed

mastodon@ubuntu:~/live$ bundle install --deployment --without development test
Fetching gem metadata from https://rubygems.org/............
balabalabala。。。。。。。。。。。。。
ERROR
checking for -licui18n... no
checking for -licui18n... no
In Gemfile:
charlock_holmes

Through google found may indeed libicu-dev, apt install it,then try aegin:
mastodon@ubuntu:~/live$ exit
logout
root@ubuntu:/# apt-get install libicu-dev
balabala
root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~/.rbenv$ cd ~/live/
mastodon@ubuntu:~/live$ bundle install --deployment --without development test
balabala。。。。。。
ERROR
checking for -lidn... no
In Gemfile:
idn-ruby
The same installation requires the plugin:
mastodon@ubuntu:~/live$ exit
logout
root@ubuntu:/# apt-get install libldap2-dev
root@ubuntu:/# apt-get install libidn11-dev
root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ cd ~/live/
mastodon@ubuntu:~/live$ bundle install --deployment --without development test
ERROR
checking for pg_config... no
checking for libpq-fe.h... no

mastodon@ubuntu:~/live$ exit
root@ubuntu:/# apt-get install libpq-dev
root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ cd live/
mastodon@ubuntu:~/live$ bundle install --deployment --without development test
ERROR
In Gemfile:
cld3
run it and try aegin:
root@ubuntu:/# apt-get install -y libprotobuf-dev protobuf-compiler
root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ cd live/
mastodon@ubuntu:~/live$ bundle install --deployment --without development test

Bundle complete! 96 Gemfile dependencies, 162 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
Post-install message from paperclip:

#

NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER

#

God, finally succeeded,carry on!~

mastodon@ubuntu:~/live$ yarn install --pure-lockfile
The program 'yarn' is currently not installed. To run 'yarn' please ask your administrator to install the package 'cmdtest'
mastodon@ubuntu:~/live$ npm -v
The program 'npm' is currently not installed. To run 'npm' please ask your administrator to install the package 'npm'

Now i hava two problem,
1: When I was the root user, my nodejs or not installed? I was set up rbenv global 2.4.1
2:npm should be installed after the built-in ruby, right?
Okey,apt install npm and yarn

I found that my nodejs did not install, I may be apt install-y balabala when the copy or the installation of a few software when the network lost the reasons for the connection,So that gem install this step there are a lot of missing errors,so I re-executed:
apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib letsencrypt yarn libidn11-dev libicu-dev

carry on!

root@ubuntu:/sudo su - mastodon
mastodon@ubuntu:~$ cd live/
mastodon@ubuntu:~/live$ yarn install --pure-lockfile
There are some warnings
yarn install v1.2.1
[1/5] Resolving packages...
[2/5] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/5] Linking dependencies...
warning "[email protected]" has incorrect peer dependency "webpack@^2.2.0".
warning "[email protected]" has incorrect peer dependency "react@^0.14.9 || ^15.3.0".
warning "[email protected]" has incorrect peer dependency "react@^0.14.0 || ^15.0.0".
warning "[email protected]" has incorrect peer dependency "react@^15.0.0".
warning "[email protected]" has incorrect peer dependency "react-dom@^15.0.0".
warning "[email protected]" has incorrect peer dependency "react@^0.14.0 || ^15.0.0".
warning "[email protected]" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0".
warning "[email protected]" has incorrect peer dependency "react@^0.14.0 || ^15.0.0".
warning "[email protected]" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0".
[4/5] Building fresh packages...
[5/5] Cleaning modules...
$ npm rebuild node-sass

[email protected] install /home/mastodon/live/node_modules/node-sass
node scripts/install.js

node-sass build Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node

[email protected] postinstall /home/mastodon/live/node_modules/node-sass
node scripts/build.js

Binary found at /home/mastodon/live/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
[email protected] /home/mastodon/live/node_modules/node-sass
Done in 464.63s.

No matter what the feeling is not big,carry on
mastodon@ubuntu:~/live$ exit
logout
root@ubuntu:/# sudo -u postgres psql
psql (9.5.9)
Type "help" for help.

postgres=# CREATE USER mastodon CREATEDB;
CREATE ROLE
postgres=# q

root@ubuntu:/# vim /etc/nginx/sites-available/test.com.conf
root@ubuntu:/# cat /etc/nginx/sites-available/test.com.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 80;
listen [::]:80;
server_name test.com;
# Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name test.com;

ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

ssl_certificate /home/key/fullchain.pem;
ssl_certificate_key /home/key/privkey.pem;

keepalive_timeout 70;
sendfile on;
client_max_body_size 0;

root /home/mastodon/live/public;

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

add_header Strict-Transport-Security "max-age=31536000";

location / {
try_files $uri @proxy;
}

location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri @proxy;
}

location /sw.js {
add_header Cache-Control "public, max-age=0";
try_files $uri @proxy;
}

location @proxy {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy "";
proxy_pass_header Server;

proxy_pass http://127.0.0.1:3000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

tcp_nodelay on;

}

location /api/v1/streaming {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy "";

proxy_pass http://127.0.0.1:4000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

tcp_nodelay on;

}

error_page 500 501 502 503 504 /500.html;
}
root@ubuntu:/# cd /etc/nginx/sites-enabled
root@ubuntu:/etc/nginx/sites-enabled# ln -s ../sites-available/example.com.conf
root@ubuntu:/etc/nginx/sites-enabled# systemctl stop nginx

It's a Error,I think it will not be successful because now my test.com is unable to connect, so i use the real available site before the pending certificate instead

root@ubuntu:/etc/nginx/sites-enabled# letsencrypt certonly --standalone -d test.com
Failed authorization procedure. test.com (tls-sni-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Incorrect validation certificate for tls-sni-01 challenge. Requested 87762dfd29b919cc64949355635c89da.70dfef155249af82cc7a0fa2c1e3c2e6.acme.invalid from 69.172.200.235:443. Received 4 certificate(s), first certificate had names "test.com, www.test.com"

root@ubuntu:/# vim /etc/nginx/sites-available/test.com.conf
root@ubuntu:/# mv /etc/nginx/sites-available/test.com.conf /etc/nginx/sites-available/test.forxu.cn.conf
root@ubuntu:/# ll /home/key/
total 72
drwxrwxrwx 2 root root 4096 Oct 22 02:00 ./
drwxr-xr-x 5 root root 4096 Oct 22 01:58 ../
-rwxrwxrwx 1 root root 1647 Oct 22 02:00 cert-1508311543.csr*
-rwxrwxrwx 1 root root 0 Oct 22 02:00 cert-1508311543.pem*
-rwxrwxrwx 1 root root 1647 Oct 22 02:00 cert-1508312546.csr*
-rwxrwxrwx 1 root root 0 Oct 22 02:00 cert-1508312546.pem*
-rwxrwxrwx 1 root root 1647 Oct 22 02:00 cert-1508312700.csr*
-rwxrwxrwx 1 root root 0 Oct 22 02:00 cert-1508312700.pem*
-rwxrwxrwx 1 root root 1647 Oct 22 02:00 cert-1508312846.csr*
-rwxrwxrwx 1 root root 2139 Oct 22 02:00 cert-1508312846.pem*
-rwxrwxrwx 1 root root 1647 Oct 22 02:00 cert.csr*
-rwxrwxrwx 1 root root 2139 Oct 22 02:00 cert.pem*
-rwxrwxrwx 1 root root 1684 Oct 22 02:00 chain-1508312846.pem*
-rwxrwxrwx 1 root root 1684 Oct 22 02:00 chain.pem*
-rwxrwxrwx 1 root root 3823 Oct 22 02:00 fullchain-1508312846.pem*
-rwxrwxrwx 1 root root 3823 Oct 22 02:00 fullchain.pem*
-rwxrwxrwx 1 root root 3243 Oct 22 02:00 privkey-1508311543.pem*
-rwxrwxrwx 1 root root 3243 Oct 22 02:00 privkey-1508312546.pem*
-rwxrwxrwx 1 root root 3243 Oct 22 02:00 privkey-1508312700.pem*
-rwxrwxrwx 1 root root 3243 Oct 22 02:00 privkey-1508312846.pem*
-rwxrwxrwx 1 root root 3243 Oct 22 02:00 privkey.pem*

root@ubuntu:/# systemctl restart nginx

carry on
root@ubuntu:/# sudo su - mastodon
mastodon@ubuntu:~$ cd ~/live
mastodon@ubuntu:~/live$ cp .env.production.sample .env.production
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rake secret
a26b8b734ce076b49e814654b53bbd57639ce955ab9ec057c9a16da3ff839214dbe265adb600638129081a7a67aee73bcc38f9aa54f1c7c8901617c8804fc37a
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rake secret
0a6e04afdaeb96489bbfba1871b0dc9a7d4c53622e83f59fa9d232ddc4752d58704d42205aff856557a19286ddad86e1666763081f86dd9f87e2b491422daf48
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rake secret
68595794da9040d47bf77e29d19f2ccf902afeae609457a1cb90a75b38f09f5014fd297073bb60096eeb6db161ec46f4fd93a169ce1519b8a9a36963b72e21d2
mastodon@ubuntu:~/live$ vim .env.production
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key
VAPID_PRIVATE_KEY=hQZlID-Ro3sXX4JP10PVbJLbS8vEm8A-jS_uIxIlGIk=
VAPID_PUBLIC_KEY=BA6-CBVbtpOdltkRpZ7IHQB41J26g05yw4LkrIuoFHPM8vrMhQsGa-vCj32SQWAeCn3nvns6zENOMStnx7_E6U8=

mastodon@ubuntu:~/live$ cat .env.production|grep -v "#"
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
DB_HOST=/var/run/postgresql
DB_USER=mastodon
DB_NAME=mastodon_production
DB_PASS=
DB_PORT=5432
LOCAL_DOMAIN=test.forxu.cn
LOCAL_HTTPS=true
PAPERCLIP_SECRET=819f2d6914d44bdcff67fd5faf550ff940c3b1736d3b13891ffdc5eef5e1556cf5d87404b7e14e438940e6d6ac9a66949b0ad431d0788be78afe0ae6acf20fdc
SECRET_KEY_BASE=05a0f0a79f8b0ab693b60f2160231b7618f264ec98c3a34de88034108e31d77033f2db7f93635b81f5d7f82fac22f33da9f6d2cb3bfbfbc8a9be619afdaca740
OTP_SECRET=6ff007fe041f2055141adec07a0a8d15c6c08fe15721f5a9f8958613f7790444ad2fc671e95d12a239ab517df1135ee5042c774b856db441f09a3f6bb0155de8
VAPID_PRIVATE_KEY=hQZlID-Ro3sXX4JP10PVbJLbS8vEm8A-jS_uIxIlGIk=
VAPID_PUBLIC_KEY=BA6-CBVbtpOdltkRpZ7IHQB41J26g05yw4LkrIuoFHPM8vrMhQsGa-vCj32SQWAeCn3nvns6zENOMStnx7_E6U8=
SMTP_SERVER=smtp.163.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=xxxxxxxxxxxxxxx
[email protected]
STREAMING_CLUSTER_NUM=1

On no!,and then to this step, is still wrong, my God, today is very late, sleep tomorrow to continue

mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup
Created database 'mastodon_production'
rails aborted!
Set SAFETY_ASSURED=1 to run this task in production
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/strong_migrations-0.1.9/lib/tasks/strong_migrations.rake:5:in block (2 levels) in <top (required)>' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:252:inblock (3 levels) in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in block in perform' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:inperform'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:in invoke' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:inrequire'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in block in require' /home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:inload_dependency'
/home/mastodon/live/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in require' bin/rails:4:in

'
Tasks: TOP => db:schema:load => strong_migrations:safety_assured
(See full trace by running task with --trace)

@hugogameiro Hi,
Oh, my god! I finally found a solution! Here's the detailed process:
When an error is added to the database:
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup
Created database 'mastodon_production'
rails aborted!
Set SAFETY_ASSURED=1 to run this task in production
balabalabalabala。。。。。。。。。。。。。。。

Just follow what he says: "Set SAFETY_ASSURED=1 to run this task in production" :
mastodon@ubuntu:~/live$ echo "SAFETY_ASSURED=1" >> .env.production
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails db:setup --trace
* Invoke db:setup (first_time)
*
Invoke db:schema:load_if_ruby (first_time)
* Invoke db:create (first_time)
*
Invoke db:load_config (first_time)
* Execute db:load_config
*
Execute db:create
Database 'mastodon_production' already exists
* Invoke environment (first_time)
*
Execute environment
* Execute db:schema:load_if_ruby
*
Invoke db:schema:load (first_time)
* Invoke environment
*
Invoke db:load_config
* Invoke db:check_protected_environments (first_time)
*
Invoke environment
* Invoke db:load_config
*
Execute db:check_protected_environments
* Invoke strong_migrations:safety_assured (first_time)
*
Invoke environment
* Execute strong_migrations:safety_assured
*
Invoke db:define_timestamp_id (first_time)
* Execute db:define_timestamp_id
*
Execute db:schema:load
-- enable_extension("plpgsql")
-> 0.0516s
-- create_table("account_domain_blocks", {:force=>:cascade})
-> 0.0703s
-- create_table("account_moderation_notes", {:force=>:cascade})
-> 0.0451s
-- create_table("accounts", {:force=>:cascade})
-> 0.1458s
-- create_table("blocks", {:force=>:cascade})
-> 0.0128s
-- create_table("conversation_mutes", {:force=>:cascade})
-> 0.0149s
-- create_table("conversations", {:force=>:cascade})
-> 0.0938s
-- create_table("custom_emojis", {:force=>:cascade})
-> 0.0486s
-- create_table("domain_blocks", {:force=>:cascade})
-> 0.0495s
-- create_table("email_domain_blocks", {:force=>:cascade})
-> 0.0141s
-- create_table("favourites", {:force=>:cascade})
-> 0.0550s
-- create_table("follow_requests", {:force=>:cascade})
-> 0.0575s
-- create_table("follows", {:force=>:cascade})
-> 0.0729s
-- create_table("imports", {:force=>:cascade})
-> 0.0300s
-- create_table("media_attachments", {:force=>:cascade})
-> 0.0521s
-- create_table("mentions", {:force=>:cascade})
-> 0.0200s
-- create_table("mutes", {:force=>:cascade})
-> 0.0159s
-- create_table("notifications", {:force=>:cascade})
-> 0.0452s
-- create_table("oauth_access_grants", {:force=>:cascade})
-> 0.0151s
-- create_table("oauth_access_tokens", {:force=>:cascade})
-> 0.1308s
-- create_table("oauth_applications", {:force=>:cascade})
-> 0.0504s
-- create_table("preview_cards", {:force=>:cascade})
-> 0.0323s
-- create_table("preview_cards_statuses", {:id=>false, :force=>:cascade})
-> 0.0082s
-- create_table("reports", {:force=>:cascade})
-> 0.2433s
-- create_table("session_activations", {:force=>:cascade})
-> 0.0228s
-- create_table("settings", {:force=>:cascade})
-> 0.0198s
-- create_table("site_uploads", {:force=>:cascade})
-> 0.0287s
-- create_table("status_pins", {:force=>:cascade})
-> 0.0143s
-- create_table("statuses", {:id=>:bigint, :default=># -> 0.0854s
-- create_table("statuses_tags", {:id=>false, :force=>:cascade})
-> 0.0517s
-- create_table("stream_entries", {:force=>:cascade})
-> 0.0858s
-- create_table("subscriptions", {:force=>:cascade})
-> 0.0611s
-- create_table("tags", {:force=>:cascade})
-> 0.0598s
-- create_table("users", {:force=>:cascade})
-> 0.0776s
-- create_table("web_push_subscriptions", {:force=>:cascade})
-> 0.0162s
-- create_table("web_settings", {:force=>:cascade})
-> 0.0283s
-- add_foreign_key("account_domain_blocks", "accounts", {:name=>"fk_206c6029bd", :on_delete=>:cascade})
-> 0.0066s
-- add_foreign_key("account_moderation_notes", "accounts")
-> 0.0034s
-- add_foreign_key("account_moderation_notes", "accounts", {:column=>"target_account_id"})
-> 0.0042s
-- add_foreign_key("blocks", "accounts", {:column=>"target_account_id", :name=>"fk_9571bfabc1", :on_delete=>:cascade})
-> 0.0032s
-- add_foreign_key("blocks", "accounts", {:name=>"fk_4269e03e65", :on_delete=>:cascade})
-> 0.0041s
-- add_foreign_key("conversation_mutes", "accounts", {:name=>"fk_225b4212bb", :on_delete=>:cascade})
-> 0.0045s
-- add_foreign_key("conversation_mutes", "conversations", {:on_delete=>:cascade})
-> 0.0053s
-- add_foreign_key("favourites", "accounts", {:name=>"fk_5eb6c2b873", :on_delete=>:cascade})
-> 0.0046s
-- add_foreign_key("favourites", "statuses", {:name=>"fk_b0e856845e", :on_delete=>:cascade})
-> 0.0033s
-- add_foreign_key("follow_requests", "accounts", {:column=>"target_account_id", :name=>"fk_9291ec025d", :on_delete=>:cascade})
-> 0.0031s
-- add_foreign_key("follow_requests", "accounts", {:name=>"fk_76d644b0e7", :on_delete=>:cascade})
-> 0.0046s
-- add_foreign_key("follows", "accounts", {:column=>"target_account_id", :name=>"fk_745ca29eac", :on_delete=>:cascade})
-> 0.0028s
-- add_foreign_key("follows", "accounts", {:name=>"fk_32ed1b5560", :on_delete=>:cascade})
-> 0.0034s
-- add_foreign_key("imports", "accounts", {:name=>"fk_6db1b6e408", :on_delete=>:cascade})
-> 0.0032s
-- add_foreign_key("media_attachments", "accounts", {:name=>"fk_96dd81e81b", :on_delete=>:nullify})
-> 0.0046s
-- add_foreign_key("media_attachments", "statuses", {:on_delete=>:nullify})
-> 0.0033s
-- add_foreign_key("mentions", "accounts", {:name=>"fk_970d43f9d1", :on_delete=>:cascade})
-> 0.0040s
-- add_foreign_key("mentions", "statuses", {:on_delete=>:cascade})
-> 0.0044s
-- add_foreign_key("mutes", "accounts", {:column=>"target_account_id", :name=>"fk_eecff219ea", :on_delete=>:cascade})
-> 0.0038s
-- add_foreign_key("mutes", "accounts", {:name=>"fk_b8d8daf315", :on_delete=>:cascade})
-> 0.0029s
-- add_foreign_key("notifications", "accounts", {:column=>"from_account_id", :name=>"fk_fbd6b0bf9e", :on_delete=>:cascade})
-> 0.0031s
-- add_foreign_key("notifications", "accounts", {:name=>"fk_c141c8ee55", :on_delete=>:cascade})
-> 0.0040s
-- add_foreign_key("oauth_access_grants", "oauth_applications", {:column=>"application_id", :name=>"fk_34d54b0a33", :on_delete=>:cascade})
-> 0.0027s
-- add_foreign_key("oauth_access_grants", "users", {:column=>"resource_owner_id", :name=>"fk_63b044929b", :on_delete=>:cascade})
-> 0.0297s
-- add_foreign_key("oauth_access_tokens", "oauth_applications", {:column=>"application_id", :name=>"fk_f5fc4c1ee3", :on_delete=>:cascade})
-> 0.0064s
-- add_foreign_key("oauth_access_tokens", "users", {:column=>"resource_owner_id", :name=>"fk_e84df68546", :on_delete=>:cascade})
-> 0.0074s
-- add_foreign_key("oauth_applications", "users", {:column=>"owner_id", :name=>"fk_b0988c7c0a", :on_delete=>:cascade})
-> 0.0061s
-- add_foreign_key("reports", "accounts", {:column=>"action_taken_by_account_id", :name=>"fk_bca45b75fd", :on_delete=>:nullify})
-> 0.0041s
-- add_foreign_key("reports", "accounts", {:column=>"target_account_id", :name=>"fk_eb37af34f0", :on_delete=>:cascade})
-> 0.0036s
-- add_foreign_key("reports", "accounts", {:name=>"fk_4b81f7522c", :on_delete=>:cascade})
-> 0.0050s
-- add_foreign_key("session_activations", "oauth_access_tokens", {:column=>"access_token_id", :name=>"fk_957e5bda89", :on_delete=>:cascade})
-> 0.0031s
-- add_foreign_key("session_activations", "users", {:name=>"fk_e5fda67334", :on_delete=>:cascade})
-> 0.0031s
-- add_foreign_key("status_pins", "accounts", {:name=>"fk_d4cb435b62", :on_delete=>:cascade})
-> 0.0033s
-- add_foreign_key("status_pins", "statuses", {:on_delete=>:cascade})
-> 0.0056s
-- add_foreign_key("statuses", "accounts", {:column=>"in_reply_to_account_id", :name=>"fk_c7fa917661", :on_delete=>:nullify})
-> 0.0054s
-- add_foreign_key("statuses", "accounts", {:name=>"fk_9bda1543f7", :on_delete=>:cascade})
-> 0.0034s
-- add_foreign_key("statuses", "statuses", {:column=>"in_reply_to_id", :on_delete=>:nullify})
-> 0.0054s
-- add_foreign_key("statuses", "statuses", {:column=>"reblog_of_id", :on_delete=>:cascade})
-> 0.0029s
-- add_foreign_key("statuses_tags", "statuses", {:on_delete=>:cascade})
-> 0.0032s
-- add_foreign_key("statuses_tags", "tags", {:name=>"fk_3081861e21", :on_delete=>:cascade})
-> 0.0034s
-- add_foreign_key("stream_entries", "accounts", {:name=>"fk_5659b17554", :on_delete=>:cascade})
-> 0.0032s
-- add_foreign_key("subscriptions", "accounts", {:name=>"fk_9847d1cbb5", :on_delete=>:cascade})
-> 0.0055s
-- add_foreign_key("users", "accounts", {:name=>"fk_50500f500d", :on_delete=>:cascade})
-> 0.0035s
-- add_foreign_key("web_settings", "users", {:name=>"fk_11910667b2", :on_delete=>:cascade})
-> 0.0030s
* Invoke db:ensure_id_sequences_exist (first_time)
*
Execute db:ensure_id_sequences_exist
* Invoke db:structure:load_if_sql (first_time)
*
Invoke db:create
* Invoke environment
*
Execute db:structure:load_if_sql
* Invoke db:seed (first_time)
*
Execute db:seed
* Invoke db:abort_if_pending_migrations (first_time)
*
Invoke environment
* Invoke db:load_config
*
Execute db:abort_if_pending_migrations
** Execute db:setup

As you can see, the table has been successfully added!

Then,Second, error compiling code:
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails assets:precompile
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key
rake aborted!
Devise.secret_key was not set. Please add the following to your Devise initializer:

config.secret_key = '4dee94b6703c13cb1583faad4489b5e5d15c25c2320bc8f5b7bd663cdae54e6d9969bebfedbd48dcbcccd87ad2684eb2f5db65dc7b429bbd428055fa8b21009c'

Please ensure you restarted your application after installing Devise or setting the key.
balabalalbala...........................

I put the "config. Secret_key = '4 dee94b6703c13cb1583faad4489b5e5d15c25c2320bc8f5b7bd663cdae54e6d9969bebfedbd48dcbcccd87ad2684eb2f5db65dc7b429bbd428055fa8b21009c'
"
In the/home/mastodon/live/config/initializers/devise in rb can:

mastodon@ubuntu:~/live$ echo "config.secret_key = '4dee94b6703c13cb1583faad4489b5e5d15c25c2320bc8f5b7bd663cdae54e6d9969bebfedbd48dcbcccd87ad2684eb2f5db65dc7b429bbd428055fa8b21009c'" >> ~/live/config/initializers/devise.rb
mastodon@ubuntu:~/live$ RAILS_ENV=production bundle exec rails assets:precompile
I, [2017-10-22T16:23:56.474774 #20254] INFO -- : Writing /home/mastodon/live/public/assets/doorkeeper/admin/application-50d68ad91b15067c63771e4811d971d7a56406c472a878021d1fb95d066efd8d.css
I, [2017-10-22T16:23:56.477322 #20254] INFO -- : Writing /home/mastodon/live/public/assets/doorkeeper/admin/application-50d68ad91b15067c63771e4811d971d7a56406c472a878021d1fb95d066efd8d.css.gz
I, [2017-10-22T16:23:56.520298 #20254] INFO -- : Writing /home/mastodon/live/public/assets/doorkeeper/application-29873392fba1f6a4fd5359214f854d900e24920096164f6e5343dbc0de69df0d.css
I, [2017-10-22T16:23:56.521290 #20254] INFO -- : Writing /home/mastodon/live/public/assets/doorkeeper/application-29873392fba1f6a4fd5359214f854d900e24920096164f6e5343dbc0de69df0d.css.gz
I, [2017-10-22T16:24:02.340528 #20254] INFO -- : Writing /home/mastodon/live/public/assets/pghero/application-a013dbdf269bc5d5f3610778edb4075c172f162ee90827f8839c4e8128a3a54d.js
I, [2017-10-22T16:24:02.342248 #20254] INFO -- : Writing /home/mastodon/live/public/assets/pghero/application-a013dbdf269bc5d5f3610778edb4075c172f162ee90827f8839c4e8128a3a54d.js.gz
I, [2017-10-22T16:24:02.359373 #20254] INFO -- : Writing /home/mastodon/live/public/assets/pghero/application-c2618b70600dfedb0f3ba1f916d97a2f93a3f265aba10356abb763bd663d0cbd.css
I, [2017-10-22T16:24:02.360005 #20254] INFO -- : Writing /home/mastodon/live/public/assets/pghero/application-c2618b70600dfedb0f3ba1f916d97a2f93a3f265aba10356abb763bd663d0cbd.css.gz
Webpacker is installed 🎉 🍰
Using /home/mastodon/live/config/webpacker.yml file for setting up webpack paths
Compiling…
After a long time, done!
Compiled all packs in /home/mastodon/live/public/packs

After I added the system service, I opened my test domain and finally saw the page I wanted! Thank you for your help!

Glad you managed to find the problem. Well done :)

So what's the solution?
Faced the same issue, where should I set SAFETY_ASSURED=1?

Edit: okay, echo "SAFETY_ASSURED=1" >> .env.production worked fine for me. Not very obvious from the messages above.

@MasterGroosha friend ,Please look carefully,
mastodonmastodon@ubuntu: /live$ echo "SAFETY_ASSURED=1">> .env.production,
and

echo "config.secret_key = '4dee94b6703c13cb1583faad4489b5e5d15c25c2320bc8f5b7bd663cdae54e6d9969bebfedbd48dcbcccd87ad2684eb2f5db65dc7b429bbd428055fa8b21009c'" >> /live/config/initializers/devise.rb:smile:

Just a security reminder, you really shouldn't paste your secret keys here. And, if your problem is solved, please close this issue.

closed because the problem was resolved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sorin-davidoi picture sorin-davidoi  ·  3Comments

hidrarga picture hidrarga  ·  3Comments

golbette picture golbette  ·  3Comments

ccoenen picture ccoenen  ·  3Comments

psychicteeth picture psychicteeth  ·  3Comments