Body: <p>I'm upgrading my CiviCRM in stages, because I encountered an error similar to <a href="https://civicrm.stackexchange.com/questions/45962/fatal-error-unconstructed-intldateformatter-after-upgrade-to-php-8-1">this one</a>.  First I started with 5.66.0 to 5.66.2.</p>
  <p>When I get to the DB upgrade stage, I'm hitting a snag.  In the UI, when I hit <code>/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/upgrade&amp;reset=1</code> -&gt; <code>Upgrade Now</code> -&gt; <code>OK</code>, I just see an empty progress bar and the message <code>[Executed: undefined]</code>.</p>
  <p>If I switch to the command-line <code>cv</code> (version <code>v0.3.48</code>), and turn on maximum debugging output, I see this:</p>
  <pre><code>singersin@s483:~/www/wp$ cv upgrade:db -vvv
  
  Box Requirements Checker
  ========================
  
  &gt; Using PHP 8.1.28
  &gt; PHP is using the following php.ini file:
    /home/singersin/www/wp/php.ini
  
  &gt; Checking Box requirements:
    ✔ The application requires a version matching &quot;&gt;=7.3.0&quot;.
    ✔ The application requires the extension &quot;json&quot;.
    ✔ The package &quot;psy/psysh&quot; requires the extension &quot;json&quot;.
    ✔ The package &quot;nikic/php-parser&quot; requires the extension &quot;tokenizer&quot;.
    ✔ The package &quot;psy/psysh&quot; requires the extension &quot;tokenizer&quot;.
    
                                                                                                                                                                                                                        
   [OK] Your system is ready to run the application.                                                                                                                                                                    
                                                                                                                                                                                                                        
  
  [BootTrait:debug] Start
  [BootTrait:debug] Attempting to set verbose error reporting
  [BootTrait:debug] Call standard cv bootstrap
  [Bootstrap:debug] Options: {
      &quot;dynamicSettingsFile&quot;: &quot;phar:///home/singersin/private/bin/cv/lib/settings_location.php&quot;,
      &quot;env&quot;: &quot;CIVICRM_SETTINGS&quot;,
      &quot;prefetch&quot;: true,
      &quot;settingsFile&quot;: null,
      &quot;search&quot;: true,
      &quot;cmsType&quot;: null,
      &quot;httpHost&quot;: &quot;&quot;,
      &quot;output&quot;: {}
  }
  [Bootstrap:debug] Find settings file
  [Bootstrap:debug] Load supplemental configuration for &quot;/home/singersin/www/wp/wp-content/uploads/civicrm/civicrm.settings.php&quot;
  [Bootstrap:notice] Find CMS root for &quot;/home/singersin/www/wp&quot;
  [Bootstrap:notice] Found &quot;wp&quot; in &quot;/home/singersin/www/wp&quot;
  [Bootstrap:notice] Simulate web environment in CLI
  [Bootstrap:debug] Load settings file &quot;/home/singersin/www/wp/wp-content/uploads/civicrm/civicrm.settings.php&quot;
  [Bootstrap:notice] Initialize class loader
  [Bootstrap:notice] Call core bootstrap
  [Bootstrap:debug] Finished
  [BootTrait:debug] Call core bootstrap
  [BootTrait:debug] Call CMS bootstrap
  [BootTrait:debug] Set active MySQL timezone
  [BootTrait:debug] Finished
  [PHP Warning] mkdir(): Permission denied at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:137
  
  In UpgradeDbCommand.php line 138:
                                                                           
    [RuntimeException]                                                     
    Failed to initialize upgrade data folder: /home/singersin/.cv/upgrade  
                                                                           
  
  Exception trace:
    at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:138
   Civi\Cv\Command\UpgradeDbCommand-&gt;getUpgradeFile() at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:47
   Civi\Cv\Command\UpgradeDbCommand-&gt;execute() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Command/Command.php:127
   Cvphar\Symfony\Component\Console\Command\Command-&gt;run() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:637
   Cvphar\Symfony\Component\Console\Application-&gt;doRunCommand() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:190
   Cvphar\Symfony\Component\Console\Application-&gt;doRun() at phar:///home/singersin/private/bin/cv/src/Application.php:67
   Civi\Cv\Application-&gt;doRun() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:101
   Cvphar\Symfony\Component\Console\Application-&gt;run() at phar:///home/singersin/private/bin/cv/src/Application.php:33
   Civi\Cv\Application::main() at phar:///home/singersin/private/bin/cv/bin/cv:28
   require() at /home/singersin/private/bin/cv:14
  </code></pre>
  <p>I'm assuming this is because I don't have permission to create directories in <code>$HOME</code> (the site's hosting provider doesn't allow it):</p>
  <pre><code>$ ls -ld ~
  drwxr-x---+ 15 root singersin 4096 Mar  9  2020 /home/singersin
  </code></pre>
  <p>Can I <strong>run the DB upgrades manually</strong>, or specify a <strong>different temporary directory</strong> for it to perform its work somehow?  Trying <code>HOME=$HOME/private/tmp cv upgrade:db</code> didn't work, it still tried to create <code>.cv/upgrade</code> in the original non-writeable location.</p>
  <p>I'm using CiviCRM with Wordpress 6.5.3 and MySQL 5.7.44.  Thanks.</p>
  <p>########################################</p>
  <p><strong>UPDATE</strong> - apparently <code>HOME</code> is special and can't be overridden:</p>
  <pre><code>$ HOME=foo BAR=baz php -r '$home=getenv(&quot;HOME&quot;); $bar=getenv(&quot;BAR&quot;); echo(&quot;[$home;$bar]\n&quot;);'
  [/home/singersin;baz]
  </code></pre>
  <p>The <code>*.cli</code> PHP binaries seem to have this behavior; <code>*.cgi</code> binaries will let me override <code>HOME</code>, but <code>cv</code> refuses to run from a CGI binary:</p>
  <pre><code>$ HOME=$HOME/private/tmp php81.cgi bin/cv
  Content-type: text/html
  
  
  The application may only be invoked from a command line, got &quot;cgi-fcgi&quot;
  </code></pre>
  <p>I'm still wondering if there's some place I can find the DB update steps and just run them manually.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-30T04:23:29.227Z
