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

.bash_profile content deleted #6281

Closed
jandubois opened this issue Jan 7, 2024 · 11 comments · Fixed by #6352
Closed

.bash_profile content deleted #6281

jandubois opened this issue Jan 7, 2024 · 11 comments · Fixed by #6352
Assignees
Labels
kind/bug Something isn't working priority/1 Work should be fixed for next release
Milestone

Comments

@jandubois
Copy link
Member

jandubois commented Jan 7, 2024

I've experienced this before on Dec 18, but it has since happened 3 more times this Friday (5-Jan-2024): After a factory-reset, and restarting Rancher Desktop with automatic PATH management enabled, my ~/.bash_profile was replaced with an empty file that just had the Rancher Desktop boilerplate:

$ cat ~/.bash_profile
### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
export PATH="/Users/jan/.rd/bin:$PATH"
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)

Once I perform another factory-reset, the file gets deleted completely because it is now empty.

I use symlinks into Dropbox for ~/.bash_profile (and ~/.bashrc):

$ ls -ld ~/.bash*
-rw-------   1 jan  staff   13706  7 Jan 14:24 /Users/jan/.bash_history
lrwxr-xr-x   1 jan  staff      35  7 Jan 14:23 /Users/jan/.bash_profile -> /Users/jan/Dropbox/dot/bash_profile
drwx------  14 jan  staff     448 16 Sep  2020 /Users/jan/.bash_sessions
lrwxr-xr-x   1 jan  staff      35  7 Jan 14:23 /Users/jan/.bashrc -> /Users/jan/Dropbox/dot/bash_profile

It is the symlink that gets deleted on the second factory-rest.

Since the older version is still on Dropbox, it is simple to restore. Here are some screenshots from when it happened:

CleanShot 2023-12-18 at 17 06 23@2x

CleanShot 2024-01-05 at 10 50 23@2x

CleanShot 2024-01-05 at 14 12 29@2x

CleanShot 2024-01-05 at 21 27 28@2x

The very last screenshot is from an instance that used manual path management, so the factory-reset didn't remove the path management logic because it was never added to the file. Still on a restart the file was overwritten.

I sometimes didn't discover that .bash_profile was destroyed until later (when I had to create a new terminal window), so I'm not sure if this is really true, but I believe this always happened when I initiated the factory-reset from the GUI, and restarted the app (via a hotkey) immediately once the window was closed (this was part of QASE testing, where many test cases ask for a factory-reset followed by a restart).

I've not been able to reliably reproduce the problem, even though it happened 3 times this Friday.

Open questions

  1. Is this related to having .bash_profile stored as a symlink?
  2. Is this related to having the symlink point to Dropbox?
  3. Is this related to having both .bashrc and .bash_profile symlink to the same file?
  4. Does it matter that each time the app was restarted immediately after the facory reset?

Candidate?

After looking through the sources, the only way I can see this happening is if fs.promises.stat('~/.bash_profile') returned ENOENT (or if os.homedir() did return an incorrect value):

// If none of the files exist, write .bash_profile
if (!linesAdded) {
const filePath = path.join(os.homedir(), bashLoginShellFiles[0]);
await manageLinesInFile(filePath, [pathLine], desiredPresent);
}

But the file exists, and I don't see how HOME could not be set correctly, so this still doesn't make sense.

@jandubois jandubois added kind/bug Something isn't working priority/1 Work should be fixed for next release labels Jan 7, 2024
@gaktive
Copy link
Contributor

gaktive commented Jan 8, 2024

@mook-as to help here to see what could be going on.

@jandubois
Copy link
Member Author

And it happened again:

CleanShot 2024-01-08 at 14 39 52@2x

@jandubois jandubois added this to the 1.13 milestone Jan 8, 2024
@jandubois jandubois self-assigned this Jan 8, 2024
@jandubois
Copy link
Member Author

I just noticed that at the Friday, January 5th timestamp at 10:40am my ~./zshrc file also got truncated (it too is a symlink into Dropbox):

CleanShot 2024-01-08 at 17 09 33@2x

@nwwells
Copy link

nwwells commented Jan 12, 2024

This happened to me on my work computer where I had not backed up my dot files yet. I'm a ZSH user, so in my case my .zshrc was wiped.

@jandubois
Copy link
Member Author

@nwwells Thanks for letting us know! Is there anything unusual about your ~/.zshrc in any way? Is it a symlink, like mine? If yes, does it point to Dropbox/iCloud/Google Drive/OneDrive or similar?

@nwwells
Copy link

nwwells commented Jan 12, 2024 via email

@DanielSchranc
Copy link

Hello...this has happened to me too. I installed rancher desktop with automatic PATH enabled and then it has overwritten everything I had in my bash_profile with the rancher desktop PATH

@pplanel
Copy link

pplanel commented Jan 17, 2024

I just lost my .*rc to this app. Really disappointing...

@hopsor
Copy link

hopsor commented Jan 17, 2024

I experienced the same losing my .zshrc :-/

@Cutieguwu
Copy link

Wiped my .bashrc and .bashprofile, had to restore from backup.

I don't use .zshrc (at least I don't think I do), but it didn't wipe that for me and actually appended properly.

@jandubois jandubois linked a pull request Jan 22, 2024 that will close this issue
@jandubois jandubois modified the milestones: 1.13, 1.13.2 Jan 22, 2024
@jandubois
Copy link
Member Author

This issue is a regression from Rancher Desktop 1.11. It is a race condition that happens after either a fresh install or a factory reset, when the first-run dialog is closed again very quickly after it is displayed.

The problem has been fixed in #6352 and will be released in a 1.12.2 patch release in the next day or two, once it has passed further testing.

Sorry for not catching this regression in time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working priority/1 Work should be fixed for next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants