Failed to rebuild: no such file /usr/local/etc/ImageMagick-6/policy.xml

Hi,

I tried to update discourse with ./launcher rebuild app refer from How do I manually update Discourse and Docker image to latest?
But I got failure about ENOENT.

I did below commands to improve this situation.
dpkg-reconfigure -plow unattended-upgrades

apt-get update
apt-get dist-upgrade

wget -qO- https://get.docker.com/ | sh

But the error remained.
I can’t solve it. :sob:

Logs is here.

dstest:/var/discourse$ sudo ./launcher rebuild app
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
cd /pups && git pull && /pups/bin/pups --stdin
Already up to date.
I, [2020-11-13T07:34:54.569773 #1]  INFO -- : Loading --stdin
I, [2020-11-13T07:34:54.576058 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2020-11-13T07:34:54.676810 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2020-11-13T07:34:54.677475 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2020-11-13T07:34:54.702215 #1]  INFO -- : 
I, [2020-11-13T07:34:54.703054 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2020-11-13T07:34:54.712895 #1]  INFO -- : 
I, [2020-11-13T07:34:54.713681 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2020-11-13T07:34:54.717105 #1]  INFO -- : 
I, [2020-11-13T07:34:54.717680 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2020-11-13T07:34:54.719943 #1]  INFO -- : 
I, [2020-11-13T07:34:54.720466 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2020-11-13T07:34:54.723863 #1]  INFO -- : 
I, [2020-11-13T07:34:54.724449 #1]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2020/11/13 07:34:54 socat[27] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2020-11-13T07:34:54.791451 #1]  INFO -- : 
I, [2020-11-13T07:34:54.791940 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2020-11-13T07:34:54.795116 #1]  INFO -- : 
I, [2020-11-13T07:34:54.795545 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2020-11-13T07:34:54.798154 #1]  INFO -- : 
I, [2020-11-13T07:34:54.798578 #1]  INFO -- : > mkdir -p /shared/postgres_run/12-main.pg_stat_tmp
I, [2020-11-13T07:34:54.800772 #1]  INFO -- : 
I, [2020-11-13T07:34:54.801357 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/12-main.pg_stat_tmp
I, [2020-11-13T07:34:54.803400 #1]  INFO -- : 
I, [2020-11-13T07:34:54.807557 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2020-11-13T07:34:54.811426 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2020-11-13T07:34:54.815457 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2020-11-13T07:34:54.819414 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2020-11-13T07:34:54.820021 #1]  INFO -- : > chown -R root /var/lib/postgresql/12/main
I, [2020-11-13T07:34:58.099992 #1]  INFO -- : 
I, [2020-11-13T07:34:58.100865 #1]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/12/bin/initdb -D /shared/postgres_data || exit 0
I, [2020-11-13T07:34:58.103259 #1]  INFO -- : 
I, [2020-11-13T07:34:58.103633 #1]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2020-11-13T07:34:58.125185 #1]  INFO -- : 
I, [2020-11-13T07:34:58.125939 #1]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2020-11-13T07:34:58.128600 #1]  INFO -- : 
I, [2020-11-13T07:34:58.129158 #1]  INFO -- : > /root/upgrade_postgres
I, [2020-11-13T07:34:58.133295 #1]  INFO -- : 
I, [2020-11-13T07:34:58.133708 #1]  INFO -- : > rm /root/upgrade_postgres
I, [2020-11-13T07:34:58.135503 #1]  INFO -- : 
I, [2020-11-13T07:34:58.136036 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/12/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.136723 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.137998 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.138960 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.139939 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.140867 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' i
 /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.141833 #1]  INFO -- : > install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
I, [2020-11-13T07:34:58.144916 #1]  INFO -- : 
I, [2020-11-13T07:34:58.145559 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.146076 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.147118 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.162784 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/12/main/pg_hba.conf
I, [2020-11-13T07:34:58.163691 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/12/main/pg_hba.conf
I, [2020-11-13T07:34:58.164784 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main
I, [2020-11-13T07:34:58.166947 #1]  INFO -- : > sleep 5
2020-11-13 07:34:58.208 UTC [50] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2020-11-13 07:34:58.208 UTC [50] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-11-13 07:34:58.209 UTC [50] LOG:  listening on IPv6 address "::", port 5432
2020-11-13 07:34:58.218 UTC [50] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-11-13 07:34:58.302 UTC [53] LOG:  database system was shut down at 2020-11-13 07:23:18 UTC
2020-11-13 07:34:58.321 UTC [50] LOG:  database system is ready to accept connections
I, [2020-11-13T07:35:03.209924 #1]  INFO -- : 
I, [2020-11-13T07:35:03.222141 #1]  INFO -- : > su postgres -c 'createdb discourse' || true
2020-11-13 07:35:03.575 UTC [63] postgres@postgres ERROR:  database "discourse" already exists
2020-11-13 07:35:03.575 UTC [63] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database "discourse" already exists
I, [2020-11-13T07:35:03.578465 #1]  INFO -- : 
I, [2020-11-13T07:35:03.578976 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2020-11-13 07:35:03.644 UTC [74] postgres@discourse ERROR:  role "discourse" already exists
2020-11-13 07:35:03.644 UTC [74] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists
I, [2020-11-13T07:35:03.646897 #1]  INFO -- : 
I, [2020-11-13T07:35:03.647407 #1]  INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
I, [2020-11-13T07:35:03.711432 #1]  INFO -- : GRANT

I, [2020-11-13T07:35:03.712171 #1]  INFO -- : > su postgres -c 'psql discourse -c "alter schema public owner to discourse;"'
I, [2020-11-13T07:35:03.782199 #1]  INFO -- : ALTER SCHEMA

I, [2020-11-13T07:35:03.782901 #1]  INFO -- : > su postgres -c 'psql template1 -c "create extension if not exists hstore;"'
NOTICE:  extension "hstore" already exists, skipping
I, [2020-11-13T07:35:03.847761 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.848327 #1]  INFO -- : > su postgres -c 'psql template1 -c "create extension if not exists pg_trgm;"'
NOTICE:  extension "pg_trgm" already exists, skipping
I, [2020-11-13T07:35:03.909805 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.910376 #1]  INFO -- : > su postgres -c 'psql discourse -c "create extension if not exists hstore;"'
NOTICE:  extension "hstore" already exists, skipping
I, [2020-11-13T07:35:03.972494 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.973165 #1]  INFO -- : > su postgres -c 'psql discourse -c "create extension if not exists pg_trgm;"'
NOTICE:  extension "pg_trgm" already exists, skipping
I, [2020-11-13T07:35:04.035738 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:04.036418 #1]  INFO -- : > sudo -u postgres psql discourse
I, [2020-11-13T07:35:04.055691 #1]  INFO -- : update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = 'discourse' AND encoding = pg_char_to_encoding('SQL_ASCII');

I, [2020-11-13T07:35:04.147941 #1]  INFO -- : File > /var/lib/postgresql/take-database-backup  chmod: +x  chown: postgres:postgres
I, [2020-11-13T07:35:04.150956 #1]  INFO -- : File > /var/spool/cron/crontabs/postgres  chmod:   chown: 
I, [2020-11-13T07:35:04.151502 #1]  INFO -- : > echo postgres installed!
I, [2020-11-13T07:35:04.167002 #1]  INFO -- : postgres installed!

I, [2020-11-13T07:35:04.172330 #1]  INFO -- : File > /etc/service/redis/run  chmod: +x  chown: 
I, [2020-11-13T07:35:04.176723 #1]  INFO -- : File > /etc/service/redis/log/run  chmod: +x  chown: 
I, [2020-11-13T07:35:04.181121 #1]  INFO -- : File > /etc/runit/3.d/10-redis  chmod: +x  chown: 
I, [2020-11-13T07:35:04.182910 #1]  INFO -- : Replacing daemonize yes with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.183837 #1]  INFO -- : Replacing (?-mix:^pidfile.*$) with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.185609 #1]  INFO -- : > install -d -m 0755 -o redis -g redis /shared/redis_data
I, [2020-11-13T07:35:04.225330 #1]  INFO -- : 
I, [2020-11-13T07:35:04.226369 #1]  INFO -- : Replacing (?-mix:^logfile.*$) with logfile "" in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.227109 #1]  INFO -- : Replacing (?-mix:^bind .*$) with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.229259 #1]  INFO -- : Replacing (?-mix:^dir .*$) with dir /shared/redis_data in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.230796 #1]  INFO -- : Replacing (?-mix:^protected-mode yes) with protected-mode no in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.232306 #1]  INFO -- : Replacing # io-threads 4 with io-threads $redis_io_threads in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.233981 #1]  INFO -- : > echo redis installed
I, [2020-11-13T07:35:04.236684 #1]  INFO -- : redis installed

I, [2020-11-13T07:35:04.237270 #1]  INFO -- : > cat /etc/redis/redis.conf | grep logfile
I, [2020-11-13T07:35:04.263966 #1]  INFO -- : logfile ""

I, [2020-11-13T07:35:04.264740 #1]  INFO -- : > exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
I, [2020-11-13T07:35:04.266909 #1]  INFO -- : > sleep 10
167:C 13 Nov 2020 07:35:04.374 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
167:C 13 Nov 2020 07:35:04.375 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=167, just started
167:C 13 Nov 2020 07:35:04.375 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 167
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

167:M 13 Nov 2020 07:35:04.379 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
167:M 13 Nov 2020 07:35:04.379 # Server initialized
167:M 13 Nov 2020 07:35:04.379 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
167:M 13 Nov 2020 07:35:04.498 * DB loaded from disk: 0.118 seconds
167:M 13 Nov 2020 07:35:04.498 * Ready to accept connections
I, [2020-11-13T07:35:14.270726 #1]  INFO -- : 
I, [2020-11-13T07:35:14.271660 #1]  INFO -- : Terminating async processes
I, [2020-11-13T07:35:14.271971 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main pid: 50
I, [2020-11-13T07:35:14.272236 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 167
2020-11-13 07:35:14.272 UTC [50] LOG:  received fast shutdown request
167:signal-handler (1605252914) Received SIGTERM scheduling shutdown...
2020-11-13 07:35:14.276 UTC [50] LOG:  aborting any active transactions
2020-11-13 07:35:14.278 UTC [50] LOG:  background worker "logical replication launcher" (PID 59) exited with exit code 1
2020-11-13 07:35:14.283 UTC [54] LOG:  shutting down
2020-11-13 07:35:14.312 UTC [50] LOG:  database system is shut down
167:M 13 Nov 2020 07:35:14.331 # User requested shutdown...
167:M 13 Nov 2020 07:35:14.331 * Saving the final RDB snapshot before exiting.
167:M 13 Nov 2020 07:35:14.369 * DB saved on disk
167:M 13 Nov 2020 07:35:14.370 # Redis is now ready to exit, bye bye...

FAILED
--------------------
Errno::ENOENT: No such file or directory @ rb_sysopen - /usr/local/etc/ImageMagick-6/policy.xml
Location of failure: /pups/lib/pups/replace_command.rb:8:in `read'
replace failed with the params {"filename"=>"/usr/local/etc/ImageMagick-6/policy.xml", "from"=>"<policymap>", "to"=>"<policymap>\n  <policy domain=\"coder\" rights=\"none\" pattern=\"EPHEMERAL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"URL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"HTTPS\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"MVG\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"MSL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"TEXT\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"SHOW\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"WIN\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"PLT\" />\n"}
8a2b7a84ea2ce73e8438d1a8ba1209227b633c0797880d18ca3b5e49d60f1007
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

Can you share your app.yml file here? Don’t forget to redact passwords after pasting the contents.

2 Likes

Thanks your response.

This is app.yml which replaced some words.

# this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.custom.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "768MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  version: stable

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 2

  ## TODO: The domain name this Discourse instance will respond to
  DISCOURSE_HOSTNAME: bbs.tmp_name.jp

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'tmp_name@gmail.com'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
  DISCOURSE_SMTP_PORT: 2525
  DISCOURSE_SMTP_USER_NAME: tmp_name
  DISCOURSE_SMTP_PASSWORD: "*********"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: tmp_name@gmail.com

  ## The CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"
1 Like

Thanks to @jamie.wilson investigation looks like you are on an outdated version of the install script. Try running:

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

This will still fail currently, but because of another stable incompatibility that we are tracking. If you need to update please remove the stable lock, as that is currently broken and not something we test frequently.

3 Likes

This topic was automatically closed after 7 days. New replies are no longer allowed.