Skip to content

Warning: file_exists(): open_basedir restriction in effect. File(/tmp/Google_Client/xx/xxx...) is not within the allowed path(s) #713

Closed

Description

@MassimoPiccioni

I'm developing a web application in php and i downloaded the API from here and followed the guides but when i try to run it it gave me this error:

Warning: file_exists(): open_basedir restriction in effect. File(/tmp/Google_Client/9d/9dac732490e227eb6b11f1cbf0e36d47) is not within the allowed path(s): (/www) in /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php on line 52 Warning: is_dir(): open_basedir restriction in effect. File(/tmp/Google_Client/9d) is not within the allowed path(s): (/www) in /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php on line 148 Warning: mkdir(): open_basedir restriction in effect. File(/tmp/Google_Client) is not within the allowed path(s): (/www) in /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php on line 149 Fatal error: Uncaught exception 'Google_Cache_Exception' with message 'Could not create storage directory: /tmp/Google_Client/9d' in /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php:154 Stack trace: #0 /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php(139): Google_Cache_File->getCacheDir('ba077eabce470c1...', true) #1 /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php(134): Google_Cache_File->getCacheFile('ba077eabce470c1...', true) #2 /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php(95): Google_Cache_File->getWriteableCacheFile('ba077eabce470c1...') #3 /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Auth/OAuth2.php(322): Google_Cache_File->set('ba077eabce470c1...', '{"access_token"...') #4 /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/index in /www/MW_qPRcycRIG/massimopiccioni.it/Test/AnalyticsAPITest/google-api-php-client/src/Google/Cache/File.php on line 154

Can anyone help me?

http://www.massimopiccioni.it/Test/AnalyticsAPITest/

Activity

  1. bshaffer commented on Oct 27, 2015

    @bshaffer
    Contributor

    The 7th parameter to Google_Auth_AssertionCredentials is $useCache. This defaults to true. Try setting it to false, and the library will stop writing to a file.

    I imagine this is because you're running in a shared hosting environment, and the php.ini setting open_basedir is set, and the cache file is attempting to write outside the allowed path. If you have access, you could also just disable open_basedir in your php.ini so that it is not in effect.

  2. DManstrator commented on Feb 16, 2018

    @DManstrator

    I got (nearly) the same problem.
    Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/tmp/Google_Client/19/19431c28c9844f253b7493fd88125111) is not within the allowed path(s): (/users/dmanstrator/www:/users/_temp/dmanstrator) in /users/dmanstrator/www/vendor/google/apiclient/src/Google/Cache/File.php on line 45

    I went into the AssertionCredentials.php and changed the $useCache variable to be false as default ( $this->useCache = false;) but it doesn't change a thing.
    I can't access my php.ini because I get hosted by bplaced.net, any tips for me?

    Thanks in advance.

    Edit: After looking around, I found a way.

    $client = new Google_Client();
    $client->setClassConfig('Google_Cache_File', array('directory' => '/users/_temp/dmanstrator'));

    Just set the value of "directory" to one of the allowed paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions