Creating a custom product: define projectname?

I’m following the guide in the docs on how to create a custom product. Like suggested I created a separate folder and used composer to clone the module skeleton into my folder advproduct. Now I noticed that inside the created folders and files, everything is named commerce_projectname where I was expecting commerce_advproduct. Now it’s the first time I’m doing this, so I’m probably wrong here, but did something go wrong or where else has the projectname to be defined? Or do I have to rename every commerce_projectname manually?

This documentation for bootstrapping a module is the best place to start.

There’s overlap in the guides, but this one is a bit more thorough for that first setup.

It is indeed the expectation to get the commerce_advproduct naming automatically. That you don’t, suggests you may not have used composer create-project but cloned the repository directly?

2 Likes

I did use the command and I just retried it again and it seems I missed some errors before:

[...ERROR:cache_util_win.cc(20)] Unable to move the cache: Access denied (0x5)
[...ERROR:cache_util.cc(145)] Unable to move cache folder C:\Users\VibeDesign\AppData\Roaming\Code\Cache\Cache_Data to C:\Users\VibeDesign\AppData\Roaming\Code\Cache\old_Cache_Data_000
[...ERROR:disk_cache.cc(196)] Unable to create cache

It looks like it fails as soon as it gets to the post_create_project.php file as this one also gets opened within VSCode from where I run my terminal.

Also obvious from the above I’m running all this locally on Windows 10 to then push it later to the server as I don’t have proper server access on my webhosting.

I’ve tried to look for a solution the last 2 hours without luck (installed composer only for my user, used composer locally from within the project, changed other windows settings, used powershell…), so if you have any ideas, I’m happy to try them.

Otherwise I don’t suspect this to be a commerce issue, thanks for letting me know that it should work like I expected originally and I will have to figure out a different way… no need to bother with this on your end.

Hi @Vibe_Design, you definitely have permissions-issues on the necessary directories.
Did you encounter the same errors when using PowerShell?

So one idea I have is loosing the permissions on this directory:
[user-home]\AppData\Roaming\Code\Cache\

If you make it 777 it should be writable for everyone/everything. And you should get rid of these errors.

Thanks for reaching out @sebastian-marinescu! PowerShell does output the same errors, unless run in Administrator mode:

[...ERROR:gpu_init.cc(481)] Passthrough is not supported, GL is disabled, ANGLE is      // (note: I did not cut anything after `ANGLE is`)
The following exception is caused by a process timeout

In Process.php line 1204:

  The process "skel\post_create_project.php" exceeded the timeout of 300 seconds.

Like mentioned above the reported post_create_project.php always gets opened in VSCode when I run the create-project command (whether in VSCode terminal or PowerShell), is this supposed to happen or might this be an issue?

@Vibe_Design To be honest, I haven’t used the create-project-command yet, so I don’t know if this is supposed to happen (but I guess not). As you tried it in Admin-Mode, this eliminates the permission-issues… And the shown error seems to be from chrome/electron?! :thinking:

That’s what’s confusing me also. I’m guessing this is due to the opening of VSCode as it’s chromium based or is this not the case?

Also not sure :slight_smile: But it has “Chrome-Debugging”, so probably starts up a headless-chromium for that.
In this case, this would mean the error-message from the gpu_init.cc is irrelevant.

Some questions in the dark:

  • How did you install composer? Through the executable?
  • Do you have PHP installed on your system?
  • Does PHP work from the command-line? (enter php -v for version-info)
  • Did you change the permissions of the before mentioned cache-directory?
  • Try the composer-command with the --verbose parameter: any additional info?
  • If nothing works: do you have a linux-environment, where you could test the same?

Another thought just crossed my mind, although it’s maybe not related -
but as you develop under Windows, it would be good to ensure long paths are never the problem:

1 Like

I installed the exe for all users, tried the exe for just my user, I tried a manual install in the needed project folder and used composer directly via php composer.phar create-project...

Yes, php (7.4) is running and usable through the command line.

I tried but the folder belongs to my local user which already has full access, nothing more to grant.

Unfortunately nothing more. Just in case I’m missing something, here the full log:

Show output
composer create-project modmore/moduleskeleton advproduct --verbose

Creating a "modmore/moduleskeleton" project at "./advproduct"
Installing modmore/moduleskeleton (v1.1.7-pl)
  - Installing modmore/moduleskeleton (v1.1.7-pl): Extracting archive
Created project in [...]\server\advproduct
Loading composer repositories with package information
Updating dependencies
Dependency resolution completed in 0.000 seconds
Analyzed 51 packages to resolve dependencies
Analyzed 51 rules to resolve dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
No installed packages - skipping audit.
> post-create-project-cmd: skel/post_create_project.php

[12888:1020/131107.277:ERROR:cache_util_win.cc(20)] Unable to move the cache: Access denied (0x5)
[12888:1020/131107.277:ERROR:cache_util.cc(145)] Unable to move cache folder C:\Users\VibeDesign\AppData\Roaming\Code\Cache\Cache_Data to C:\Users\VibeDesign\AppData\Roaming\Code\Cache\old_Cache_Data_000
[12888:1020/131107.277:ERROR:disk_cache.cc(196)] Unable to create cache

Not really, I would have to install or boot something up I guess… really annoying, as it seems to be such an easy thing but nothing works.

Thanks for all the suggestions though!

It’s not supposed to open it. Could see what happens if you run out manually, but that will likely have the same outcome.

At this point it may be simplest to just open the file and do the steps it does manually. It’s a nice time saver, but it doesn’t save you that much time to spend another two hours on getting it to run.

I just checked on a different machine (still Windows but without VSCode) and now I get a prompt for which program I would like to open the .php file with. So maybe a Windows issue over all…

So can I assume everything else finished correctly and I can proceed that way?

Interestingly enough, just running it by itself (from within the advproduct folder) seems to work just fine:

php skel/post_create_project.php --verbose

Project name Advproduct taken from directory name
Removing dist files
Refreshing autoloader
Generating autoload files
Generated autoload files
Done!

If I may add a (hopefully) last followup question: Does it matter where I put my advproduct folder? Right now it’s lingering at the root of the site, I would rather see it under core/components/ though, or what would be a good suggested spot?

Huh, that is indeed interesting! Maybe there is something wrong with our composer definition that makes it work on Linux/Mac, but breaks in Windows.

Keeping it out of the MODX directories is the standard way of developing extras for MODX; it makes things a little easier to manage and version when you add a second project to the same installation. When the work is done, you’ll create a transport package (also included in the skeleton) which then installs those directories in the normal places on the site that will use it.

Even if you’re making something that’s specific to one site I’d suggest following that approach just cause it’ll help you keep it in version control, and down the road when you may want to re-use part of it anyway, or even consider a public release. All those things get a lot harder when you mix things in with your MODX installation.

2 Likes

Thank you again for this thorough explanation! I will follow your suggestion then. As I’m developing this locally, can you point me to a resource where I can see which folders and files will be updated later, so I know which things to push to the server again after bootstrapping and all that?

The things in the bootstrap are also in the build script to create a transport package to install on the server. So if you use that, you should be good to go.

(And to track actual file changes, use git. :slight_smile: )