maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
226 stars 24 forks source link

issue calling wikidata-cli from php on webserver #60

Closed HakanIST closed 4 years ago

HakanIST commented 5 years ago

Hello, I'm using wikidata-cli inside a php bot. When I execute the php script from shell it works fine, but when I run in on webserver I get the following error. Any suggestions what may be the problem?

function is

shell_exec('wd sparql ./team.rq -j');

path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1155:7)
    at module.exports (/usr/lib/node_modules/wikidata-cli/lib/get_folder_path.js:24:23)
    at Object. (/usr/lib/node_modules/wikidata-cli/lib/config/file_path.js:2:51)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
maxlath commented 5 years ago

it looks like it can't find a $HOME directory where it could initialize config files; is the $HOME variable set in this environment? If not, a workaround could be to define one before the command: shell_exec('export HOME=/tmp; wd sparql ./team.rq -j');.

You can also now update to v7.0.2 where it tries to recover from this missing environment variable by running without persisting the config