renovatebot/renovate

Upgrade versions in .tool-versions

aaronjensen opened this issue · 21 comments

What would you like Renovate to be able to do?
When upgrading node, ruby or the like, it should also change the version in .tool-versions, used by asdf.

Describe the solution you'd like
See above.

Describe alternatives you've considered
Doing it manually.

Additional context
I'd imagine other version managers have similar files. Maybe renovate already supports them, but if not, it'd be great if it did as well.

As a workaround it should be possible to add a custom rule using our new regex-based manager: https://docs.renovatebot.com/modules/manager/regex/

However I don't see any .tool-versions file in that repo today

@rarkins interesting. Which repo are you referring to? asdf is the tool that makes use of .tool-versions, not the repo I was writing in about. The repo is private.

Ok but in that case there’s no reference repositories for us to look at?

Here's an example .tool-versions:

nodejs 12.15.0
ruby 2.7.0

Is that good or do you need an actual repo with that in it?

If you want to try it, I suggest doing it in a public repo so that it's easiest to troubleshoot

I realized there are two different parts to implement for asdf:

  1. Updating variables in asdf itself. Because it's plugin-based, it's hard to know exactly what's supported, but it can start with the simple ones like ruby and nodejs
  2. Using values in .tool-versions when we decide which version of ruby or node to run to update npm or bundler packages

@rarkins Are there any plans to implement this, or any guidance on how it should be implemented?

This would be a new manager and require a community contribution.

@viceice I can take a shot at it. Do you have any pointers on how to achieve @rarkins' second point? An example from another manager, perhaps?

checkout

const rubyVersionFile = getSiblingFileName(
packageFileName,
'.ruby-version'
);
const rubyVersionFileContent = await readLocalFile(rubyVersionFile, 'utf8');
if (rubyVersionFileContent) {
logger.debug('Using ruby version specified in .ruby-version');
rubyConstraint = rubyVersionFileContent
.replace(/^ruby-/, '')
.replace(/\n/g, '')
.trim();
}

I'd like to help with this one.

The asdf tool seems to keep its config in .tool-versions file and use single versions of dependencies, not ranges: http://asdf-vm.com/manage/configuration.html#tool-versions

So my plan for implementing this feature:

  1. Implement a new manager in lib/manager/asdf. Take some existing manager as a base. I would take lib/manager/pip_requirements as a base since its config file format is similar. But asdf seems to not have any artifacts, so it's even simpler.

  2. In the manager's extract.ts, split the .tool-versions file into lines, and parse each line.

Each line has format:

depName version

where version may be one of the following:

  • 10.15.0 - an actual version.
  • ref:v1.0.2-a or ref:39cb398vb39 - tag/commit/branch to download from github and compile
  • path:/src/elixir - a path to custom compiled version of a tool to use. Ignore such dep since it can't be updated well.
  • system - this keyword causes asdf to passthrough to the version of the tool on the system that is not managed by asdf. Ignore this dep since it can't be updated.

Depending on the depName, use different datasource. Maybe have a map of supported dep names and corresponding datasources. For example, for node deps use the npm datasource; for ruby use ruby-version.

I like to name the new manager tool-versions, as the file may be used by other tools later and the file is not specific to asdf

Work was started in #14092 but is not able to continue. Anyone who needs/wants this is welcome to pick up from where that PR left off.

+1 because that would be awesome 🎸

@bodinsamuel Please Don't flood issue with "me too" comments, this will cause a lot of noise for subscribers.

Use the 👍 emoji on issue description for voting.

ganta commented

With #17166, it appears that .tool-version is supported for Node.js only.
This change is released in version 32.199.0.

There are a bunch of rules defined in https://github.com/kachick/renovate-config-asdf/, would it be something that could be merged in Renovate itself?

This issue now is unfortunately a bit "wide", ideally we'd have an issue per tool so that each PR can close one issue. Unless someone is happy to submit a PR covering the remaining tools soon, we should close this as done and then create/link to separate feature requests per tool.

My plan was always to add tools as I need them or for others to contribute for their needs - I just wanted to get one supported tool (and probably the most popular one) just so I could validate the flow without the additional complication of all the additional tools.

Closing this issue as suggested #4051 (comment).
For further tools please open a separate feature requests.