Weirdness with running a ruby-on-rails program from procmail - ruby-on-rails

I am trying to run a ruby program that is part of a RoR project from .procmailrc. From the command line the entire .procmailrc action line works fine, but when a real email message is processed through Procmail I'm getting the following error:
/bin/sh: line 1: 12625 File size limit exceeded(core dumped) /usr/bin/rails r test.rb
test.rb is just a simple script that copies from STDIN to a temp file.
My .procmailrc is
:0: $HOME/alerts.lock
* ^X-mailer: X-System Alert Info
| cd /usr/local/src/Alert; /usr/bin/rails r ./test.rb
Anyone have any idea what's going on?
EDIT: I should note that replacing /usr/bin/rails r ./test.rb in .procmailrc with a perl program that does the same thing (as test.rb) works.

It seems, as with all the other "File size limit exceeded" questions out there, it was indeed a large file. What threw me was that
I am running a 64-bit Fedora and thought the 2G file size limit did not apply to 64-bit OS's, and
The size of the culprit file was not even over 1G!!
Found this by changing the action line of the .procmailrc recipe to run the same program out of another RoR project and that worked. To make a long story short, in the end it turned out to be the development.log file in the project's log/ directory. As I said in 2. above, the file was only 192M, but as soon as I emptied it the .procmailrc recipe started working.

Related

Fatal error: Allowed memory size exhausted after MAMP update

I know this question can be found a lot of time on this forum and the internet. But I can't seem to find the answer to my specific question.
I'm running a Drupal website, and since the update of MAMP from 5.5 to 5.6 I get the following error:
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) when running a composer require in the terminal.
I updated the php.ini tot 1024MB instead of 128MB of the current php version I'm running via MAMP. When I add a php file to my root with <?php phpinfo(); ?> I see that the memory is like I want so 1024MB. When I look at the location of the php ini file I see it is in the MAMP folder.
But I still get the error. When I run this php -r "echo ini_get('memory_limit').PHP_EOL;" in my terminal I see the 128MB again. When I try to find the php ini that is running using
php -i|grep 'php.ini' I get:
Configuration File (php.ini) Path => /etc
So it looks like the php.ini file is somewhere else. But I don't know where and can't change it. How can I solve this?
I also tried changing the composer memory using php -d memory_limit=-1 /usr/bin/composer but this didn't solve the problem either.
My question is, how can I solve this problem? How can I find the php.ini file that is used. Or how can I change the memory limit?
Update:
Running php -i | grep 'Configuration File' in the terminal ouputs:
Loaded Configuration File => (none)
And maybe good to know that I have the option Make this version available for command line enabled on the MAMP php section.
I tried many of the suggestions on this and a few other stack overflow questions but couldn't get it to work until I tried:
COMPOSER_MEMORY_LIMIT=-1 composer require 'yourpackagenamehere'
Just trying COMPOSER_MEMORY_LIMIT=-1 by itself before running the command didn't seem to work. Not sure why, but I had to run them on the same command line in a similar way as documented in the composer troubleshooting: https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
I ended up adding a php.ini file to the /etc folder on my computer. This way the php memory_limit raise did work. And checking it in the terminal did show me the right value. But as Alister already said, this didn't fix the problem. The problem was not in the php.ini memory_limit.
I found out that using COMPOSER_MEMORY_LIMIT=-1 in the terminal at the beginning of my session put the memory limit to unlimited during that terminal session. This fixed the problem.
After that I added, alias composer="COMPOSER_MEMORY_LIMIT=-1 composer" to my bash file and know everything is working like I would expect.
Changing the amount of memory in php.ini won't help - that is the limit for what is being used by the webserver's version of PHP - and having too much available for the webserver can cause problems (at least when running in production).
Composer, when it is being run from the command line, will, by default set the limit to 1,610,612,736 bytes - 1.5 GB.
As you are apparently still on PHP 5.6, that's also a very considerable problem. PHP 7+ is a great deal more efficient with memory, as would be an up to date version of composer.
Finally, to actually solve the problem: Restrict your requirement to be more specific since that keeps memory usage lower.

Can't compile image with `gforthmi`

The application shown below
." Hello, world!"
bye
creates the following error when compiling via gforthmi stdout.4th:
/usr/bin/gforthmi: 47: /usr/bin/gforthmi: /usr/lib/gforth/0.7.3/gforth-ditc: not found
/usr/bin/gforthmi: 48: /usr/bin/gforthmi: /usr/lib/gforth/0.7.3/gforth-ditc: not found
redefined th
*OS command line*:-1: No such file or directory
comp-image >>>./temp-image.fi1<<< ./temp-image.fi2 stdout.4th bye
Backtrace:
$7F416215C970 throw
$7F41621924F8 slurp-file
rm: cannot remove './temp-image.fi1': No such file or directory
rm: cannot remove './temp-image.fi2': No such file or directory
I am running gforth 0.7.3 installed on an Ubuntu system via the official Ubuntu PPA.
Have I made a mistake in the way I compile the image? Am I missing any options?
There's couple of issues involved.
For some reason gforth-ditc on ubuntu is located in different path. Not under /usr/bin, but under /use/lib/$MACHTYPE/gforth/$version. I.e. for 64-bit ubuntu and gforth version 0.7.2 I have it located at /usr/lib/x86_64-linux-gnu/gforth/0.7.2/gforth-ditc. Find it in your system and specify with GFORTHD environment variable.
Second problem is with your test sample. It shouldn't end with bye, as that will terminate gforth-ditc (used by gforthmi) without possibly saving anything, as savesystem word passed as arguments to gforth-ditc will never be reached.
Another hint - your test sample will be interpreted during compilation, but won't contribute any code to generated image. At least define some words to be called after your image is loaded :)

