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

Permissions issues? Missing folders? #12

Open
Saeven opened this issue Nov 6, 2013 · 54 comments
Open

Permissions issues? Missing folders? #12

Saeven opened this issue Nov 6, 2013 · 54 comments
Assignees

Comments

@Saeven
Copy link
Contributor

Saeven commented Nov 6, 2013

Any of you developers using this on OSX? I'm running into an issue where the call to your library:

<project>/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/lw/0f57k9dj617_ntr760qw2lcr0000fgp/T/poedit1nmsrR/3extracted.pot" --from-code=UTF-8  -k_ -ktranslate -ksetLabel -ksetValue -ksetLegend -k_refresh -L PHP --files  "vendor/mylibrary/core/view/ldp/forgot/email.twig" "vendor/mylibrary/core/view/ldp/forgot/index.twig" "vendor/mylibrary/core/view/ldp/login/index.twig" "vendor/mylibrary/core/view/ldp/main/index.twig" "vendor/mylibrary/core/view/ldp/register/index.twig"

Fails with this error message:

Fatal error: Uncaught exception 'RuntimeException' with message 'Gettext command "xgettext --sort-output --force-po -o /var/folders/lw/0f57k9dj617_ntr760qw2lcr0000fgp/T/poedit1nmsrR/3extracted.pot --from-code=UTF-8 -k_ -ktranslate -ksetLabel -ksetValue -ksetLegend -k_refresh -L PHP /tmp/cache/5279bc643f96f/8c/e1/c60ddc5ef854138efa25631b4b6d.php /tmp/cache/5279bc643f96f/d3/37/bf84f1be48ed8fd950ff618fba22.php /tmp/cache/5279bc643f96f/a7/e7/56cec92524ceab7ab465d688f936.php /tmp/cache/5279bc643f96f/73/df/2a5e4848ca69cb43dc05818ce5b0.php /tmp/cache/5279bc643f96f/82/0b/167d3083d340e123ea9742944113.php" failed with error code 1 and output: ' in <project>/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php:90

So attempting to run that command directly leads to:

xgettext: cannot create output file "/var/folders/lw/0f57k9dj617_ntr760qw2lcr0000fgp/T/poedit1nmsrR/3extracted.pot": No such file or directory

All PHP these PHP scripts are owned by Me:admin on my filesystem. Seen this before?

@Saeven
Copy link
Contributor Author

Saeven commented Nov 6, 2013

Looks like there might be a bug in Poedit, so I have just another quick question for you. Which version of poedit have you successfully used with your script?

@umpirsky
Copy link
Owner

umpirsky commented Nov 6, 2013

@Saeven Hehum...strange. I used it with 1.5.4-1.

@Saeven
Copy link
Contributor Author

Saeven commented Nov 6, 2013

Sorry to be daft, I'm partway trying to ascertain that I'm not crazy. Can you tell me what you have in your catalog preferences in the sources path section?

@Saeven
Copy link
Contributor Author

Saeven commented Nov 6, 2013

Also, what OS were you using 1.5.4-1 with?

@umpirsky
Copy link
Owner

umpirsky commented Nov 6, 2013

I suggest to test with simplest data possible, one simple string.

I'm using Ubuntu 13.04.

@Saeven
Copy link
Contributor Author

Saeven commented Nov 6, 2013

Sorry to be a pain, but could you share a sample catalog config in sources path?

@umpirsky
Copy link
Owner

umpirsky commented Nov 7, 2013

Unfortunately, I have no. But you can try with one string catalog.

@aeneasr
Copy link
Contributor

aeneasr commented Apr 25, 2014

Same issue here - I'm on Mac OS X

@umpirsky
Copy link
Owner

@arekkas Can you debug it?

@aeneasr
Copy link
Contributor

aeneasr commented Apr 25, 2014

it seems like poedit is telling xgettext to use a file that is inside a directory, poedit has not created yet. Which is weird, because the other parsers work.

@aeneasr
Copy link
Contributor

aeneasr commented Apr 25, 2014

The problem is, I can't really see why the command fails in poedit, only when executing it directly from cmd I see the error messages. However, when I modify the -o parameter to an existing directory, the script is working fine

@umpirsky
Copy link
Owner

