spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
564 stars 102 forks source link

wsl and laravel #756

Closed spham closed 1 year ago

spham commented 1 year ago

Describe the bug event not return from test

Versions 2.1.1.0

You can use composer show to get the version numbers of:

PHP version: Laravel version (if applicable):

To Reproduce Steps to reproduce the behavior:

step0: publish config

step1: update .env

RAY_HOST=
RAY_REMOTE_PATH=
RAY_LOCAL_PATH=

start a t, it's not work

Expected behavior display result

Desktop (please complete the following information):

RhysLees commented 1 year ago

To get this to work on wsl2 you will need to do the following:

Add this to your wsl2 terminal profile, in my case ~/.bashrc:

# Set winhost to windows ip
export winhost=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
old_winhost=$(grep -P "[[:space:]]winhost" /etc/hosts | awk '{ print $1 }')

if [ -z $old_winhost ]; then
    echo "write winhost to /etc/hosts"
    echo "$winhost winhost" | sudo tee -a "/etc/hosts"
elif [ $old_winhost != $winhost ]; then
    echo "update winhost in /etc/hosts from $old_winhost to $winhost"
    sudo sed -i "s/$old_winhost winhost/$winhost winhost/g" /etc/hosts
fi

Close and restart your terminal

This will then when a new terminal is opened create an entry in wsl2's hosts file a winhost config pointing to windows local ip.

The reason you have to do this is because windows local ip for wsl changes every time wsl2 is started/restarted.

In your projects env add RAY_HOST=winhost

This will also work for Helo and other windows applications as winhost is basically the same as localhost except referring to windows compared to localhost referring to wsl2

spham commented 1 year ago

too complcated and overkill for me

RhysLees commented 1 year ago

too complcated and overkill for me

it only takes 30 seconds to do...