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

Reinstate 'current' junctions as a part of scoop reset #4573

Closed
hgkamath opened this issue Dec 9, 2021 · 16 comments · Fixed by #5031
Closed

Reinstate 'current' junctions as a part of scoop reset #4573

hgkamath opened this issue Dec 9, 2021 · 16 comments · Fixed by #5031

Comments

@hgkamath
Copy link

hgkamath commented Dec 9, 2021

Bug Report

Package Name: [name of package which has bug(s)]
scoop

Current Behaviour

Scoop uses a NTFS-directory-junction 'current` to point to the active-version of an app.
The NTFS junction is absolute.
Hence when scoop is xcopy-ed into a VHDX and remounted on another windows-OS installation, the scoop root folder may not be in exactly the same location. (```xcopy /H /E /B /O /K /Y src dst```)
As a result powershell-function ```app_status()``` is not able to descend into the junction to retrieve the installed manifest,json and hence scoop list throws an error .

PS C:\vol\scoop_01\scoop\apps\scoop\current\lib> scoop list
Installed apps:

  7zip 21.06 *global* [main]
  adb  *global* *failed*
  android-sdk  *global* *failed*
  anki  *global* *failed*
  blender  *global* *failed*
  colortool  *global* *failed*
  doublecmd  *global* *failed*

The NTFS-directory-junction contains path from the other operating system, which is invalid on the new one.
Hence, errors.

Expected Behaviour

Scoop should still work when copied for portability sake, instead of requiring user to install applications afresh

Perhaps instead of NTFS-junction, consider using

  • symbolic link mklink /d current 21.06
    Junction-links are always absolute, when copied point to the original mount path, environment variables cannot be embedded.

I want scoop to be

  • located on a VHDX/partition etc,
  • be mounted anywhere by any of a multi-boot multi-windows operating systems.

Workaround

  • mount the VHDX/partition in exactly same path on each windows operating system such as C:\vol\scoop_01\scoop
  • include a small script to fix the junctions, in a manner similar to scoop reset

Additional context/output

Possible Solution

  • use symbolic links?

System details

Windows version: [e.g. 7, 8, 10]
Windows-10 and Windows-11

OS architecture: [e.g. 32bit, 64bit]
64-bit

PowerShell version: [output of "$($PSVersionTable.PSVersion)"]
PS C:\Users\admin> echo $PSVersionTable

Name Value
PSVersion 5.1.22000.282
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.282
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Additional software: [(optional) e.g. ConEmu, Git]

@hgkamath hgkamath added the bug label Dec 9, 2021
@hgkamath
Copy link
Author

hgkamath commented Dec 9, 2021

PS C:\vol\scoop_01\scoopg\apps\adb> Get-Item .\current | Format-List


    Directory: C:\vol\scoop_01\scoopg\apps\adb



Name           : current
CreationTime   : 12/10/2021 12:01:06 AM
LastWriteTime  : 8/21/2021 7:56:55 PM
LastAccessTime : 12/10/2021 12:01:06 AM
Mode           : d----l
LinkType       : Junction
Target         : {E:\SCOOPG\apps\adb\31.0.3}