You can go into Twig-Gettext-Extractor code and log information you need to see if files exist at that moment and all data you are inetrested in, right @arekkas? For example in https://github.com/umpirsky/Twig-Gettext-Extractor/blob/master/Twig/Gettext/Extractor.php#L70-L88

@aeneasr
Copy link
Contributor

aeneasr commented Apr 25, 2014

True, I'll have a closer look tomorrow

@feedmeastraycat
Copy link

I had the same, or similar issues, as described here (and in other issues here). I'm on OSX. After picking Twig-Gettext-Extractor apart and rebuilding it again I found out that I only had to do three things (2 of them not described in the readme.md file).

  1. Copy the vendor/bin/twig-gettext-extractor and add some extensions (as described in readme.md)
  2. Setup poedit with the following parser command:
    ./twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F
    I don't know if is meant to be literarily "" or your project path. But doing ./twig-gettext-extractor seems to work to use the po-files project location which would be nicer then changing the parser every time you switch project.
  3. Put this line first in my copied twig-gettext-extractor file:
    putenv('PATH='.getenv('PATH').':/opt/local/bin');

It seemed that PHP didnt find "gettext" because PHP wasn't allowed to look in /opt/local/bin. That caused all other issues I had basically. But it was very hard to debug.

Ping @umpirsky FYI. :)

It would be nice though if the twig-gettext-extractor could run as a service in a symfony/console command instead though. I tried to do that but I have yet to solve how that could be done. Or maybe if you could create a twig-gettext-extractor file that included the vendor/bin/twig-gettext-extractor file and only had to contain your custom extensions. This way makes it a bit less easy to keep up to date if/when Twig-Gettext-Extractor updates. But, well. It works now at least... I think. :)

@umpirsky
Copy link
Owner

@feedmeastraycat Thanks for sharing this man!

I didn't understand point 2. Did you copy extractor to poedits dir?

I would like to keep this decoupled from Symfony. People use it with other frameworks too. But I would like to see people integrating it with frameworks too.

@feedmeastraycat
Copy link

@umpirsky No. My .pot file is located in /src/locale/ inside the project so I put base path to "../../" in Catalog > Properties > Sources path within Poedit. Then I have added "./src/views" in "Paths". And then I have "./twig-gettext-extractor" when I setup the twig parser. It seems that Poedit (1.6.5) understands that "./twig-gettext-extractor" is within the base path.

I had to copy twig-gettext-extractor from /vendor/bin/ because I needed to add some more extensions.

Here is a screenshot of my parser setup:
https://www.dropbox.com/s/jc0svmt4wxmgepm/Screenshot%202014-05-21%2011.08.39.png

Here is a screenshot of my pot-file catalog properties:
https://www.dropbox.com/s/fuwcury2w4az86q/Screenshot%202014-05-21%2011.09.53.png

Im still unsure if the example of <project>/vendor/bin/twig-gettext-extractor/ ... is meant to be taken literarily. Or if I should replace <project> with the full path to where my project is. But that seemed like a bad solution because that would make the twig parser project specific. But either way. Replacing <project>/ with ./ did the trick anyway. :)

The only problem I have now is that I want to use the {% trans %} tag the way Symfony sets it up so I can use, for example {% trans with {'%name%':'David'} %}Hello %name%!{% endtrans %} ... But I havent figured that out yet. If it even can be done. :)

I understand that you wanna keep it decoupled from Symfony though. Makes sense. I will probably revisit that again and see if I can put it into the console.

@umpirsky
Copy link
Owner

You should replace with the full path to where your project lives. 😸

But I agree, it is not handy for project switching.

Thanks for the effort, really appreciate it.

@feedmeastraycat
Copy link

@umpirsky Ok. Thanks. :) I wasn't sure from the readme if it was a placeholder or some poedit var. :D But cool. Now I know. But I'll keep ./ because I like to keep it not project specific. I know that Im gonna forget about that if else, and Im gonna spend weeks trying to figure out why it doesn't use my twig-gettext-extractor on my next project! ;)

@aeneasr
Copy link
Contributor

aeneasr commented May 27, 2014

I finally got it working, you need to execute POEdit (on Mac) like this: WXTRACE=poedit,poedit.tmp,poedit.execute /Applications/Poedit.app/Contents/MacOS/Poedit --verbose --keep-temp-files

