jycouet / VSTSExtensions

MIT License
30 stars 11 forks source link

Fails when yarn global bin is not in $PATH #16

Closed elwynelwyn closed 4 years ago

elwynelwyn commented 5 years ago

I'm just setting this up on a new pipeline, and I've selected a Hosted Ubuntu 1604 from the Azure Pipelines agent pool.

This Ubuntu instance has yarn installed, however the yarn globals bin directory is not in the $PATH.

This means that the Renovate task successfully does the global yarn install of the renovate package, but when it comes time to run, fails with an error that renovate can not be found.

My workaround was to add a new Bash task in the pipeline before Renovate, which runs this:

echo '##vso[task.prependpath]$(yarn global bin)'

It would be great though if this was not necessary. A couple of options come to mind. One would be to run renovate via npx. This would add a dependency on having a recent version of npm available, but it would mean there is no need for the global install. Another would be to figure out the absolute path to the Renovate binary by using the yarn global bin command.

wescopeland commented 4 years ago

The Renovate task is currently failing in Azure Pipelines for me due to this issue, and unfortunately the Bash task workaround doesn't seem to be working.

jycouet commented 4 years ago

Actually, when you look at the Readme.md, you can see that I was using the task Yarn Tool Installer, and everything was working fine. A few months ago, it stopped working because of an issue that in renovate, he was not able to find the path of yarn (like you!!!) I tried many things without any success :(

Today I don't use the task Yarn Tool Installer and renovate is using npm directly. It's working... but without yarn!

But I agree that it would be good to be more integrated... So what are the options?

  1. npx? (I don't know this, maybe you can guide me?)
  2. The absolute path to the Renovate binary by using the yarn global bin command. I'm not sure where you want to go?! Could you explain more? :)

//Project is going back to active :)

elwynelwyn commented 4 years ago
  1. With npx, you would not globally install Renovate at all. So lines ~50 - 60 would go away. Then your runRenovate would change to

    const runRenovate: ExecutionOptions = { tool: 'npx', arguments: `renovate@${renovateOptionsVersion} ${renovateArgs}` }

    npx will take care of installing renovate and then runs it, all in one.

  2. You can get the path to the bin folder by executing yarn global bin. You can then save this into a variable, and in your runRenovate if it is yarn capable you can do

    { tool: yarnBinPath + 'renovate'` ...
jycouet commented 4 years ago
  1. I will then need to install npx globally first. So is it really better?

  2. I will correct it now and see your feedback 👍

elwynelwyn commented 4 years ago

For 1., no, npx is available everywhere npm is available (it installs with npm, from version 5.2.0 onwards)

jycouet commented 4 years ago

@elwynelwyn can you have a look? I merged with the "manual search of the bin path".

And now see that with npx... we can remove a LOT of lines! Hummm... what is the best?

elwynelwyn commented 4 years ago

Looks good! Thank you for making the change!