10-20 years with major investments.
If no one in world bought oil from Russia it would not matter. There is enough global supply to make up for it.
Oil is the least of the issues. In the short term it can be made up by SA and the UAE if they so desire. It's clear that cars are moving away form oil, and trucks will follow. This is a 20-30+ year process of attrition before the overwhelming majority of trucks are electric.
The bigger issue is the NG used to generate electricity which will be replacing the gasoline. There isn't anywhere near enough capacity to replace all the current oil, coal, and NG usage with renewables, never mind the increased demand for electricity replacing gasoline and replacing NG and oil for heating.
As we know, the chance of another nuclear power plant coming online in the US anytime soon is slim to none. That leaves us with wind and solar as the primary replacements. There isn't nearly enough manufacturing capacity to build these wind turbines and solar panels. Solar panels also need a lot more mining (likely in Russia) to increase production by at least an order of magnitude.
Even if there was enough solar and wind in 20 years to replace all fossil fuels (there won't be) there is still the issue of storage. Solar and wind are intermittent, they need a huge amount of battery storage to be able to take over the reliability of fossil fuels.
Battery technology has come a long way, and is continuing to advance at an amazing rate. There is no shortage of investment in battery technology, but mark my words, you will see OEMs unable to reach their targets for EV production due to cell shortages. Once that's resolved it will be on to electrifying trucks. Only then will all excess battery cell production be available to the massive scale grid storage that is necessary.
There already is some grid scale storage being implemented, but in order to change everything to renewables we will need to increase by orders of magnitude.
It's not a lack of investment, it just takes time. The cost for batteries dropped something like 90% over the past decade making it economically viable for the first time ever. Now it will just take time.