Source: http://circlical.com/blog/2013/11/5/localizing-your-twig-using-zend-framework-2-applications

@aeneasr
Copy link
Contributor

aeneasr commented May 27, 2014

Works like a charm now, even with ZF2 :)

@umpirsky
Copy link
Owner

umpirsky commented Jun 2, 2014

@arekkas Thanks for sharing. If this works on Mac I will accept PR with MacOS section instruction.

@barmarko27
Copy link

I'm on OSX Yosemite and the issue of missing folder under "/var" still continue. There are many OSX users that have same problem? Thank so much!

@umpirsky
Copy link
Owner

@barmarko27 Have you tried #12 (comment)?

@barmarko27
Copy link

@umpirsky Yes, but don't work! It seems that Poedit can't delete the temp file.

Poedit parser configuration:
schermata 2015-05-26 alle 12 28 41

Poedit Command Line Execution:
schermata 2015-05-26 alle 12 31 23

Poedit Error:
schermata 2015-05-26 alle 12 31 07

Thanks for your support!

@umpirsky
Copy link
Owner

@arekkas Any idea why it does not work for @barmarko27? Thanks.

@aeneasr
Copy link
Contributor

aeneasr commented May 26, 2015

With the latest POedit version, you don't need WXTRACE=poedit,poedit.tmp,poedit.execute /Applications/Poedit.app/Contents/MacOS/Poedit --verbose --keep-temp-files any more. Just start PoEdit regularly.

You'll also need to make sure that the path to twig-gettext-extractor is correct by running it in the console.

@barmarko27
Copy link

@arekkas Yes the path to twig-gettext-extractor is correct. It seems that Poedit can't delete temporary folder after execution of Twig Parser. Thanks for helping me!

@umpirsky
Copy link
Owner

Is it a permission problem?

@aeneasr
Copy link
Contributor

aeneasr commented May 27, 2015

@barmarko27 did you start POEdit without --keep-temp-files?

@saadhre
Copy link

saadhre commented Jul 29, 2015

Platform: MacOS Yosemite 10.10.4 (14E46)
Poeditor: 1.8.3 (3998) with xgettext 0.19.4.

When I starting Poeditor without parameters and trying to update translation from source, poeditor throws described error. With --keep-temp-files or with WXTRACE=poedit,poedit.tmp,poedit.execute exception is different:

Can't remove directory '/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2' (error 66: Directory not empty)
Can't run application: PATH_TO_PROJECT/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig"

Any idea?

@aeneasr
Copy link
Contributor

aeneasr commented Jul 29, 2015

Can't run application: PATH_TO_PROJECT/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig"

Doesn't look like a real path to me ;)

@saadhre
Copy link

saadhre commented Jul 29, 2015

Yes, real path has sensitive client data in names. But trust me - path is correct.

@aeneasr
Copy link
Contributor

aeneasr commented Jul 29, 2015

I see :)
Does verbose give useful info?

@saadhre
Copy link

saadhre commented Jul 29, 2015

In trace everything looks fine... Trace data before exception:

Trace: (poedit.tmp) new temp file /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/14extracted.pot
Trace: (poedit.execute) /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin//Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor doesn't exist, falling back to /Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor
Trace: (poedit.execute) executing: /Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig"
Trace: (poedit.tmp) keeping temp files in /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW
Trace: (poedit.tmp) removing temp dir /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW

@saadhre
Copy link

saadhre commented Jul 29, 2015

Just checked content of /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/ directory and 14extracted.pot not exists in there.

@ternes3
Copy link

ternes3 commented Aug 31, 2015

same problem here.
start with --keep-temp-files ends in error 66#
without --keep-temp-files ends in

Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/0extracted.pot
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/1extracted.pot
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/2extracted.pot
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/3extracted.pot
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/4extracted.pot
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/5merged.pot
Trace: (poedit.tmp) removing temp dir /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08

@jeremyzahner
Copy link

Having the same problem:

Trace: (poedit.tmp) new temp file /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ/0extracted.pot
Trace: (poedit.execute) /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin//Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor doesn't exist, falling back to /Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor
Trace: (poedit.execute) executing: /Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ/0extracted.pot" --from-code=UTF-8  -L PHP --files  "_angebot.twig" "_index.twig" "_kontakt.twig" "_team.twig" "_technologie.twig" "_werte.twig" "baselayout.twig"
Trace: (poedit.tmp) keeping temp files in /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ
Trace: (poedit.tmp) removing temp dir /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ

