Closed jameswilson closed 6 years ago
I just tested Platform.sh and TMPDIR environment variable is undefined:
$ printenv | grep -i tmp
returned nothing at all.
So we'd need to then come up with a way for each project to copy .env.platformsh
to .env
or remember to add a custom environment variable on every project. This seems cumbersome and will lead to problems down the road.
@balintk I'm fresh out of ideas here about how to make this stupid simple.
Ok, so here is an idea:
1) look for TMPDIR environment variable getenv('TMPDIR')
.
2) if undefined, determine if "/tmp" folder exists and is writable, and if so use that
3) if /tmp doesnt exist or is not writable, send a warning message and exit 1
.
Platform.sh will fail at step 1, but pass at step 2.
Marking this as a blocker because it prevents us from using / testing spark drupal:backup
on platform environment before sending untested or only locally-tested code to the client for testing on their linux environments.
Turns out Robo has its own Task for creating a tmp directory TmpDir, which relies on php sys_get_temp_dir
.
All that needs to be done here is to update the drupal:backup
command to use tmp directory in the paths.
@balintk PR #20 should solve this, would appreciate a review at earliest convenience.
Some of the commands such as the
drupal:backup
command generate output files that are stored temporarily in the webroot or in the repo-root.As we know, the Platform.sh filesystem is read only except for a few exceptions like the tmp folder and any custom mounted folders like the Drupal private folder or the sites/default/files folder.
We need a general solution to store the output files to a writable and accessible directory on any environment and for any kind of project.
I'm not sure if we can make the assumption that
/tmp
is available on every system or not. So probably there needs to be a better way to specify the temporary folder on an environment-speicific basis. Random ideas:php -i | grep -i tmp
which turned up an interesting variable:upload_tmp_dir
but it happened to be unset on my local environment.TMPDIR
environment variable seems like the globally accepted unix/linux pattern. On mac the value is seemingly random:printenv | grep -i tmp
gives:TMPDIR=/var/folders/r3/<randomcharacters>/T/
. Could we depend on this to grab the temporary folder location? if the variable is unset, how should we fallback? One idea is test to see if the env variable exists and is not empty, and if not spit out a warning to define TMPDIR in the.env
file.