Skip to content
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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Improve clarity of dotfile edits #4054

wants to merge 18 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 31, 2017

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 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 PR fixes reduces that confusion, by noting, for each edit some 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.

Sam Pablo Kuper added 2 commits May 31, 2017 15:55
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
@pkuczynski
Copy link
Member

This is only for ~/.bash_profile. How about the other files we modify?

@@ -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
Copy link
Member

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...

Copy link
Author

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.

# this file if it did not already exist).
#########
#
# Add RVM to PATH for scripting. Ensure this is the last PATH variable change.
Copy link
Member

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".

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. Will push shortly.

@ghost
Copy link
Author

ghost commented May 31, 2017

@pkuczynski wrote:

This is only for ~/.bash_profile.

I don't think so. It should apply to all dotfiles in the search_list.

@pkuczynski
Copy link
Member

Indeed, had a look on the too small part of the file, sorry...

@pkuczynski
Copy link
Member

Waiting for @mpapis review before merge...

Sam Pablo Kuper added 2 commits May 31, 2017 16:13
# 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
Copy link
Member

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" :)

Copy link
Author

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 :)

Copy link
Member

Choose a reason for hiding this comment

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

Did you try ${rvm_version}?

If that does not work we might need to wait until my PR #4043 is reviewed by @mpapis and merged.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Edit pushed.

@@ -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
Copy link
Member

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?

Copy link
Author

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

Copy link
Author

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 :)

@pkuczynski
Copy link
Member

@mpapis any feedback on this?

Copy link
Member

@mpapis mpapis left a 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?

###############################################################################
# At $(date --iso-8601=s), the RVM ${rvm_version} created
# this code block (and also this file, if it did not already exist).
#########
Copy link
Member

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 :)

Copy link
Author

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

Copy link
Member

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.

@pkuczynski
Copy link
Member

@mpapis in which other places you would like something like this to be added?

@mpapis
Copy link
Member

mpapis commented Jun 16, 2017

scripts/functions/installer in the setup_user_profile_login just after rvm_out "Adding rvm loading line to ${target_login[*]}."

there are other implications, when we run with --auto-dotfiles it will accumulate the comments, please try: ./install --auto-dotfiles to check it locally.

@pkuczynski
Copy link
Member

Indeed multiple runs duplicate the info entry. I am working on a solution for this issue.

Copy link
Member

@pkuczynski pkuczynski left a comment

Choose a reason for hiding this comment

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

Work in progress...

@pkuczynski pkuczynski changed the title Give clarity to code block installed to dot-files Improve clarity of dotfile edits Jul 2, 2017
@pkuczynski
Copy link
Member

pkuczynski commented Jul 2, 2017

@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?

pkuczynski
pkuczynski previously approved these changes Jul 2, 2017
@pkuczynski pkuczynski added this to the rvm-1.29.3 milestone Jul 2, 2017
@@ -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" )
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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 :(

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

setup_user_profile_rc
setup_user_profile_login
if
(( rvm_auto_dotfiles_flag == 1 ))
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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'
Copy link
Member

Choose a reason for hiding this comment

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

👍

@pkuczynski pkuczynski modified the milestones: rvm-1.29.3, rvm-1.29.4 Sep 14, 2017
@saizai
Copy link
Contributor

saizai commented Apr 14, 2018

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".

@pkuczynski pkuczynski modified the milestones: rvm-1.29.4, rvm-1.29.5 Sep 23, 2018
@pkuczynski pkuczynski modified the milestones: rvm-1.29.5, rvm-1.29.7 Dec 12, 2018
@pkuczynski pkuczynski modified the milestones: rvm-1.29.7, rvm-1.29.8 Jan 3, 2019
@pkuczynski pkuczynski modified the milestones: rvm-1.29.8, rvm-1.29.9 May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add clarity to dotfile edits
4 participants