Any Updates on this?

@umpirsky
Copy link
Owner

@jeremyzahner MacOS?

@jeremyzahner
Copy link

Yes! Sorry for leaving out that detail ^^

@umpirsky
Copy link
Owner

@jeremyzahner The problem is that I am a Linux user myself and project is tested on OSX by other users. Have you tried @arekkas suggestion from #12 (comment) ?

@aeneasr
Copy link
Contributor

aeneasr commented Dec 22, 2015

I can confirm this issue with recent POEdit versions. It works neither with --keep-temp-files nor without. My best guess is to rollback your POEdit version.

@umpirsky
Copy link
Owner

Thanks for the update @arekkas. Let's try to ping Mr. @vslavik the author of Poedit, maybe he can give us some inside information about Poedit and how it handles files.

@vslavik
Copy link

vslavik commented Dec 22, 2015

Let's try to ping Mr. @vslavik the author of Poedit, maybe he can give us some inside information about Poedit and how it handles files.

Sorry, it’s not really clear what you’re asking about — this issue is a bit of a mess to read through and I can’t quite make sense of all it. If you have a reproducible test case (one that doesn’t take half an eternity to setup), by all means, send it to me to have a look.

Without that, just a few assorted observations:

  1. The original issue doesn’t seem related to Poedit: it’s clearly some extractor failure. The subsequent complain about manual xgettext command failing is bogus: of course it fails if you didn’t create the output directory (as Poedit would before invoking the command).
  2. The advice to always use --keep-temp-files doesn’t make sense to me — that’s for debugging only!
  3. The errors about failing to delete the temp directory are caused by the use of --keep-temp-files (due to a minor bug where Poedit would still try to delete the dir despite the flag — I’ll fix that right away).
  4. If some *extracted.pot file is not created and not kept with --keep-temp-files (this is the only valid use for it: debugging if some files were created or not), then the only explanation is that the extractor tool that was supposed to create it didn't. Notice how the builtin extractors use the --force-po to always create an output file, even if empty. If twig-gettext-extractor doesn’t create an empty-but-valid POT file (i.e. with header, but no other msgids) when it doesn’t encounter any translatable strings, that would certainly cause this.
  5. The use of relative paths to extractor executable was never supported and if it worked at some point, it was by pure accident. It’s not really clear to me why would you want to do that (instead of having a copy of twig-gettext-extractor somewhere in PATH to use with all your projects), but I assume I must be missing something, and would welcome education (probably at help@poedit.net as it would be offtopic here).

(BTW, I’m reworking extractors completely for the next major version (don’t worry, there will be “legacy” compatibility) and am soliciting any extractors-related feedback from, you know, real users of custom extractors — feel free to ping me at the above email address).

@aeneasr
Copy link
Contributor

aeneasr commented Dec 22, 2015

The errors about failing to delete the temp directory are caused by the use of --keep-temp-files (due to a minor bug where Poedit would still try to delete the dir despite the flag — I’ll fix that right away).

This will fix our issue 100%. It would be great if you could implement that!

@vslavik
Copy link

vslavik commented Dec 22, 2015

This will fix our issue 100%. It would be great if you could implement that!

I feel like I might have not been as clear as I thought I was, so let me repeat myself in the interest of being absolutely clear:

DO NOT EVER USE --keep-temp-files!

It doesn’t solve anything and is not meant to be used by end users! If it does seem to help you with something, please show me a reproducible test case of what it solves, using the latest Poedit version, and I’ll fix that, because that would uncover some serious issue — but to be frank, I simply don’t see how could anything of the sorts be possible.

@aeneasr
Copy link
Contributor

aeneasr commented Dec 22, 2015

Well I believe that the issue is as follows:

twig-gettext-extractor converts *.twig (no native POEdit/xgettext support) files to *.php files. These get stored in a temp dir and then iterated by xgettext. Somewhere inbetween, these files get deleted which is why xgettext is saying that they don't exist. This issue was "resolved" by telling POEdit to keep the files.

That's at least what I think is happening.

@vslavik
Copy link

vslavik commented Dec 22, 2015