'rake' is not recognized as an internal or external command, operable program or batch file

Minutes ago, I downloaded the oscurrency code from github, and I'm installing oscurrency on heroku. Everything seemed to be going perfectly until this command:
rake heroku:install
on the command line, in the directory where I downloaded the source code. I get the error:
'rake' is not recognized as an internal or external command, operable program or batch file.
I'm following the installation instructions at heroku here:
https://github.com/oscurrency/oscurrency/wiki/Heroku-Deployment-Guide
The command "rake heroku:install" is in the third paragraph from the bottom.
The code I downloaded came in a top-level folder called oscurrency. I downloaded that onto my laptop in C:\me\oscurrency. I was issuing the command in that directory when I got the error. I tried issuing the command in the folder C:\me\oscurrency\oscurrency -- same error.
Maybe the command has changed for some reason. Anybody have an idea what's going wrong?
Your problem is most likely that the command prompt is looking for a file named rake.exe and not able to find it because your PATH environment variable is not set to include that directory. I suspect that the rails command won't work either. You should add the ruby install directory (probably C:\Program Files\Ruby on Rails\bin\ to your PATH environment variable.
To do this, open your Computer Properties by right-clicking My Computer and selecting Properties, then find the "Advanced System Settings" link. Click the "Environment Variables" button at the bottom, and paste the path to that directory into the PATH variable, separating it with a semicolon.

LoadError when trying to get source code in Ruby

Trying to teach myself Ruby and using the Book Apress Beginning Ruby. I bought TextMate 2 and in the very beginning of Chap. 4 I am being asked for following:
Launch Terminal (Completed)
Use cd to navigate to the folder where you placed example1.rb, like so:cd ~/ruby. This tells Terminal to take you to the ruby folder located off of your home user folder. (Can't figure this out. What is "cd". Where do I type this TextMate 2 or Terminal. Do I type irb prior? I saved the example1.rb on my desktop, tried to drag and drop, says permission denied).
Type ruby example1.rb and press Enter to execute the example1.rb Ruby script.
If you get an error such as ruby:No such file or directory -- example1.rb (LoadError), you aren’t in the same folder as the example1.rb source file, and you need to establish where you have saved it. (Obviously I get this error, but I can't complete step 2).
Was super excited getting through chap 1-3 and using irb and now I bought TextMate2 and I get stuck trying to start my first ruby app.
Can anyone help explain Step 2 so I can complete 3 and 4?
What is "cd"
cd is change directory command. Type it in your terminal like this:
cd /dir/that/has/example1.rb
If example1.rb is in your Desktop and you are using Mac and your username is tom, then cd command would be:
cd /Users/tom/Desktop
Then from the terminal again, type:
ruby example1.rb
to run your Ruby script.

How can I get more information about a py2app error?

I am trying to package up a mixed Python/C++ application using py2app. My setup.py is
from setuptools import setup
setup(app=['voxpopuli.py'],data_files=[],options=
{'py2app'{'argv_emulation':True}},setup_requires=['py2app'])
and I invoke py2app via
python setup.py py2app --no-strip --iconfile /Users/irving/otherlab/other/bin/OLicon.icns --resources /opt/local/lib/Resources/qt_menu.nib
This completes without warnings or errors, but when I try to run the resuling app a window pops up that simply says "voxpopuli Error". It has an "Open Console" button, but the only console messages are
9/21/12 11:43:14.691 AM voxpopuli[52765]: voxpopuli Error
9/21/12 11:43:15.926 AM com.apple.launchd.peruser.501[158]: ([0x0-0x177d77c].org.pythonmac.unspecified.voxpopuli[52765]) Exited with code: 255
Are there standard ways to get more information out of py2app to help diagnosing this error?
I believe this is a problem with the app rather than the py2app.
If the app hits an unhandled exception it will exit out like this. Which version of osx are you using? In 10.8 they stopped automatically forwarding stderr to the console, so might be an idea to pipe the applications stdout and stderr to a file to see if you have a stack trace.
Although if it's an error in the C++ part I'm guessing you wouldn't see a stack trace, but the error could be in that part of the application.
If you really can't find the issue, try stripping large parts out the app until it runs then add bits back in until it doesn't run, then strip etc. (like a binary search) to try and find the offending part.
With the package built you can still run the 'application' from the command line.
For example for your project in ~/Projects/MyApp built into folder ~/Projects/MyApp/dist you should find you can run the following from commandline: ~/Projects/MyApp/dist/MyApp.app/Contents/MacOS/MyApp
This will output all the normal stderr messages to the console so you can see what is going wrong.

Resources