PS C:\vol\scoop_01\scoopg\apps>  Get-ChildItem -Directory | ForEach-Object { cd $_.Name; echo === $_.Name ; $trg=(Get-Item .\current).Target; echo "OldTarg=$trg" ; $op = New-Item -ItemType SymbolicLink -Path current2 -Value (Split-Path -Leaf $trg) ; (Get-Item(".\current\")).Delete()  ; Rename-Item .\current2 .\current ; echo "NewTarg=$((Get-Item .\current).Target)" ; echo "---" ; cd .. }
===
7zip
OldTarg=C:\vol\scoop_01\scoopg\apps\7zip\21.06
NewTarg=C:\vol\scoop_01\scoopg\apps\7zip\21.06
---
===
adb
OldTarg=E:\SCOOPG\apps\adb\31.0.3
NewTarg=C:\vol\scoop_01\scoopg\apps\adb\31.0.3
---
===
android-sdk
OldTarg=E:\SCOOPG\apps\android-sdk\4333796
NewTarg=C:\vol\scoop_01\scoopg\apps\android-sdk\4333796
---
===
anki
OldTarg=E:\SCOOPG\apps\anki\2.1.49
NewTarg=C:\vol\scoop_01\scoopg\apps\anki\2.1.49
---
===
blender
OldTarg=E:\SCOOPG\apps\blender\2.93.6
NewTarg=C:\vol\scoop_01\scoopg\apps\blender\2.93.6
---
===
colortool
OldTarg=E:\SCOOPG\apps\colortool\1904.29002
NewTarg=C:\vol\scoop_01\scoopg\apps\colortool\1904.29002
---
===
doublecmd
OldTarg=E:\SCOOPG\apps\doublecmd\1.0.1
NewTarg=C:\vol\scoop_01\scoopg\apps\doublecmd\1.0.1
---

PS C:\vol\scoop_01\scoopg\apps> scoop list
Installed apps:

  7zip 21.06 *global* [main]
  adb 31.0.3 *global* [main]
  android-sdk 4333796 *global* [extras]
  anki 2.1.49 *global* [extras]
  blender 2.93.6 *global* [extras]
  colortool 1904.29002 *global* [main]
  doublecmd 1.0.1 *global* [extras]

@rashil2000
Copy link
Member

rashil2000 commented Dec 10, 2021

Symbolic links cannot be created without admin access , and do not exist for Windows 7 and 8. This goes against Scoop's philosophy.

@rasa
Copy link
Member

rasa commented Dec 10, 2021

Symbolic links cannot be created without admin access,

Sorta no longer true. See https://www.howtogeek.com/292914/what-is-developer-mode-in-windows-10/ :

In Windows 10’s Creators Update, putting your device into developer mode relaxes restrictions on creating symbolic links. Previously, it was only possible for Administrator users to create symlinks. This is still the case on Windows 10—unless you put it into Developer Mode.

In Developer Mode, a user account with any level of privileges can create symbolic links. In other words, you can open a normal Command Prompt window and use the mklink command. Outside of Developer Mode, you’d need to open a Command Prompt window as Administrator before using the mklink command.

Symbolic links are often used by developers, so this change makes it possible for development tools to create and work with symbolic links without having to run as Administrator.

@rashil2000
Copy link
Member

rashil2000 commented Dec 10, 2021

Yes, but you need an admin to enable that Developer Mode (one time setup) in the first place, if I remember correctly, which brings us back to square one.

@hgkamath
Copy link
Author

hgkamath commented Dec 10, 2021

okay.

I can't find the log as to what sent me down this path as has scrolled off my terminal buffer.

But, I think it was because either scoop reset * did not work for me, or I was worried it was going to do a re-download all apps and reinstall everything.

The below is one of my earliest trouble shooting logs

PS C:\Users\admin> scoop info 7zip
Name: 7zip
Description: A multi-format file archiver with high compression ratios
Version: 21.06
Website: https://www.7-zip.org/
License: Freeware,LGPL-2.0-only,BSD-3-Clause (https://www.7-zip.org/license.txt)
Manifest:
  C:\vol\scoop_01\scoop\buckets\main\bucket\7zip.json
Installed: No
Binaries:
  7z.exe
Notes
-----
Add 7-Zip as a context menu option by running: "C:\vol\scoop_01\scoopg\apps\7zip\current\install-context.reg"

The above snipped was clue-ing me that scoop thinks that the app is not installed, and then it was a matter of troubleshooting why it was able to get some of the info by reading the libexec/scoop-info.ps1 file.

Firstly don't assume me to be an expert on NTFS junctions. As you mention you need to be very careful study and weigh each type of link before you choose, in order to ensure backward compatibility, and remain consistent with scoop-philosophy which I also like and support.

The powershell script that I typed in #4573 (comment) fixed all the current junctions and then I was able to do a scoop reset

Junction repair is a one time work.

So maybe just having scoop being able fix its junctions is all that is needed.

@rashil2000
Copy link
Member

The powershell script that I typed in #4573 (comment) fixed all the current junctions and then I was able to do a scoop reset

Junction repair is a one time work.

So maybe just having scoop being able fix its junctions is all that is needed.

Yes, that seems to be a reasonable request - that's why I didn't close this issue :)

Would you like to submit a PR? We can repair junctions as a part of scoop-reset, with an optional (off by default) flag.

@hgkamath
Copy link
Author

I appreciate you for trying to let me make a developer contribution. But it would be more exigent if an expert coder like you do it and take full-credits for it.

If i had to do it, I'd have to get my setup to do more testing, get more intimate with the code base, make decision points as to where it has to go and rewrite the code from a goofy-one-liner to a formal coding style and do error handling and all that. Thx though.

@rashil2000 rashil2000 changed the title Consider something else other than NTFS junction for increased portability Reinstate 'current' junctions as a part of scoop reset Dec 10, 2021
@niheaven
Copy link
Member

niheaven commented Dec 10, 2021

Could you try to disable current junction? Use scoop config NO_JUNCTIONS true and there will be no current folder at all.

And, since this is rare use case, please report any problem that you may meet.

@dwettstein
Copy link

@niheaven , when using NO_JUNCTIONS the following issues occur:

Relates #3655

@niheaven
Copy link
Member

Thanks, we will check these issues.

@niheaven niheaven added bug and removed enhancement labels Dec 14, 2021
@quantuumsnot
Copy link

WRONG!

  1. I'm on Win 8 and they are here, what a surprise
  2. Show us statistics about how many home/advanced/pro/power/etc users are working on their computers with limited accounts

@rashil2000
Copy link
Member

  1. I'm on Win 8 and they are here, what a surprise

Thanks for the info. Updated my comment.

  1. Show us statistics about how many home/advanced/pro/power/etc users are working on their computers with limited accounts

Scoop collects no information. See #3781.

@quantuumsnot
Copy link

And my question was out of Scoop's features, but in general. Whatever

@rashil2000
Copy link
Member

Why are you asking here if it's out of Scoop's scope?

@quantuumsnot
Copy link

Because it's directly connected about how software should be written when there's a plausibility of something not working due to user permissions

@rashil2000
Copy link
Member

Closed in #4720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants