wayneeseguin/rvm — Issue #665: 1.10.0 __rvm_ensure_has_environment_files() doesn't force clobber
Author: kliuless
Created: 2011-12-27 17:21:00+00:00
State: open

Symptoms: after upgrading rvm from 1.6 to 1.10, then switching to already-installed rubies, I see bash errors "cannot overwrite existing file"

I have noclobber enabled in bash, and by tracing executiion, I found this line to be the cause.

```bash
printf "export PATH ; PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"\n" \
> "$file_name"
```

However, the other writes are succeeding because they are appends. The resulting file is my old environment file with newly appended lines.
To force a clobber, please use greater-than with a pipe as mentioned on the bash manpage: >|

Even better, would be to rename the file to a backup, inform the user, then create the new file. Otherwise any customizations are lost.