Using Launchd with Mavericks and Ruby - ruby

Upgraded to Mavericks and now launchd / Lingon is unable to launch Ruby scripts. I have the files set to be executable (using chmod +x), and have the first lines set to
#!/usr/bin/ruby
However, I keep getting the following error in Console:
com.apple.launchd.peruser.501[169] (craig.logging[754]): Exited with code: 1
That is a permissions error, but I have no idea what permissions to fix or change. The script runs fine in terminal with ruby.
This is driving me nuts.
Update: the Ruby scripts that are causing the problem write their output to another file, for example, in my Dropbox. But I'm running the launchd files as myself who has admin privileges to write to those files. No idea what's going wrong...]
Update 2: Have started using Applescript to launch the Terminal and run my scripts, but this is pretty clumsy and inelegant. Anyone else have any insight to why launchd won't run scripts that write their output to files? Or is anyone having success with scripts that do?
Update 3: The failures were being triggered because of encoding issues. I had to specifically set file.open(path/to/file, encoding: 'UTF-8') for the scripts to work.
Thanks everyone.

I had this same problem on a Mavericks box with several Ruby scripts I have set to run at various intervals. I found that while this machine that had the OS upgraded was failing, my new MacBook Pro that shipped with Mavericks could schedule the same scripts off launchd just fine. I ended up erasing the machine and reinstalling Mavericks (and everything else) from scratch, and then scheduling the scripts began to work.
Not the most delicate answer, I know, but Worked For Me™.

I'm still not entirely sure why, but the permissions errors were being triggered because of encoding issues. I had to specifically do this:
File.open(path/to/file, encoding: 'UTF-8')
for the scripts to work.
Thanks everyone for your help.

Related

oh-my-bash not launching at terminal startup

A little while ago I updated to the newest version of bash on my macbook (all went smoothly there,) and decided to try out the oh-my-bash framework. I had previously used oh-my-zsh, so I was familiar with the installation; however, I'm running into an annoying problem with oh-my-bash.
When I open the terminal the framework doesn't launch automatically. It only launches if I run exec bash in the command line. I've checked in system preferences and bash is set as default, and running bash --version confirms that I am running the correct version of bash when the terminal starts up.
It's more of an inconvenience than anything else, but I'm learning scripting and my burning curiosity wants to find the solution. I'm out of ideas short of a fresh install of the framework; what do you guys think?
My solution is this:
Run this code in terminal
mv $HOME/.bashrc $HOME/bash_profile
Restart your terminal
In linux, bash run command file is .bashrc, but in MacOS is .bash_profile.

Mac OS install application and run a script on startup

I'm looking for a way to package my application with the added requirement that I need to add a python script to always run on startup.
What I've been trying so far is having a .pkg that installs the .app into the applications folder and adds the python script (wrapped in a .plist launch daemon) to the user's LaunchAgents folder.
I've tried a lot of different things, but for whatever reason the python script runs fine on the command line and just doesn't work when running through launchctrl. I could go into what the problems were, but I feel that would make more sense as a separate question.
I am wondering if I should be using a different approach to achieve my goal of installing the app in Applications and having a python script run on boot. Is there a more standard solution that I am missing perhaps? Thanks.

Sencha Touch Cmd tool 3.0 install not working on Mac

-bash: sencha: command not found
I just spent a few hours trying to make this Sencha Cmd works on my MacBook, but just couldn't. I uninstalled a previous version and just couldn't get it to work again. I always get the
-bash: sencha: command not found
error. I did try everything in this post, without success.... I even get an error when I call
.bash_profile
stating that it's not found... Do you have any idea what could be the problem ?
I'm fairly new to the Linux command world so I might miss a point here. Maybe I might use "sudo" to be granted acces to bask_profile ?
EDIT : I got it working for the current bash session. I position myself at the user root (~/) and call ". .bash_profile"(the space is important here). BUT... it only works for the current session. As soon as I close Terminal and reopen it, I loose everything :-(
OK, just so you know, I managed to fix the damn thing be opening and editing the ".bash_profile" file in a text editor (TextMate for me). This is an hidden file, but you can configure your Mac to show those files in Finder. The file is located at your user's root. It is quite annoying to have to spend hour messing in path and environment variables in 2013... Installer should do those things and reports error if something happens in the install process.

Mac OS X 10.8.1 - Files no longer being watched

Just updated to OS X 10.8.1. I'm not sure if this is the cause, but basically immediately after, programs are unable to check for file changes.
In my makefile, the following command does not work (it doesn't trigger on file changes)
watchr -e "watch('scripts/.*\.js') {system 'make scripts'}"
On Sublime Text, when I make a new file in a folder, that new file is not shown in the sidebar, but it is created correctly in the directly.
This command, however works (based on Node's watch command, I believe):
stylus -w -u nib styles/ie8.styl -o public/styles
Anyone know what's going on or how to debug?
Edit: This isn't working now after rebooting again. I hate this! :/
I also ran into this issue with Sublime Text 2 as well as Guard (it started using a polling fallback).
I believe I found a fix:
Download Onyx and run it with all of the options under the automation tab checked
After it's done shut down your machine and turn it back on
At this point I was suddenly able to see new directories created using mkdir in terminal from within the Sublime Text 2 file browser. Guard was also working without the polling fallback.
I hope this helps, it was really starting to get on my nerves.
This isn't going to be very informative but maybe it will help...
There is a thread in the Sublime Text forums discussing this issue and it doesn't seem to be secluded to OS X 10.8.1.
There also seems to be a thread about watchr not always working, and that issue seems to be platform independent as well.
I would bet that you've become the unwitting victim of the 'Mac OSX' env vars change ...
Please take a look at the following to determine if your env vars are set correctly on Mountain Lion as the environment.plist is now deprecated ...
Env Plist Deprecated
Mac OSX - Sublime

Mac OSX 10.6.4 - postinstall/postflight scripts fine in single pkgs but not in metapkgs

I'm new to Mac OSX dev, and I'm having trouble with building a metapackage.
I have 7 pkgs which I want to wrap up into a metapkg.
When I executing each package separately everything works as expected, all scripts run etc.
However, when the same packages run as part of a metapackage, none of the scripts execute. The scripts are all postinstall or postflight.
I've tried using Iceberg in place of PackageMaker but get the same result.
Is there something I'm missing?
I'm tearing my hair out!
Thanks in advance,
Mark.

Resources