• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trouble running ruby code in Run Script build phase
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble running ruby code in Run Script build phase


  • Subject: Re: Trouble running ruby code in Run Script build phase
  • From: Paul Walmsley <email@hidden>
  • Date: Wed, 13 Aug 2008 23:16:07 +0100

Abizer Nasir wrote:
I've got the following ruby code which works fine when run as a script, but doesn't run correctly when run as a script in an Xcode buld phase:

I've got the shell correctly pointing to /usr/bin/ruby
...
output = `which git`
puts output
# THIS RESULTS IN A nil
...
This is only part of the script, I would like it to be agnostic about the location of git on a computer, but I can't run 'which' from within Xcode.


This is very frustrating. Am I missing something? I can work around this, but it would be inelegant.
The line `which git` from ruby invokes the shell (probably sh or bash), and it will only return the path to the git program if it is already on your path (which typically is set in /etc/profile or ~/.bash_profile). If it is already on your path then you could just run 'git' directly anyway without needing to worry about the path to it. If it's not on the path then there is no decent way of finding out where it is. You may legitimately have several versions of git that you use for different projects which are in different directories.

If you are expecting git to be in a nonstandard location and not part of the path, probably the best thing to do is search the path first and if it can't be found then fall back to an environment variable (eg GIT_PATH).

Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Trouble running ruby code in Run Script build phase (From: Abizer Nasir <email@hidden>)

  • Prev by Date: Re: build script access
  • Next by Date: Re: Trouble running ruby code in Run Script build phase
  • Previous by thread: Re: Trouble running ruby code in Run Script build phase
  • Next by thread: Re: Trouble running ruby code in Run Script build phase
  • Index(es):
    • Date
    • Thread