I’ve updated my Mac to Catalina version.
Since this new release of Mac OS, i’m not able to execute ruby from PHP anymore.
I can’t find anything of internet.
This is how I call ruby from PHP
$cmd = "ruby duplicate_ios.rb '$xcode_version' '$xcodeproj_path' '$bundle_id' '$display_name' '$target_source' '$target_destination' '$iosTeamID'";
$outputDuplicateTarget = system($cmd);
When I execute from terminal, it works.
But not when it’s from PHP.
And before Catalina release, it worked.
EDIT
in ruby script
require "xcodeproj"
=> seem to be the origin of the crash (only from php script)
3
Answers
SOLUTION :
PHP was run in MAMP, which using a special ruby version.
Use "php -S 192.168.xx.xx:8888" instead of MAMP fixed the problem !
Apple has removed Ruby and other scripting languages from their OS, see deprecations
You probably will want to use a ruby version manager such as RVM. For install instructions see https://rvm.io/rvm/install
For maintaining a current, up-to-date environment on macOS you have several options:
rbenv
which is a minimally invasive version manager you can install with Homebrew.rvm
which is more cross-platform, but which embeds more deeply in your shell environment.Both of these allow you to install different versions of Ruby simultaneously and switch between them automatically with a
.ruby-version
file in your project’s directory. This makes working with older code-bases quite effortless.They also allow you to install Ruby gems without having to
sudo
anything as the gems are installed for one user only.WARNING: When calling
system()
in PHP it’s extremely important to properly escape any and all data arguments. Useescapeshellcmd
to handle the escaping. If you fail to do this you run the risk of command errors due to conflicting quotes, or worse, as a user could potentially hijack your system by running arbitrary shell commands.