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] .jar shims change the working directory when running from cmd #6026

Open
davidpatel0 opened this issue Jun 23, 2024 · 1 comment
Open
Labels

Comments

@davidpatel0
Copy link

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

Scoop/lib/core.ps1

Lines 1012 to 1018 in d337bb1

} elseif ($path -match '\.jar$') {
warn_on_overwrite "$shim.cmd" $path
@(
"@rem $resolved_path",
"@cd /d $(Split-Path $resolved_path -Parent)"
"@java -jar `"$resolved_path`" $arg %*"
) -join "`r`n" | Out-UTF8File "$shim.cmd"

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
Copy link
Author

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.

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

No branches or pull requests

1 participant