Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Trim trailing space from discovered Python versions.
The setup-python action failed because my .python-version (generated from a recent pyenv) had a trailing newline (not sure if this is a bug in pyenv, but I'll look there next). 

```
Installed versions
  Version 3.11.3
   was not found in the local cache
  Error: The version '3.11.3
  ' with architecture 'x64' was not found for Ubuntu 18.04.
  The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
```

As you can see, the version was not discovered because the newline didn't match exactly. The way I figure, even if this is user error, stripping trailing space is super easy, and will probably prevent some problems.
  • Loading branch information
Andrew Gwozdziewycz authored May 9, 2023
commit d14c82c71825ea8d75dafbbe769d05bdd4bc1d78
4 changes: 2 additions & 2 deletions src/setup-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function resolveVersionInput() {
`The specified python version file at: ${versionFile} doesn't exist.`
);
}
const version = fs.readFileSync(versionFile, 'utf8');
const version = fs.readFileSync(versionFile, 'utf8').trimEnd();
core.info(`Resolved ${versionFile} as ${version}`);
return [version];
}
Expand All @@ -52,7 +52,7 @@ function resolveVersionInput() {
);
versionFile = '.python-version';
if (fs.existsSync(versionFile)) {
const version = fs.readFileSync(versionFile, 'utf8');
const version = fs.readFileSync(versionFile, 'utf8').trimEnd();
core.info(`Resolved ${versionFile} as ${version}`);
return [version];
}
Expand Down