user1104854
user1104854

Reputation: 2167

Conflicting versions of composer installed package causing issues

I'm running mac OS X and trying to use codeception through the terminal for a laravel project I'm working on, but I'm having some issues related to the version. The codecept command through terminal is referencing an older version and I cannot figure out how to change the reference to the newer one.

When I type in codecept -v in terminal it shows 2.1.6. However, when I type in ./vendor/bin/codecept it shows 2.4.1. So, every time I need to use codeception I now have to type ./vendor/bin/codecept some_command, which is quite aggravating.

How can I change it so that I don't have to type out ./vendor/bin/codecept every single time I need to run a codeception command and can instead just use codecept, which the older version is currently referencing? I tried using export PATH=$PATH:./vendor/bin/codecept but that didn't do anything.

Upvotes: 1

Views: 129

Answers (2)

Stipe
Stipe

Reputation: 510

what worked for me is:

  1. Install Composer Navigate to your desired location and copy this set of commands in your terminal:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

  1. Install latest Codeception via Composer: In terminal type:

composer require codeception/codeception --dev

Upvotes: 0

rob006
rob006

Reputation: 22174

Try run:

export PATH=./vendor/bin:$PATH

It will prefer binaries from local composer installation.

You may want to add it to your ~/.profile or ~/.bashrc file, then you will not need to run this command in every session.


If your global Codeception installation is installed by Composer, you should be able to update it by:

composer global require codeception/codeception

But I would not recommend to use global installation - required Codeception version may vary for different projects, so using version installed locally should give you less trouble and more predictable results.

Upvotes: 1

Related Questions