Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddev import-files removes settings.php and settings.ddev.php #5474

Closed
1 task done
rebelmusic opened this issue Oct 30, 2023 · 12 comments
Closed
1 task done

ddev import-files removes settings.php and settings.ddev.php #5474

rebelmusic opened this issue Oct 30, 2023 · 12 comments

Comments

@rebelmusic
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Output of ddev debug test

No response

Expected Behavior

settings.php and settings.ddev.php should remain as is.

Actual Behavior

settings.php settings.ddev.php are deleted

Steps To Reproduce

  1. add settings.php to web/sites/default
  2. start a new Drupal project with ddev start
  3. run ddev import-files --source=.tarballs/files.tgz

Anything else?

No response

@rfay
Copy link
Member

rfay commented Oct 30, 2023

We always want to hear about problems, so thanks for filing this issue.

I just attempted to recreate this with a drupal10 site and wasn't able to. Is it possible that it had to do with the content of your files.tgz file? Please take a look at that. It could also be that your project wasn't of type drupal*, or that you had upload_dirs set to something "interesting" that wasn't correct?

You didn't provide the requested output of ddev debug test so I don't have any answers to these questions, but maybe you can come back and add that to the issue, or out the output in a gist on gist.github.com or some other pastebin.

But before that, please make sure you can recreate this behavior.

It would be nice if you'd do a trivial plain-vanilla drupal10 project and demonstrate it with that. You can create one with the instructions at https://ddev.readthedocs.io/en/latest/users/quickstart/#drupal

If you'd like a sample files.tgz to work with, there's a d10 version of a set of files at https://github.com/ddev/d10simple-artifacts

@rebelmusic
Copy link
Author

Sorry I should have pasted the output. Please see here

The files.tgz just contains user uploaded images (it's pretty big though...like 20GB).

I have reproduced the issue consistently.

This is for a D9 site.

I'll try to reproduce the problem on a D10 and get back to you.

@rebelmusic
Copy link
Author

upload_dirs was left commented out in config.yaml...so just using the defaults for mostly everything.

@rfay
Copy link
Member

rfay commented Oct 30, 2023

I just repeated my test on a plain-vanilla drupal9 site and certainly didn't see this behavior. Please make sure you can provide a recreatable scenario. Maybe you can push up a repo to GitHub that demonstrates it? Maybe you can PM me the files.tgz (but look inside first).

(I should note that DDEV manages the settings.ddev.php, and it will be recreated on every ddev start unless the #ddev-generated has been removed from it.)

@rebelmusic
Copy link
Author

I've narrowed it down a bit.

When I do ddev import-files --source=.tarballs/files.tgz --target=sites/default I can consistently reproduce the problem.

When I go ddev import-files --source=.tarballs/files.tgz it works as it should.

I'll send you a PM to see how best I can demonstrate it to you without sending across confidential info. Thanks for taking a look into it btw.

@rfay
Copy link
Member

rfay commented Oct 30, 2023

Yes, if you use --target=sites/default it puts your files into sites/default, overwriting what was there, which was your settings.php.

@rfay rfay closed this as completed Oct 30, 2023
@rfay
Copy link
Member

rfay commented Oct 30, 2023

Please don't use the --target if you don't know what it's for.

@rfay
Copy link
Member

rfay commented Oct 30, 2023

I would love to have you explain why you were using --target though, and what made you think that pointing it at sites/default was a good idea. Is there something in the docs or ddev help import-files that led you down this path?

@rebelmusic
Copy link
Author

Well at first, when I just tried ddev import-files --source=.tarballs/files.tgz it would place the files in web/sites/default/files/files. So when I added the --target flag, it solved that problem. But then it brought about a new problem which took me quite a while to realise (the deleting of the settings.php).

Nowhere in the docs mentioned that adding the --target flag blows away everything in that directory. (probably worth adding a little note in the docs)

I got around the issue finally by created a custom command like so:

## Description: Copy files to container
## Usage: files
## Example: ddev files

mkdir -p web/sites/default/files
tar -zxf .tarballs/files.tgz -C web/sites/default

Then I can just run ddev files.

@rfay
Copy link
Member

rfay commented Oct 30, 2023

I see, your tarball was based at the wrong level (it included the files directory, instead of starting inside the files directory. So that led you down the path of trying to fix that problem. I think https://ddev.readthedocs.io/en/latest/users/usage/cli/#ddev-import-files could be improved to add some information about how to create the tarball.

You can still just create the tarball correctly. And note that ddev import-files doesn't do anything particularly magical. It just untars a tarball into your files directory. So what you've done is fine... except that now it only works with the particular type of tarball you've created (that includes the top-level directory).

@rfay
Copy link
Member

rfay commented Oct 30, 2023

Please take a look at

and see if it would help you.

Note that ddev help import-files already had the statement

If the
destination directory exists, it will be replaced with the assets being
imported.

@rebelmusic
Copy link
Author

Thanks! I added a couple comments to the PR. It's up to you to include it.

rfay added a commit to rfay/ddev that referenced this issue Nov 2, 2023
rfay added a commit to rfay/ddev that referenced this issue Nov 22, 2023
rfay added a commit that referenced this issue Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants