wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

PHP Warning: mkdir(): Read-only file system in MakePotCommand.php on line 376 #369

Closed berkbirkan closed 9 months ago

berkbirkan commented 9 months ago

hello,

When I wanted to create a pot file with the following command, I got the following error:

wp i18n make-pot . /languages/ai-comment-creator.pot --slug=ai-comment-creator

Plugin file detected. PHP Warning: mkdir(): Read-only file system in phar:///opt/homebrew/Cellar/wp-cli/2.8.1/bin/wp/vendor/wp-cli/i18n-command/src/MakePotCommand.php on line 376

Warning: mkdir(): Read-only file system in phar:///opt/homebrew/Cellar/wp-cli/2.8.1/bin/wp/vendor/wp-cli/i18n-command/src/MakePotCommand.php on line 376 Error: Could not create destination directory!

I am 100% sure that I have given the necessary chmod permissions. but I still get the same error. what should I do ? I would be glad if you could help me, thank you.

swissspidy commented 9 months ago

Hi there, as per our guidelines on how to write clear bug reports, could you please share the output of wp cli info?

Also, what's the output if you run the command with the --debug flag? e.g. wp i18n make-pot . /languages/ai-comment-creator.pot --slug=ai-comment-creator --debug

That line in the code tries to create the languages directory with 0777 permissions if it doesn't exist yet. (though not sure why explicitly 777)

You can try manually creating that directory, either with simple mkdir languages or mkdir -m 0777 languages. If that fails, you do have some chmod permission issues. If not, then wp i18n make-pot should succeed.


Aside: curious, is this your plugin? https://wordpress.org/plugins/ai-comment-creator/ If so, there shouldn't be a need to use this command, as WordPress.org handles all the translation stuff for you. So curious about your use case.

swissspidy commented 9 months ago

Update

Actually, I just re-read your command and the issue is the location of your destination directory.

wp i18n make-pot . /languages/ai-comment-creator.pot

That means you are pointing at the languages folder in the root directory. The root is no longer writable in macOS.

You'll need to use a relative path, e.g. wp i18n make-pot . ./languages/ai-comment-creator.pot.

That said, you can actually simply omit the destination, as ./languages/ai-comment-creator.pot is the default location determined by the command. So simply running wp i18n make-pot . should work just fine.

berkbirkan commented 9 months ago

Hi there, as per our guidelines on how to write clear bug reports, could you please share the output of wp cli info?

Also, what's the output if you run the command with the --debug flag? e.g. wp i18n make-pot . /languages/ai-comment-creator.pot --slug=ai-comment-creator --debug

That line in the code tries to create the languages directory with 0777 permissions if it doesn't exist yet. (though not sure why explicitly 777)

You can try manually creating that directory, either with simple mkdir languages or mkdir -m 0777 languages. If that fails, you do have some chmod permission issues. If not, then wp i18n make-pot should succeed.

Aside: curious, is this your plugin? https://wordpress.org/plugins/ai-comment-creator/ If so, there shouldn't be a need to use this command, as WordPress.org handles all the translation stuff for you. So curious about your use case.

Hello,

Yes, that plugin is mine. I noticed that wordpress.org has a translate feature. but this felt extremely slow and cumbersome. Maybe there is a practical way that I don't know about.

swissspidy commented 9 months ago

All plugins hosted on WordPress.org will get the community-provided translations from translate.wordpress.org. There is no need to provide your own. And if you do, the ones from dotorg will take precedence if they exist.

berkbirkan commented 9 months ago

My plugin is very small, so I don't have a community to get translation help from. I want to translate it myself on wordpress.org, but it gets stuck waiting. I think I need to confirm it myself, but I couldn't figure out how to do it.

swissspidy commented 9 months ago

You‘ll need to ask someone from the translation team for that language to approve the translations. You can also become a translation editor for your own plugin and language as well by posting on make.wordpress.org/polyglots. I recommend reading their handbook