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

[Bug] Scoop checking ~/scoop instead of custom dir after update #4918

Closed
RavenMacDaddy opened this issue May 12, 2022 · 9 comments · Fixed by #4960 or #4982
Closed

[Bug] Scoop checking ~/scoop instead of custom dir after update #4918

RavenMacDaddy opened this issue May 12, 2022 · 9 comments · Fixed by #4960 or #4982
Labels

Comments

@RavenMacDaddy
Copy link

Bug Report

Current Behavior

Ran 'scoop update *', the app was updated to v0.2.0, tried running 'scoop list' and it returned 'no apps installed'.

Tried other commands and noticed hints to it looking in my Users dir.

Checked environment variables and noticed SCOOP was completely vanished.

Luckily, the app is otherwise very stable, so manually adding it again and pointing it to the desired dir fixed everything.

Expected Behavior

Updating Scoop to a new version should not result in the environment variables getting erased.

Additional context/output

I'm using a custom dir for my Scoop installation.

Possible Solution

Finding the technical cause to the environment variable getting erased.

System details

Windows version: 11 - 22000.613

OS architecture: 64bit

PowerShell version: 7.2.3

Additional software:

Other tools like MSYS2 always show warnings cause I've a Kaspersky security product, though I've never ran into any issues while running that shell or anything else - no conflicts detected while updating, and everything seemed normal till I was attempting my next command as described above.

Scoop Configuration

//# Your configuration here

{
  "rootPath": "F:\\Backup\\Scoop",
  "lastUpdate": "2022-05-12T19:24:06.4048137+02:00",
  "aria2-warning-enabled": false,
  "MSIEXTRACT_USE_LESSMSI": true,
  "SCOOP_REPO": "https://github.com/ScoopInstaller/Scoop",
  "SCOOP_BRANCH": "master"
}
@rashil2000
Copy link
Member

That's strange, I don't think the codebase has any code to erase/reset the SCOOP variable - it only reads it if found. Something else must be at play...

@rashil2000 rashil2000 changed the title [Bug] Updating to v0.2.0 erased the environment variable [Bug] Scoop checking ~/scoop instead of custom dir after update May 12, 2022
@Vedabahu
Copy link

Bug Report

Current Behavior

Instead of looking in the custom directory of scoop, it is looking in C:\Users\Users\Scoop\ and giving me error. I tried removing scoop and reinstalling it. Showing the same problem.
scoop help Output:
image

Expected Behavior

Look for buckets and all installs directly in the desired directory as in scoop's config.json file.

System details

Windows version: 7

OS architecture: 64bit

PowerShell version:

PS D:\Vedabahu\Scoop> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      2      3

Scoop Configuration

{
  "lastUpdate": "2022-05-12T23:26:56.2305288+05:30",
  "rootPath": "D:\\Vedabahu\\Scoop\\Scoop",
  "globalPath": "D:\\Vedabahu\\Scoop\\ScoopGlobal",
  "cachePath": "D:\\Vedabahu\\Scoop\\ScoopCache",
  "SCOOP_REPO": "https://github.com/ScoopInstaller/Scoop",
  "SCOOP_BRANCH": "master",
  "aria2-split": 16,
  "aria2-max-connection-per-server": 16,
  "aria2-warning-enabled": false,
  "MSIEXTRACT_USE_LESSMSI": true,
  "aria2-enabled": true
}

System Details:
Windows 7 Ultimate v6.1 SP1
Build 7601

@Vedabahu
Copy link

I found a workaround. If we install without the Environment Variables using scoop installer, scoop will later look for the ~\scoop directory. It wont check the config file for root dir, cache dir and global dir.

If i set the environment variables, it works properly.

@ghost
Copy link

ghost commented May 13, 2022

Not much of a workaround when you've already got several gigabytes installed. It would be nice if such breaking changes were announced in advance.

@rashil2000
Copy link
Member

There's no breaking change: this is a bug. Will need to investigate further.

As mentioned in the top comment, manually readding the variable fixes the error.

@sprgchma
Copy link
Contributor

There is bug in the lib/core.ps1: the code uses the configuration before loading it:

The error gone when I moved these lines https://github.com/ScoopInstaller/Scoop/blob/master/lib/core.ps1#L1125-L1136 directly after the Optimize-SecurityProtocol invocation at https://github.com/ScoopInstaller/Scoop/blob/master/lib/core.ps1#L1110

@rashil2000
Copy link
Member

The source of error might be something else, because the code you mentioned hasn't been touched in 3 years...

image

@sprgchma
Copy link
Contributor

@rashil2000 I think the culprit is this commit 6296822.

Step-by-step

  • The error manifests itself in a situation when the scoop dir has non-default value given by the rootDir is the configuration file. It is true for my case and for the case of @RavenMacDaddy
  • Judging from the name of commit ("Load libs only once") the core.ps1 was loaded at least twice originally
  • And during the second load the $scoopConfig was defined by the first one - so $scoopdir and other variables got their value from the config!
  • It seems fixing the "multiple-loads" bug reveals this particular "use-config-before-load" incorrect behaviour.

@rashil2000
Copy link
Member

Wow, you're right. Nice observation!

The error gone when I moved these lines https://github.com/ScoopInstaller/Scoop/blob/master/lib/core.ps1#L1125-L1136 directly after the Optimize-SecurityProtocol invocation at https://github.com/ScoopInstaller/Scoop/blob/master/lib/core.ps1#L1110

Can you make a PR for this?

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