# Bug OP-13232 - `packager:postinstall` task fails, if `OPENPROJECT_HOST__NAME` is set in environment

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-13232

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 13.0.2 |
| Observed in versions |  |
| Sprint | 13.0.2 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Install OpenProject (packaged version)
2.  Set `OPENPROJECT_HOST__NAME` in the environment configuration in `/etc/openproject/conf.d`

<!-- end list -->

``` sh
export OPENPROJECT_HOST__NAME="my.project.server.org"
```

1.  Run `openproject run rake packager:postinstall`

### What is the buggy behavior?

The `rake` Task trys to update the hostname configuration in the database, but fails, because the environment variable has precedence over the database setting and thus the setting is read-only.

``` text
# openproject run rake packager:postinstall
rake aborted!
NoMethodError: host_name is not writable but can be set through env vars or configuration.yml file.
/opt/openproject/app/models/setting.rb:175:in `set_value!'
/opt/openproject/app/models/setting.rb:170:in `value='
/opt/openproject/app/models/setting.rb:199:in `[]='
/opt/openproject/app/models/setting.rb:136:in `host_name='
/opt/openproject/lib/tasks/packager.rake:66:in `block (2 levels) in <top (required)>'
/opt/openproject/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/openproject/bin/bundle:110:in `load'
/opt/openproject/bin/bundle:110:in `<main>'
Tasks: TOP => packager:postinstall
(See full trace by running task with --trace)
```

### What is the expected behavior?

The setting is not attempted to be written to the database if it is already present in the environment variable.

### **Logs**

N/A

### Screenshots and other files

N/A

### Environment information

**OpenProject installation type**

- [ ] Hosted cloud edition
- [x] Packaged installation
    - Debian 12
- [ ] Docker All-in-one container
- [ ] Docker-compose installation
- [ ] Other (please specify)

**OpenProject version**

OpenProject Enterprise Edition v13.0.1

**Browser**

N/A

**Language**

N/A

### Additional context

We are about to upgrade from OpenProject 12 to 13 and in this step to migrate the settings of `configuration.yml` to environment variables where we encountered the reported issue. Out server management system places all of the configuration under `/etc/openproject/conf.d` so we don't need to run the interactive installer. After write the configuration files the following command is executed:

``` text
# openproject run rake packager:before_postinstall db:migrate db:seed packager:postinstall
```

It fails in the last step. The above reported steps to reproduce are condensed to the essential steps. The issue also occurs with the interactive installer.
