ScoopInstaller / Scoop

A command-line installer for Windows.
https://scoop.sh
Other
21.35k stars 1.41k forks source link

[Bug] .jar shims change the working directory when running from cmd #6026

Open davidpatel0 opened 5 months ago

davidpatel0 commented 5 months ago

Bug Report

Current Behavior

.jar shims change the current working directory to the package directory when running from cmd.

Expected Behavior

shims should not change the working directory

Additional context/output

for example, install apktool: scoop install main/apktool and then run apktool in cmd:

C:\>apktool --version
2.9.3

C:\Users\User\scoop\apps\apktool\current>

When running from powershell this doesn't happen for some reason.

The cause of this is https://github.com/ScoopInstaller/Scoop/blob/d337bb1fa69a56637101254a1ac9e0ad13a12647/lib/core.ps1#L1012-L1018

I think cd shouldn't be used anywhere in shims.

System details

Windows version: 11

OS architecture: 64bit

PowerShell version: 5.1.22621.3672

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

Scoop Configuration

{
    "last_update":  "2024-06-23T08:09:07.4455297+03:00",
    "scoop_branch":  "master",
    "scoop_repo":  "https://github.com/ScoopInstaller/Scoop"
}
davidpatel0 commented 5 months ago

Another problem that this approach (modifying the working directory) causes: using relative paths with .jar shims is broken (as they are being resolved from scoop\apps\X directory and not from the real working directory.

For example with apktool, run apktool d apk_in_current_dir.apk and an error occurs:

Input file (C:\Users\User\scoop\apps\apktool\current\.\apk_in_current_dir.apk) was not found or was not readable.