Problem/Motivation

None.

Steps to reproduce

As administrator i try a create a subtheme.

After clicking 'create' i get error

'The website encountered an unexpected error. Please try again later.'

There are two error messages in the logs:

1)

Drupal\Core\File\Exception\DirectoryNotReadyException: The specified file 'themes/contrib/bootstrap5/css/style.css.map' could not be copied because the destination directory '/var/www/vhosts/phano.de/httpdocs/drupal/web/themes/custom/b5subtheme/css' is not properly configured. This may be caused by a problem with file or directory permissions. in Drupal\Core\File\FileSystem->prepareDestination() (line 476 of /var/www/vhosts/xxxxxxxxx.com/httpdocs/drupal/web/core/lib/Drupal/Core/File/FileSystem.php).

2)

The specified file 'themes/contrib/bootstrap5/css/style.css.map' could not be copied because the destination directory '/var/www/vhosts/xxxxxxxxx.com/httpdocs/drupal/web/themes/custom/b5subtheme/css' is not properly configured. This may be caused by a problem with file or directory permissions.

Proposed resolution

None.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

upk created an issue. See original summary.

vladimiraus’s picture

Status: Active » Needs work

Thanks for the report.
I can add extra checks when creating the direcotries but it seems like youe system permissions are the issue.

collin howell’s picture

I had a similar error trying to create a subtheme with 1.0.0-beta5. - The website encountered an unexpected error. Please try again later.
Subtheme name
Belwest B5 subtheme
Subtheme machine name
belwest_b5_subtheme

Error Log reports
Location http://localhost/admin/appearance/settings/bootstrap5

Referrer http://localhost/admin/appearance/settings/bootstrap5

Message Drupal\Core\File\Exception\FileNotExistsException: File 'themes/contrib/bootstrap5\style-guide\bootstrap.rtl.min.css' could not be copied because it does not exist. in Drupal\Core\File\FileSystem->prepareDestination() (line 472 of B:\Dev\publichtml\core\lib\Drupal\Core\File\FileSystem.php).

The Directory Structure created
B:\Dev\publichtml\themes\custom\belwest_b5_subtheme>dir /s
Directory of B:\Dev\publichtml\themes\custom\belwest_b5_subtheme
05/07/2021 04:38 PM css
05/07/2021 04:38 PM style-guide
0 File(s) 0 bytes
Directory of B:\Dev\publichtml\themes\custom\belwest_b5_subtheme\css
05/07/2021 04:38 PM 204,359 style.css
05/07/2021 04:38 PM 52,938 style.css.map
2 File(s) 257,297 bytes
Directory of B:\Dev\publichtml\themes\custom\belwest_b5_subtheme\style-guide
0 File(s) 0 bytes
Total Files Listed:
2 File(s) 257,297 bytes
8 Dir(s) 20,302,741,504 bytes free

Hope this helps.

panditvarun20’s picture

Dear Team,

I am also facing the same issue. I have checked the permission of folder

recent log:
1- Drupal\Core\File\Exception\FileNotExistsException: File 'themes/contrib/bootstrap5\style-guide\bootstrap.rtl.min.css' could not be copied because it does not exist. in Drupal\Core\File\FileSystem->prepareDestination() (line 459 of C:\xampp\htdocs\drupal9c\web\core\lib\Drupal\Core\File\FileSystem.php).

2- File 'themes/contrib/bootstrap5\style-guide\bootstrap.rtl.min.css' could not be copied because it does not exist.

ben25’s picture

I'm also experiencing issues when creating sub theme
for e.g. File 'themes/contrib/bootstrap5/style-guide/bootstrap.rtl.min.css' could not be copied.....

Mark.Devon’s picture

Similar problem:
Drupal\Core\File\Exception\FileNotExistsException: File 'themes/contrib/bootstrap5\style-guide\bootstrap.rtl.min.css' could not be copied because it does not exist. in Drupal\Core\File\FileSystem->prepareDestination()
Created subtheme manually.

kroh’s picture

This original issue indeed looks like a permission problem, but the other comments here are related to 3223704: php error when trying to create subtheme from UI

afeijo’s picture

That file is present in a subfolder, you can fix the problem and run the copy button by copying the file first, run this:

cp themes/contrib/bootstrap5/style-guide/bootstrap.rtl.min.css themes/contrib/bootstrap5/style-guide/index-rtl_files

Ralf Eisler’s picture

#7 worked for me.

  • VladimirAus committed af6b9de on 1.0.x
    Issue #3219767 by upk, panditvarun20, Collin Howell, VladimirAus, afeijo...

