Last modified: 2014-09-24 00:12:26 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30512, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28512 - SQLite installation via CLI fails to expand ~paths
SQLite installation via CLI fails to expand ~paths
Status: NEW
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.18.x
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: sqlite
  Show dependency treegraph
 
Reported: 2011-04-12 14:35 UTC by Mark A. Hershberger
Modified: 2014-09-24 00:12 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Mark A. Hershberger 2011-04-12 14:35:25 UTC
Running a cli installation, I got the following error:

 $ php maintenance/install.php --dbtype=sqlite --dbpath=~/work/code/mediawiki/data wiki admin
 ...
 You can install MediaWiki.
 Setting up database
 Cannot create the data directory ~/work/code/mediawiki/data, because the parent
 directory ~/work/code/mediawiki is not writable by the webserver.
 The installer has determined the user your webserver is running as.
 Make the data directory writable by it to continue.
 On a Unix/Linux system do:

 cd ~/work/code/mediawiki
 mkdir data
 chgrp mah data
 chmod g+w data

I followed the above directions, but they didn't help.  Thinking it was a permissions problem of some kind I just erased the data subdirectory, but that didn't work.  Evidently it doesn't expand the ~ properly.  When I wrote out "/home/mah", I got:

 $ php maintenance/install.php --dbtype=sqlite --dbpath=/home/mah/work/code/mediawiki/data wiki admin
 ...
 You can install MediaWiki.
 Setting up database
 Unable to write to the directory "/home/mah/work/code/mediawiki/data".
 Change its permissions so that the webserver can write to it, and try again.

In this case it was unable to write because I had removed the directory.  The previous message implied that it was going to create the directory, but evidently it lied.

When I created the directory and used the full path instead of ~, it worked.
Comment 1 Platonides 2011-04-12 14:47:12 UTC
~ expansion is done by the shell, not by mediawiki.

Whate shell are you using?

Seems that something like 'echo foo=~/foo' expands it, but echo --foo=~/foo does not.

Alternatively, use --dbpath=$HOME/work/code/mediawiki/data which is the POSIX way.
Comment 2 Mark A. Hershberger 2011-04-12 20:41:15 UTC
(In reply to comment #1)
> Whate shell are you using?

Bash.

> Seems that something like 'echo foo=~/foo' expands it, but echo --foo=~/foo
> does not.

I tried realpath("~") but got nothing.  I suggest that a warning is at least given if ~ is the first character of the path.  Also, it should actually try to create the data subdir.
Comment 3 Platonides 2011-04-12 21:02:29 UTC
I didn't mention, using an space is another way to make it happen:
 php maintenance/install.php --dbtype=sqlite --dbpath ~/data wiki admin

The way to add that feature would be:
 if (substr($value, 0, 2) == '~/') { $value = getenv("HOME") . substr($value, 1); }
Comment 4 Mark A. Hershberger 2011-04-13 19:45:53 UTC
note that your suggestion ignores cases of tilde expansion like ~www/ which would expand to the www user's home directory.  You would have to call,  This looks more complex than I initially anticipated:

  if ( substr( $value, 0, 1 ) == '~') {
    $home = getenv("HOME");
    if ( is_string($home) && $value == "~" ) {
      $value = "$home/";
    } else if ( is_string( $home ) && substr( $value, 0, 2 ) == '~/' ) {
      $value = $home . substr($value, 1);
    } else if ( substr( $value, 0, 1 ) == '~' &&
      strlen( $value ) > 2 &&
      function_exists( "posix_getpwnam" ) ) {
      $offset = strpos( $value, "/" );
      if($offset == false ) {
        $offset = strlen($value);
        $value = "$value/";
      }

      $pwent = posix_getpwnam( substr( $value, 1, $offset - 1 ) );
      if( isset( $pwent['dir'] ) ) {
        $value = $pwent['dir'] . substr( $value, $offset );
      }
    }
  }
  if ( substr( $value, 0, 1 ) == '~') {
    die( "Couldn't expand the tilde\n" );
  }
Comment 5 Sumana Harihareswara 2011-11-02 22:14:05 UTC
Decided today in IRC that this is low-priority.

For reference: From IRC discussion today:

Chad Horohoe: Rather than trying to jump through hoops to figure out where the path is, why not just error out when a ~ path is given and say "give a full path please"

Greg Sabino Mullane: That's some hacky code there. Why are we not just disallowing ~ ?

Chad: Exactly. It's easier just to say "don't do that" than anything else.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links