-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve clarity of dotfile edits #4054
base: master
Are you sure you want to change the base?
Conversation
The RVM installer edits several dot-files (and creates them, if they do not already exist). It can be confusing for a user to find dot-files in their home directory for shells they have never installed (e.g. .mkshrc, if they are not a mksh user). It can also be hard for a novice user to know which edits to their dot-files were made by what, when, and why. This commit fixes that confusion, by noting, for each edit: - that the RVM installer made the edit - when the RVM installer made the edit - the extent of the edit, using octothorpes as delimiters. Layout loosely inspired by examples such as: https://github.com/syl20bnr/spacemacs/blob/master/core/templates/.spacemacs.template https://github.com/nicksp/dotfiles/blob/master/shell/bash_profile
This is only for ~/.bash_profile. How about the other files we modify? |
scripts/functions/installer
Outdated
@@ -1100,8 +1100,15 @@ setup_user_profile_rc() | |||
do | |||
touch "$profile_file" | |||
printf "%b" " | |||
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. | |||
############################################################################### | |||
# At $(date --iso-8601=s), the RVM installer added this block (and also created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably add RVM version in here too: RVM 1.29.1 installer
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably add RVM version in here too:
RVM 1.29.1 installer
Sounds good. Will push another commit shortly.
scripts/functions/installer
Outdated
# this file if it did not already exist). | ||
######### | ||
# | ||
# Add RVM to PATH for scripting. Ensure this is the last PATH variable change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could be written in a more clear way, don't you think? Maybe "Include RVM in the PATH. Ensure it is always at the end of the PATH".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Will push shortly.
@pkuczynski wrote:
I don't think so. It should apply to all dotfiles in the |
Indeed, had a look on the too small part of the file, sorry... |
Waiting for @mpapis review before merge... |
As suggested here: #4054 (comment)
As proposed here: #4054 (comment)
scripts/functions/installer
Outdated
# this file if it did not already exist). | ||
# At $(date --iso-8601=s), this code block (and also this file, if it did not | ||
# already exist) was created by: | ||
# $__rvm_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I somehow liked more when it said "RVM 1.29 installed" :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree :) I couldn't immediately see an easy, robust way to achieve that, though. If you know a better mechanism than using $__rvm_version
, let me know :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Edit pushed.
scripts/functions/installer
Outdated
@@ -1100,8 +1100,15 @@ setup_user_profile_rc() | |||
do | |||
touch "$profile_file" | |||
printf "%b" " | |||
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. | |||
############################################################################### | |||
# At $(date --iso-8601=s), the RVM ${rvm_version} created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried if that works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically. Any reason why it wouldn't?
$ echo $rvm_version
$ rvm_version='1.2.3'
$ echo "At $(date --iso-8601=s), the RVM Installer from RVM ${rvm_version} created"
At 2017-05-31T20:49:11+0100, the RVM Installer from RVM 1.2.3 created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I'm not familiar with these steps that would seem necessary for fully testing:
- Uninstalling RVM (probably easy, but maybe time-consuming)
- Installing RVM from the branch this PR is based on (trickier)
I'm afraid I can't really put any more time into the matter at the moment either, sorry :( I hope that what I've contributed so far is helpful and can make it into RVM once it has been tested/approved/tweaked by you and @mpapis .
Thanks for maintaining RVM and for your great feedback on this PR :)
@mpapis any feedback on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, should we add the same message in other places like when we add source
lines?
scripts/functions/installer
Outdated
############################################################################### | ||
# At $(date --iso-8601=s), the RVM ${rvm_version} created | ||
# this code block (and also this file, if it did not already exist). | ||
######### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this separator :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea with the separators is this:
########################### <- First long separator indicates start of hunk inserted by rvm
# rvm should put explanation here
### <- Short separator visually separates end of explanation from start of script snippet
rvm should put snippet here
########################### <- Second long separator indicates end of hunk inserted by rvm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to have the short separator.
@mpapis in which other places you would like something like this to be added? |
there are other implications, when we run with |
Indeed multiple runs duplicate the info entry. I am working on a solution for this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Work in progress...
@mpapis this is finally done I believe! I reversed some of the changes to ensure backward compatibility with the entries added by the previous versions of RVM. Also refactored and simplified some code. From my point of view its ready for merge. Unless you want to veto it? |
@@ -1019,150 +1021,175 @@ setup_user_profile_check() | |||
setup_user_profile_detect() | |||
{ | |||
etc_profile_file="/etc/profile.d/rvm.sh" | |||
search_list_mksh=( "$HOME/.mkshrc" "$HOME/.profile" ) | |||
search_list_bash=( "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.bash_login" ) | |||
search_list_zsh=( "${ZDOTDIR:-${HOME}}/.zshenv" "${ZDOTDIR:-${HOME}}/.zprofile" "${ZDOTDIR:-${HOME}}/.zshrc" "${ZDOTDIR:-${HOME}}/.zlogin" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for limiting the list, my idea with all the files was that user can have sourcing/PATH line in any of them as long as it solves their needs, then the code was detecting which entries were already set up and not installing needlessly in other file which we think is more appropriate for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The different list was used for searching and different for adding. But then they were merged anyway. So I simplified this and use only one list now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I can not find list of the previous files :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In newer UNIXes aren't used anymore
scripts/functions/installer
Outdated
setup_user_profile_rc | ||
setup_user_profile_login | ||
if | ||
(( rvm_auto_dotfiles_flag == 1 )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean that we will not add the sourcing/PATH lines automatically on fresh install if user does not pass --auto-dotfiles
flag? This can increase amount of dissatisfied users with not working setup because of missing this lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously condition for adding was:
if (( rvm_auto_dotfiles_flag == 1 || ${#found_rc[@]} == 0 ))
so I felt that we are not making a change in functionality, but you are right. It's mistake. I will remove the rvm_auto_dotfiles_flag
as in the new code we re-add the lines on every install, as I think it simplifies the code a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we keep updating the line at every install it might mess up things? what if user adds something that depends on RVM and we move our code after his addition?
then | ||
found_login+=( "$profile_file" ) | ||
rvm_debug "Removing RVM info line from ${file}" | ||
__rvm_sed_i "$file" -e '/RVM BEGIN$/,/RVM END$/d' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
One note: I've occasionally found duplicate rvm lines in dotfiles. Would be nice if it cleaned up old ones, or if not doing differently just tweaked them with a "rechecked at date X, nothing to change since added at date Y". |
Fixes #4053
The RVM installer edits several dot-files (and creates them, if they do not already exist). It can be confusing for a user to find dot-files in their home directory for shells they have never installed (e.g.
.mkshrc
, if they are not amksh
user). It can also be hard for a novice user to know which edits to their dot-files were made by what, when, and why.This PR
fixesreduces that confusion, by noting, foreach editsome edits:The other edits made to those files by the installer (e.g. by lines like
printf "%b" "\ntest -f ${etc_profile_file} && source ${etc_profile_file}\n" > $zshrc_file
) will require additional work (e.g. in a separate pull request, or as additions to this one) to indicate as having been made by the installer. I don't have time to address all of those at the moment, but it would be good for RVM to have these improvements made at some point.