Skip to content

Commit

Permalink
Removed global gem caching.
Browse files Browse the repository at this point in the history
Excellent idea, however, it does not work for all use cases.
  • Loading branch information
wayneeseguin committed May 27, 2010
1 parent 215d9a3 commit cee66c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
14 changes: 7 additions & 7 deletions scripts/gemsets
Expand Up @@ -23,7 +23,6 @@ __rvm_gemset_create() {
for gemset in $(echo $gems_args) ; do
gem_home="${rvm_ruby_gem_prefix}${rvm_gemset_separator}${gems_args/ /}"
mkdir -p $gem_home
ln -nfs "$HOME/.gem/cache" "$gem_home/cache"
$rvm_scripts_path/log "info" "Gemset '$gemset' created."
done ; unset gem_home
}
Expand Down Expand Up @@ -55,7 +54,8 @@ __rvm_gemset_delete() {
echo -n "(anything other than 'yes' will cancel) > "
read response
if [[ "yes" = "$response" ]] ; then
rm -f $gemdir/cache && rm -rf $gemdir
rm -f $gemdir/cache 2>/dev/null
rm -rf $gemdir
else
$rvm_scripts_path/log "info" "Not doing anything, phew... close call that one eh?"
fi
Expand Down Expand Up @@ -237,10 +237,10 @@ __rvm_gem_install() {
else
if [[ -s "$gem" ]] ; then
cache_file="$gem"
elif [[ -s "$rvm_gems_path/cache/${gem_file_name}" ]] ; then
cache_file="$rvm_gems_path/cache/${gem_file_name}"
elif [[ -s "$rvm_ruby_gem_home/cache/${gem_file_name}" ]] ; then
cache_file="$rvm_ruby_gem_home/cache/${gem_file_name}"
else
cache_file="${cache_file:-$(\ls ${rvm_gems_path}/cache/${gem_file_name} 2> /dev/null | sort | head -n1)}"
cache_file="${cache_file:-$(\ls ${rvm_ruby_gem_home}/cache/${gem_file_name} 2> /dev/null | sort | head -n1)}"
fi

if [[ ! -s "$cache_file" ]] ; then
Expand All @@ -259,9 +259,9 @@ __rvm_gem_install() {
unset gem # already installed, not forcing reinstall.
$rvm_scripts_path/log "info" "$gem_name $gem_version exists, skipping (--force to re-install)"
else
if [[ -s "$rvm_gems_path/cache/$(basename $gem_file_name)" ]] ; then
if [[ -s "$rvm_ruby_gem_home/cache/$(basename $gem_file_name)" ]] ; then
mkdir -p "$rvm_tmp_path/$$/"
mv "$rvm_gems_path/cache/$gem_file_name" "$rvm_tmp_path/$$/$gem_file_name"
mv "$rvm_ruby_gem_home/cache/$gem_file_name" "$rvm_tmp_path/$$/$gem_file_name"
gem="$rvm_tmp_path/$$/$gem_file_name -f -l"
else
gem="$cache_file"
Expand Down
2 changes: 0 additions & 2 deletions scripts/rvm
Expand Up @@ -7,8 +7,6 @@
if [[ "$rvm_loaded_flag" != "1" ]] || [[ "$rvm_reload_flag" = "1" ]] ; then
unset rvm_reload_flag

mkdir -p $HOME/.gem/cache

for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
if [[ -f "$rvmrc" ]] ; then
if grep -q '^\s*rvm .*$' $rvmrc ; then
Expand Down
22 changes: 3 additions & 19 deletions scripts/utility
Expand Up @@ -489,25 +489,9 @@ __rvm_gemset_select() {

rvm_ruby_gem_path="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"

# Careful not to nuke system gems cache.
if [[ ! -z "$rvm_ruby_gem_home" ]] && [[ ! -z "$(echo $rvm_ruby_gem_home | awk '/rvm/')" ]] ; then
# Ensure that the ruby gem home exists.
mkdir -p "$rvm_ruby_gem_home"

# If there is a cache *directory* already,
# move all the gems to the global cache directory and remove it.
if [[ -d "$rvm_ruby_gem_home/cache" ]] && [[ ! -L "$rvm_ruby_gem_home/cache" ]] ; then
if [[ ! -z "$(\ls -A "$rvm_ruby_gem_home"/cache/)" ]] ; then
mv "$rvm_ruby_gem_home"/cache/* "$HOME"/.gem/cache/
fi
rmdir "$rvm_ruby_gem_home"/cache
fi

# If the ruby's gems cache directory is not a symlink to the global cache, symlink it
if [[ ! -L "$rvm_ruby_gem_home/cache" ]] ; then
ln -nfs "$HOME/.gem/cache" "$rvm_ruby_gem_home/cache"
fi
fi ; export rvm_ruby_gem_path rvm_ruby_gem_home
# Ensure that the ruby gem home exists.
mkdir -p "$rvm_ruby_gem_home"
export rvm_ruby_gem_path rvm_ruby_gem_home
}

# Use a gemset specified by 'rvm_ruby_gem_home'
Expand Down

3 comments on commit cee66c1

@stevenh512
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to make this configurable? I have a lot of gems that I use in several different gemsets but don't want in my @global. It makes sense in that case to have multiple installed copies of the gem (one for each gemset where it's used), but I don't see any reason why I would want multiple cached copeis of the .gem file.

@wayneeseguin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it would be possible but a great deal of work to make it configurable.

The common cache caused issues for tools like Bundler and others, so it seemed the best way was to not make any assumptions on my end.

That said, It could be made an option to have RVM go through and symlink the cache directories on request, does that sound like it would address your issue?

@stevenh512
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me..

Please sign in to comment.