Skip to content

Commit fb77da0

Browse files
committed
Remove version cache
1 parent c27f94c commit fb77da0

3 files changed

Lines changed: 8 additions & 44 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
ruby-build
22
ruby-build-source
3-
.ruby-build-version-cache

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@ RUBY_APPLY_PATCHES=$(curl -s https://raw.githubusercontent.com/rvm/rvm/master/pa
2929

3030
By default asdf-ruby automatically fetches the latest release of ruby-build, so new Ruby versions are available as soon as ruby-build supports them.
3131

32-
You can override this behavior with the following environment variables:
32+
You can pin to a specific ruby-build version/branch/tag with the `ASDF_RUBY_BUILD_VERSION` environment variable:
3333

34-
- `ASDF_RUBY_BUILD_VERSION` - Pin to a specific ruby-build version/branch/tag:
35-
```
36-
ASDF_RUBY_BUILD_VERSION=v20240101 asdf install ruby 3.3.0
37-
ASDF_RUBY_BUILD_VERSION=master asdf install ruby 3.3.0
38-
```
39-
40-
- `ASDF_RUBY_BUILD_CACHE_CLEAR` - Bypass the 24-hour cache and fetch the latest version:
41-
```
42-
ASDF_RUBY_BUILD_CACHE_CLEAR=1 asdf list-all ruby
43-
```
34+
```
35+
ASDF_RUBY_BUILD_VERSION=v20240101 asdf install ruby 3.3.0
36+
ASDF_RUBY_BUILD_VERSION=master asdf install ruby 3.3.0
37+
```
4438

4539
## Default gems
4640

@@ -74,7 +68,7 @@ note that you might have to change `.ruby-version` to include full version (e.g.
7468
## Troubleshooting
7569

7670
> [!NOTE]
77-
> If you are not seeing a recent Ruby version, try bypassing the version cache with `ASDF_RUBY_BUILD_CACHE_CLEAR=1 asdf list-all ruby` to fetch the latest ruby-build version. If the version still doesn't appear, check ruby-build's releases at https://github.com/rbenv/ruby-build/releases to see if it's been added yet.
71+
> If you are not seeing a recent Ruby version, check ruby-build's releases at https://github.com/rbenv/ruby-build/releases to see if it's been added yet.
7872
7973
If you are moving to asdf-ruby from another Ruby version manager, it is recommended to completely uninstall the old Ruby version manager before installing asdf-ruby.
8074

lib/utils.sh

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ ruby_build_path() {
8585
echo "$(ruby_build_dir)/bin/ruby-build"
8686
}
8787

88-
ruby_build_version_cache_path() {
89-
echo "$(asdf_ruby_plugin_path)/.ruby-build-version-cache"
90-
}
91-
92-
# Get file modification time in seconds since epoch (cross-platform)
93-
get_file_mtime() {
94-
local file="$1"
95-
# Try GNU stat first (Linux), then BSD stat (macOS)
96-
stat -c %Y "$file" 2>/dev/null || stat -f %m "$file" 2>/dev/null
97-
}
98-
9988
# Fetch the latest ruby-build version tag from GitHub
10089
fetch_latest_ruby_build_version() {
10190
git ls-remote --tags --sort=-version:refname https://github.com/rbenv/ruby-build.git 2>/dev/null |
@@ -104,38 +93,20 @@ fetch_latest_ruby_build_version() {
10493
sed 's|refs/tags/||'
10594
}
10695

107-
# Get the ruby-build version to use, with caching
108-
# Priority: ASDF_RUBY_BUILD_VERSION env var > cached latest > fetched latest > installed version
96+
# Get the ruby-build version to use
97+
# Priority: ASDF_RUBY_BUILD_VERSION env var > fetched latest > installed version
10998
get_ruby_build_version() {
11099
# If user explicitly set a version, use that
111100
if [ -n "${ASDF_RUBY_BUILD_VERSION:-}" ]; then
112101
echo "$ASDF_RUBY_BUILD_VERSION"
113102
return 0
114103
fi
115104

116-
local cache_file
117-
cache_file="$(ruby_build_version_cache_path)"
118-
119-
# Check cache first (unless ASDF_RUBY_BUILD_CACHE_CLEAR is set)
120-
if [ -z "${ASDF_RUBY_BUILD_CACHE_CLEAR:-}" ] && [ -f "$cache_file" ]; then
121-
local cache_mtime current_time age
122-
cache_mtime="$(get_file_mtime "$cache_file")"
123-
current_time="$(date +%s)"
124-
age=$((current_time - cache_mtime))
125-
126-
# Cache for 24 hours
127-
if [ "$age" -lt 86400 ]; then
128-
cat "$cache_file"
129-
return 0
130-
fi
131-
fi
132-
133105
# Fetch latest version from GitHub
134106
local latest_version
135107
latest_version="$(fetch_latest_ruby_build_version)"
136108

137109
if [ -n "$latest_version" ]; then
138-
echo "$latest_version" >"$cache_file"
139110
echo "$latest_version"
140111
return 0
141112
fi

0 commit comments

Comments
 (0)