Installation errors

Hello!
The following problem occurred during installation:
================================================================================ Error executing action run` on resource ‘execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]’
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.

The database cluster will be initialized with locale "en_US".
STDERR: initdb: encoding mismatch
The encoding you selected (UTF8) and the encoding that the
selected locale uses (LATIN1) do not match.  This would lead to
misbehavior in various character string processing functions.
Rerun initdb and either do not specify an encoding explicitly,
or choose a matching combination.
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1

Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/enable.rb

 75: execute "/opt/gitlab/embedded/bin/initdb -D #{node['postgresql']['data_dir']} -E UTF8" do
 76:   user postgresql_username
 77:   not_if { pg_helper.bootstrapped? || pg_helper.delegated? }
 78: end
 79: 

Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/enable.rb:75:in `from_file'

execute("/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8") do
  action [:run]
  default_guard_interpreter :execute
  command "/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8"
  backup 5
  declared_type :execute
  cookbook_name "postgresql"
  recipe_name "enable"
  domain nil
  user "gitlab-psql"
  not_if { #code block }
end

System Info:
------------
chef_version=15.12.22
platform=ubuntu
platform_version=18.04
ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client

Running handlers:
There was an error running gitlab-ctl reconfigure:

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 75) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received ‘1’
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user “gitlab-psql”.
This user must also own the server process.

The database cluster will be initialized with locale “en_US”.
STDERR: initdb: encoding mismatch
The encoding you selected (UTF8) and the encoding that the
selected locale uses (LATIN1) do not match. This would lead to
misbehavior in various character string processing functions.
Rerun initdb and either do not specify an encoding explicitly,
or choose a matching combination.
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1

Warnings:
Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.

Running handlers complete
Chef Infra Client failed. 4 resources updated in 23 seconds

Warnings:
Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.

dpkg: error processing package gitlab-ee (–configure):
installed gitlab-ee package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
gitlab-ee
E: Sub-process /usr/bin/dpkg returned an error code (1)
`

How to solve it?

Based on some of the errors above:

The database cluster will be initialized with locale “en_US”.
STDERR: initdb: encoding mismatch
The encoding you selected (UTF8) and the encoding that the
selected locale uses (LATIN1) do not match

Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.

I expect your Debian/Ubuntu installation isn’t using a UTF-8 locale. You can change this by running:

dpkg-reconfigure locales

first choose the appropriate .UTF-8 locales to generate, and then on the next screen set the default locale for the system to be one of those generated .UTF8 locales, eg: en_US.UTF-8 is what I have configured on my gitlab-ce system with Debian/Ubuntu and works fine.

Hello.
I did what you said, but the error continues.

Error

Lang settings:

There are two potential issues here.

  1. After running dpkg-reconfigure you’ll need to close the console window/ssh session and re-open/connect to the server so that the environment settings refresh. Also ensure from the second screen of dpkg-reconfigure locales, that you have similar to my attached screenshot.

  2. You have a partial installation of gitlab-ee, which is partially configured for the old settings.

Better would be now:

apt-get purge gitlab-ee

to cleanup the system, and reinstall gitlab with:

apt-get install gitlab-ee

that way it can configure the database from scratch with the correct encoding. You can check the console settings as follows:

export | grep LC

and also:

export | grep LANG

root@repo:~# export | grep LANG
declare -x LANG=“en_US.UTF-8”

Well, The bug has been resolved! But another appeared.

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received ‘1’
---- Begin output of “bash” “/tmp/chef-script20200917-30486-1a8i1m8” ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/opt/gitlab/postgresql/.s.PGSQL.5432”?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:53:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
/opt/gitlab/embedded/bin/bundle:23:in `’
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR:
---- End output of “bash” “/tmp/chef-script20200917-30486-1a8i1m8” ----
Ran “bash” “/tmp/chef-script20200917-30486-1a8i1m8” returned 1

Running handlers complete
Chef Infra Client failed. 6 resources updated in 02 minutes 00 seconds
dpkg: error processing package gitlab-ee (–configure):
installed gitlab-ee package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
gitlab-ee
E: Sub-process /usr/bin/dpkg returned an error code (1)

I expect it’s because it’s still partially installed. Did you try the purge command?

this will remove it, so that you won’t have a half-failed install. Then you can just apt-get install gitlab-ee again.

If you are still getting the error after a purge, I guess it means some directories were left behind on your system with a messed up config. In that case, purge the package, and then delete the following directories to ensure a clean installation:

/etc/gitlab/
/opt/gitlab
/var/opt/gitlab