How to setup both PHP and Ruby 2.3.3 in CIrcleCI2.0

I have a PHP project which runs on PHP 7.1 and i have integration test which is written in Ruby. Both the projects are in separate directories. I rerquire both PHP 7.1 and Ruby to be installed. I tried using the circleci docker images but i was able to use any one of them.

Yes, this is possible, but readers will need a lot more information than that to be able to usefully assist.

You will probably need php and ruby binaries. To start with, perhaps you could:

  • show us the config you are using now, by pasting the YAML code in a reply (and using code/block formatting so it is readable)
  • add a temporary run step that does php -v && ruby -v so we can see your versions

Here is my config.xml

 version: 2
       - image: circleci/php:7.1-apache-node-browsers
       - image: circleci/ruby:2.3-node-browsers
       - run: php -v    
       - run: ruby -v   

Output is:
#!/bin/bash -eo pipefail php -v PHP 7.1.17 (cli) (built: May 5 2018 01:13:25) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

#!/bin/bash -eo pipefail
ruby -v
/bin/bash: ruby: command not found
Exited with code 127

Ah, righto.

So, your first image is spun up, and that becomes your build container, with PHP available. The second one is spun up separately and can be connected to over a virtual LAN e.g. for TCP connections. However, running commands will only be run on the first image.

To solve this, drop the second image, and install Ruby in the first container (or drop the PHP image and install PHP in a Ruby container, it’s up to you).

I would guess installing Ruby can be done with apt-get update && apt-get install ruby, but it depends on what those images are based on. It might be apk add instead, if it’s Alpine and not Ubuntu.

Okay. I have installed Ruby in PHP 7.1 container and its working for me. Thank you.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.