I see two problems with that theory:

  1. Why do you think twig-gettext-extractor’s private temp files are stored in Poedit’s private temporary directory? Poedit creates a temp (sub)directory of its own, doesn’t change any environment variables and doesn’t change CWD to the tempdir either. Unless the extractor goes to extra pain to set the cache directory to Poedit’s temp one (i.e. the location of the output file, not the input twig files), I’m not sure how could that happen? If it does happen, it would indeed be problematic for Poedit (and I’ll address that too, because there’s no reason why Poedit shouldn’t survive some leftover temp files), but is it happening?
  2. Looking at the code, the extractor generates PHP files, runs xgettext and only exits after that. Poedit doesn’t, and cannot, delete the temp folder before twig-gettext-extractor returns. There’s no way for it to delete files from under the extractor’s hands, even if they were located in Poedit’s temp directory.

I’m more and more confused by the minute :-/

@aeneasr
Copy link
Contributor

aeneasr commented Dec 22, 2015

I'm sorry but I'm not sure if I can help you further. I ran into this issue some years ago and found the --keep-temp-files fix in some blog. It worked back then but at some point I upgraded POEdit and it stopped working. It has not been working ever since. I also think that this issue is Mac only. Maybe Mac manages its temp directory in a different way than Linux. No idea.

@umpirsky
Copy link
Owner

Thanks for your response and willing to help @vslavik, I really appreciate it.

One thing is sure. I am 100% sure cache directories of Twig and Poedit are not shared. No doubt about that.

I never encouraged people to use --keep-temp-files it was never in readme. I see they use it for debug purposes.

I agree this issue is too verbose and hard to read, so for the sake of sanity let's just wait for some Mac user to come up with proper and easy to reproduce test case.

Now we have @vslavik who is willing to take a look and I am very thankful. 👍

@umpirsky umpirsky self-assigned this Dec 22, 2015
@vslavik
Copy link

vslavik commented Dec 22, 2015

One thing is sure. I am 100% sure cache directories of Twig and Poedit are not shared.

Still a mystery, then. Let’s wait for more details as you say, then.

I never encouraged people to use --keep-temp-files

Of course! I just wanted to clarify this for readers of this issue.

@Saeven
Copy link
Contributor Author

Saeven commented Dec 22, 2015

Keep temp files did indeed fix things for me once upon a time:
https://groups.google.com/d/msg/poedit/t1HzAIZxKUc/SRjp2bAwYm0J

It was in a debug command that @vslavik had recommended during a test run.

@vslavik
Copy link

vslavik commented Dec 22, 2015

Keep temp files did indeed fix things for me once upon a time:
https://groups.google.com/d/msg/poedit/t1HzAIZxKUc/SRjp2bAwYm0J

According to the archive it was the act of running Poedit from command line that did, not the flag itself:

When I launch it from the command line, even without --keep-temp-files, it works. If I double-click it to launch it (in its Applications folder), then it fails.

That makes sense to me: it’s a very different runtime environment (in particular, your shell customizations are loaded, unlike when launching from Finder) and e.g. it could be that you can’t even successfully run some php scripts in the Finder-launched environment. Maybe that’s indeed what’s going on here.

Thanks for this link, I forgot all about it!

vslavik added a commit to vslavik/poedit that referenced this issue Dec 22, 2015
Make sure TempDirectory dtor always removes Poedit's temporary directory
completely, without errors. There were two subtle bugs in the old code:

1. Poedit would try to rmdir the directory even with --keep-temp-files.
This would fail because the files weren't deleted.

2. If something created unexpected extra files, rmdir would fail too.

Fix both by recursively deleting the directory with its content, instead
of doing the same thing manually, but only for recognized files. As a
bonus, make the code slightly simpler.

See umpirsky/Twig-Gettext-Extractor#12
@umpirsky
Copy link
Owner

@vslavik Thanks, in which version of Poedit will vslavik/poedit@849367f be included, just for the reference for people that step across this issue?

@vslavik
Copy link

vslavik commented Dec 23, 2015

@vslavik Thanks, in which version of Poedit will vslavik/poedit@849367f be included, just for the reference for people that step across this issue?

The next one (1.8.7), but this rmdir thing is a red herring, this change only affects debugging use and misbehaving extractors (which yours isn’t).

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

9 participants