Detect script location and ruby environment better