Comments.Text: Looking at [cv's code](https://github.com/civicrm/cv/blob/28710d72f9e24150c473c4e6edfe8abefb6e17d8/src/Command/UpgradeDbCommand.php#L187-L195), using HOME should work, just the target folder needs to exist first. Is that the problem?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-30T06:06:30.520Z
Comments.Text: @Demerit I'm not sure why HOME isn't working either, but when I run `HOME=$HOME/private/tmp cv upgrade:db` I still get the error `Failed to initialize upgrade data folder: /home/singersin/.cv/upgrade` as if it's not seeing the set value.  Does `cv` do anything special to not inherit environment variables from the caller?
Comments.UserDisplayName: Ken Williams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-30T06:10:10.073Z
Comments.Text: I'm also not sure why the line number is reported as line `138` when the exception should be thrown around line `195`.  I checked that I have the latest `cv`, maybe it's just wrong about its line numbering in the `.phar` file?
Comments.UserDisplayName: Ken Williams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-30T15:28:42.370Z
Comments.Text: For the line numbers, the phar is compressed/repackaged. If you extract it to a folder you'll see it's the same code. `php -r '$p = new Phar("cv.phar"); $p->extractTo("/path/to/some/folder");'`
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-30T15:32:06.513Z
Comments.Text: If it wasn't recognizing env vars, then the line above it would trigger an error: `if (empty($home)`. Extreme thought: If you do `php -i | grep Thread` is "thread safety" disabled? Although then I would expect $home to be false still.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-31T04:29:11.227Z
Comments.Text: I see `Thread Safety => disabled` in the output of `php -i`.
Comments.UserDisplayName: Ken Williams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-31T04:59:26.947Z
Comments.Text: @Demerit apparently PHP specifically doesn't allow HOME to be overridden, I added some updates at the bottom of the question.
Comments.UserDisplayName: Ken Williams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-29T19:45:09.870Z
Comments.Text: I'm facing the same permission issue on my $HOME because the hosting provider doesn't allow creating directories there. It would be nice if we could pass a parameter like "--tmp" to the `cv upgrade:db` command specifying a writable folder location. Otherwise it seems I can only do the Civi db upgrade manually via the web UI.
Comments.UserDisplayName: Justin657
Tags: <wordpress><upgrade><database><cv>
Title: Upgrade 5.66.0 -> 5.66.2 fails with permission error
ThreadText: # Upgrade 5.66.0 -> 5.66.2 fails with permission error
  
  (Asked by: username_0 on 2024-05-30)
  
  I'm upgrading my CiviCRM in stages, because I encountered an error similar to [this one](https://civicrm.stackexchange.com/questions/45962/fatal-error-unconstructed-intldateformatter-after-upgrade-to-php-8-1). First I started with 5.66.0 to 5.66.2.
  
  When I get to the DB upgrade stage, I'm hitting a snag. In the UI, when I hit `/wp-admin/admin.php?page=CiviCRM&q=civicrm/upgrade&reset=1` -> `Upgrade Now` -> `OK`, I just see an empty progress bar and the message `[Executed: undefined]`.
  
  If I switch to the command-line `cv` (version `v0.3.48`), and turn on maximum debugging output, I see this:
  
  ```
  singersin@s483:~/www/wp$ cv upgrade:db -vvv
  
  Box Requirements Checker
  ========================
  
  > Using PHP 8.1.28
  > PHP is using the following php.ini file:
    /home/singersin/www/wp/php.ini
  
  > Checking Box requirements:
    ✔ The application requires a version matching ">=7.3.0".
    ✔ The application requires the extension "json".
    ✔ The package "psy/psysh" requires the extension "json".
    ✔ The package "nikic/php-parser" requires the extension "tokenizer".
    ✔ The package "psy/psysh" requires the extension "tokenizer".
    
                                                                                                                                                                                                                        
   [OK] Your system is ready to run the application.                                                                                                                                                                    
                                                                                                                                                                                                                        
  
  [BootTrait:debug] Start
  [BootTrait:debug] Attempting to set verbose error reporting
  [BootTrait:debug] Call standard cv bootstrap
  [Bootstrap:debug] Options: {
      "dynamicSettingsFile": "phar:///home/singersin/private/bin/cv/lib/settings_location.php",
      "env": "CIVICRM_SETTINGS",
      "prefetch": true,
      "settingsFile": null,
      "search": true,
      "cmsType": null,
      "httpHost": "",
      "output": {}
  }
  [Bootstrap:debug] Find settings file
  [Bootstrap:debug] Load supplemental configuration for "/home/singersin/www/wp/wp-content/uploads/civicrm/civicrm.settings.php"
  [Bootstrap:notice] Find CMS root for "/home/singersin/www/wp"
  [Bootstrap:notice] Found "wp" in "/home/singersin/www/wp"
  [Bootstrap:notice] Simulate web environment in CLI
  [Bootstrap:debug] Load settings file "/home/singersin/www/wp/wp-content/uploads/civicrm/civicrm.settings.php"
  [Bootstrap:notice] Initialize class loader
  [Bootstrap:notice] Call core bootstrap
  [Bootstrap:debug] Finished
  [BootTrait:debug] Call core bootstrap
  [BootTrait:debug] Call CMS bootstrap
  [BootTrait:debug] Set active MySQL timezone
  [BootTrait:debug] Finished
  [PHP Warning] mkdir(): Permission denied at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:137
  
  In UpgradeDbCommand.php line 138:
                                                                           
    [RuntimeException]                                                     
    Failed to initialize upgrade data folder: /home/singersin/.cv/upgrade  
                                                                           
  
  Exception trace:
    at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:138
   Civi\Cv\Command\UpgradeDbCommand->getUpgradeFile() at phar:///home/singersin/private/bin/cv/src/Command/UpgradeDbCommand.php:47
   Civi\Cv\Command\UpgradeDbCommand->execute() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Command/Command.php:127
   Cvphar\Symfony\Component\Console\Command\Command->run() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:637
   Cvphar\Symfony\Component\Console\Application->doRunCommand() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:190
   Cvphar\Symfony\Component\Console\Application->doRun() at phar:///home/singersin/private/bin/cv/src/Application.php:67
   Civi\Cv\Application->doRun() at phar:///home/singersin/private/bin/cv/vendor/symfony/console/Application.php:101
   Cvphar\Symfony\Component\Console\Application->run() at phar:///home/singersin/private/bin/cv/src/Application.php:33
   Civi\Cv\Application::main() at phar:///home/singersin/private/bin/cv/bin/cv:28
   require() at /home/singersin/private/bin/cv:14
  
  ```
  
  I'm assuming this is because I don't have permission to create directories in `$HOME` (the site's hosting provider doesn't allow it):
  
  ```
  $ ls -ld ~
  drwxr-x---+ 15 root singersin 4096 Mar  9  2020 /home/singersin
  
  ```
  
  Can I **run the DB upgrades manually**, or specify a **different temporary directory** for it to perform its work somehow? Trying `HOME=$HOME/private/tmp cv upgrade:db` didn't work, it still tried to create `.cv/upgrade` in the original non-writeable location.
  
  I'm using CiviCRM with Wordpress 6.5.3 and MySQL 5.7.44. Thanks.
  
  ########################################
  
  **UPDATE** - apparently `HOME` is special and can't be overridden:
  
  ```
  $ HOME=foo BAR=baz php -r '$home=getenv("HOME"); $bar=getenv("BAR"); echo("[$home;$bar]\n");'
  [/home/singersin;baz]
  
  ```
  
  The `*.cli` PHP binaries seem to have this behavior; `*.cgi` binaries will let me override `HOME`, but `cv` refuses to run from a CGI binary:
  
  ```
  $ HOME=$HOME/private/tmp php81.cgi bin/cv
  Content-type: text/html
  
  The application may only be invoked from a command line, got "cgi-fcgi"
  
  ```
  
  I'm still wondering if there's some place I can find the DB update steps and just run them manually.
  
  **Tags:** wordpress, upgrade, database, cv
  
  > **Comments:**
  > **username_1**: Looking at [cv's code](https://github.com/civicrm/cv/blob/28710d72f9e24150c473c4e6edfe8abefb6e17d8/src/Command/UpgradeDbCommand.php#L187-L195), using HOME should work, just the target folder needs to exist first. Is that the problem?  
  > **username_0**: @username_1 I'm not sure why HOME isn't working either, but when I run `HOME=$HOME/private/tmp cv upgrade:db` I still get the error `Failed to initialize upgrade data folder: /home/singersin/.cv/upgrade` as if it's not seeing the set value.  Does `cv` do anything special to not inherit environment variables from the caller?  
  > **username_0**: I'm also not sure why the line number is reported as line `138` when the exception should be thrown around line `195`.  I checked that I have the latest `cv`, maybe it's just wrong about its line numbering in the `.phar` file?  
  > **username_1**: For the line numbers, the phar is compressed/repackaged. If you extract it to a folder you'll see it's the same code. `php -r '$p = new Phar("cv.phar"); $p->extractTo("/path/to/some/folder");'`  
  > **username_1**: If it wasn't recognizing env vars, then the line above it would trigger an error: `if (empty($home)`. Extreme thought: If you do `php -i | grep Thread` is "thread safety" disabled? Although then I would expect $home to be false still.  
  > **username_0**: I see `Thread Safety => disabled` in the output of `php -i`.  
  > **username_0**: @username_1 apparently PHP specifically doesn't allow HOME to be overridden, I added some updates at the bottom of the question.  
  > **username_2**: I'm facing the same permission issue on my $HOME because the hosting provider doesn't allow creating directories there. It would be nice if we could pass a parameter like "--tmp" to the `cv upgrade:db` command specifying a writable folder location. Otherwise it seems I can only do the Civi db upgrade manually via the web UI.  
  
  ---
  
  ## 0 answers
  
  