VladimirAus credited gisle.

vladimiraus’s picture

Ready to test in dev.

vladimiraus’s picture

Status: Needs work » Needs review
gisle’s picture

Version: 1.0.0-beta3 » 1.0.x-dev
Status: Needs review » Reviewed & tested by the community

The latest 1.0.x-dev snapshot solves both the permission issue (i.e. it provides a sensible error message if the site builder has not configured the right permissions for the web server), and the file copying issue (see #3223704: php error when trying to create subtheme from UI).

Creating a subtheme now works. Clicking "Create" results in a subtheme being created that is populated with all the right files.

vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nigelwhite’s picture

On clicking 'Create' for the subtheme in GUI I'm still getting the error 'Subtheme cannot be created. Check permissions.'

Steps I took -
composer require 'drupal/bootstrap5:1.0.x-dev@dev'
Enabled Bootstrap 5
Ran permissions.sh which is available to our site
Create subtheme in GUI

gisle’s picture

Ran permissions.sh which is available to our site.

Does it do the right thing? (Since it is only exists on your site, we have no way to know.)

The error message you cite indicates that it doesn't.

Since the subtheme is created by the web server user, the directory where you want to create the subtheme (default: /themes/custom/ below the webroot) must be writeable by the web server account. If it isn't, you get this error.

vladimiraus’s picture

If you cannot write to themes/custom try to write to web/sites/default/files or whereever your public files folder is.

nigelwhite’s picture

That did it, thanks for the steer to specific directories

Cd /web/themes
Mkdir custom. This produced - custom 0755 root root
chown root:www-data custom
Subtheme cannot be created. Check permissions.
chmod 0777 custom
Subtheme created at /var/src/drupal/site/web/themes/custom/b5subtheme

Maybe the web server account had been unable to create the 'custom' directory? The 'themes' directory was at 0750 root www-data.

2flower’s picture

Is there solution for version 1.1.1?

It does not have 'style-guide' directory and creating theme in public directory does not work either.

szymmszy’s picture

I have the same problems as 2flower with version 1.1.2.

Rafael Cansinos’s picture

drupal 9.3.2 fresh install with composer
composer require 'drupal/bootstrap5:1.1.x-dev@dev'

SUBTHEME create

ERROR: Subtheme cannot be created. Check permissions.

directory themes (drwxrwxr-x) change a chmod 777 themes

ERROR: Subtheme cannot be created. Check permissions.

mkdir custom

chmod 777 custom

SUBTHEME create

ERROR: The website encountered an unexpected error. Please try again later.

Rafael Cansinos’s picture

I think this problem is due to security measures on the server where Drupal runs. In order not to touch anything in the server, what I have done:

  1. Install a Xampp in Windows (or Mac or Linux).
  2. Install Drupal & Bootstrap 5
  3. I have created the sub-theme with the proper name, etc.
  4. Upload the new folder to the production server to themes/contrib
  5. Change owner: chown -Rf myuser:myuser subthemename
  6. Activate subtheme in Drupal: /admin/appearance

It works perfectly.

rmcf’s picture

I have the same issues with Drupal 9 and Bootstrap 5 on shared hosting:
"ERROR: Subtheme cannot be created. Check permissions." and "ERROR: The website encountered an unexpected error. Please try again later."

Is there any instruction how to create this subtheme manually like in Bootstrap 3? I will highly appreciate help with this – because it is a blocker for me to use Boostrap 5 theme :(

bloomt’s picture

Fresh D9 install I get this error. Set custom folder to 777.

AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\File\\Exception\\DirectoryNotReadyException: "The specified file 'themes/contrib/bootstrap5/css/style-50.css' could not be copied because the destination directory '/var/www/vhosts/website/web/themes/custom/b5subtheme/css' is not properly configured. This may be caused by a problem with file or directory permissions." at /var/www/vhosts/website/web/core/lib/Drupal/Core/File/FileSystem.php line 476', referer: https://website/admin/appearance/settings/bootstrap5

Is there a fix for this or a way to manually create the subtheme?

gisle’s picture

bloomt, do you have SELinux (Security-Enhanced Linux) enabled?

It is mostly used on RHEL and CentOS (and orther Red Hat derived flavours of Gnu/Linux), but I think he can be enabled on other platforms as well.

bloomt’s picture

SELinux is enabled, I temporarily disabled but the issue was the same.

drupgirl’s picture

+1 for instructions on how to manually create a subtheme for this module.

gisle’s picture

Just for the record, the built-in "Create" command works fine (I just tested it) provided you're able to set the permissions correctly so that the web server are allowed to copy and edit all required files. If you're desperate, go with 777 and make sure SELinux is disabled.

A newly created subtheme looks like the tree shown below, where the files (except b5subtheme.info.yml – see below) are first copied from Bootstrap5 (so b5subtheme.breakpoints.yml are copied from bootstrap5.breakpoints.yml). After the files has been copied and renamed, all ocurrences of "boostrap5" is changed to "b5subtheme" (e.g. "bootstrap5.screen.xs-max:" becomes "b5subtheme.screen.xs-max:").

You should have this tree:

b5subtheme/
├── b5subtheme.breakpoints.yml
├── b5subtheme.info.yml
├── b5subtheme.libraries.yml
├── b5subtheme.theme
├── config
│   └── optional
│       ├── block.block.b5subtheme_account_menu.yml
│       ├── block.block.b5subtheme_branding.yml
│       ├── block.block.b5subtheme_breadcrumbs.yml
│       ├── block.block.b5subtheme_content.yml
│       ├── block.block.b5subtheme_footer.yml
│       ├── block.block.b5subtheme_help.yml
│       ├── block.block.b5subtheme_local_actions.yml
│       ├── block.block.b5subtheme_local_tasks.yml
│       ├── block.block.b5subtheme_main_navigation.yml
│       ├── block.block.b5subtheme_messages.yml
│       ├── block.block.b5subtheme_page_title.yml
│       ├── block.block.b5subtheme_powered_by_drupal.yml
│       └── block.block.b5subtheme_search_form.yml
├── css
│   ├── style-50.css
│   ├── style-50.css.map
│   ├── style.css
│   └── style.css.map
├── favicon.ico
├── logo.svg
├── README.md
├── screenshot.png
└── scss
    ├── style.scss
    ├── _variables_bootstrap.scss
    └── _variables_drupal.scss

This is the content of the subtheme's b5subtheme.info.yml:

name: 'B5 subtheme'
type: theme
description: 'B5 subtheme subtheme based on Bootstrap 5 theme.'
core_version_requirement: '^8.9 || ^9'
'base theme': bootstrap5
libraries:
  - b5subtheme/global-styling
stylesheets-remove:
  - '@bootstrap5/css/style.css'
regions:
  header: Header
  nav_branding: 'Navigation branding region'
  nav_main: 'Main navigation region'
  nav_additional: 'Additional navigation region (e.g.: search form, etc)'
  breadcrumb: Breadcrumbs
  content: 'Main content'
  sidebar_first: 'Sidebar first'
  sidebar_second: 'Sidebar second'
  footer: Footer
slawomir’s picture

We've a server running Plesk. with its psacln and psaserv groups for public webfiles. The sub-theme creator is coming back with "wrong permissions." I tried a few things around file permissions including 777 and using the OS' group / owner for the theme paths. No luck.

Now working on recreating the file structure given by @Gisle in #31. If I don't post a repo of the final in a few days, someone give me a nudge. ;)

dtamajon’s picture

In my case, it is related to #2799635

bcobin’s picture

I've tried all of the above on a fresh D9 install and nothing happens. I get a success message, but nothing is created - no error message in the UI nor in the logs. I tried to manually create the subtheme - no dice.

Thanks in advance for any guidance here...

UPDATE: I am a (fill in expletive here). Rather than clicking "Create," I was clicking on the Save button. Duh.

So the creation works great... but the subtheme doesn't work. It's as if there's no theme at all.

No errors - could I be missing something? Thanks in advance for any suggestions...

FURTHER UPDATE: After updating core and fixing a problem with a "missing" module, all seems to be working as advertised... thanks!

calbasi’s picture

In my case, the issue is due opendir restrictions. If disabled it in my web account (ispconfig) and then I have not issue at all.

Videtes’s picture

I'm still getting the "Subtheme cannot be created. Check permissions." error despite having allowed everything for the /themes directory and the root it is located into.

Even adding permission to the normal /bootstrap5 theme directory (which makes no sense, but I tried because you never know) yelded no result.

I have no idea what other permissions I should change.

dtamajon’s picture

@Videtes, try with the following patch: https://www.drupal.org/project/drupal/issues/2799635

We are using nginx and we had the same problem, given the way in which the core manages the file creation. With that patch, the problem is solved without the need to provide unsecure permissions to the filesystem.

Videtes’s picture

@dtamajon, that patch worked for me, thanks a lot!

montogro’s picture

Still got permission issues with creating B5 subtheme, tried on nginx and local repositories, no result for me