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] --using/--pm don't do anything if overridden by a config file #677

Closed
00-kat opened this issue Jan 28, 2024 · 5 comments · Fixed by #678
Closed

[Bug] --using/--pm don't do anything if overridden by a config file #677

00-kat opened this issue Jan 28, 2024 · 5 comments · Fixed by #678
Assignees
Labels
bug Something isn't working

Comments

@00-kat
Copy link

00-kat commented Jan 28, 2024

Issue

Trying to use the --using or the --pm options to change the package manager have to effect if the setting is overridden by a config.toml.
I'm on Windows 10.

My config file (at ~\.config\pacaptr\pacaptr.toml looks like this:

# This enforces the use of `install` instead of
# `reinstall` in `pacaptr -S`
needed = true

# Explicitly set the default package manager
default_pm = "winget"

Expected Outcome

Using the --using or the --pm options changes the package manager (unless I'm using them wrong):

PowerShell 7.4.1
PS user@hostname:C:\Users\user> pacaptr -V
pacaptr v0.20.1
PS user@hostname:C:\Users\user> sudo pacaptr --using choco -Ss fastfetch
  Running `choco search fastfetch`
Chocolatey v2.2.2
0 packages found.
PS user@hostname:C:\Users\user> pacaptr --using scoop -Ss fastfetch
  Running `scoop search fastfetch`
Results from local buckets...

Name      Version Source Binaries
----      ------- ------ --------
fastfetch 2.7.0   main

PS user@hostname:C:\Users\user> pacaptr -Ss fastfetch
  Running `winget search --accept-source-agreements fastfetch`
No package found matching input criteria.
    Error Subprocess exited with code -1978335212

Actual Outcome

When I try to use Chocolatey or Scoop instead, it still runs Winget (P.S. Scoop has a package named fastfetch, while Chocolatey and Winget don't):

PowerShell 7.4.1
PS user@hostname:C:\Users\user> pacaptr -V
pacaptr v0.20.1
PS user@hostname:C:\Users\user> sudo pacaptr --using choco -Ss fastfetch
  Running `winget search --accept-source-agreements fastfetch`
No package found matching input criteria.
    Error Subprocess exited with code -1978335212
PS user@hostname:C:\Users\user> pacaptr --using scoop -Ss fastfetch
  Running `winget search --accept-source-agreements fastfetch`
No package found matching input criteria.
    Error Subprocess exited with code -1978335212
PS user@hostname:C:\Users\user> pacaptr -Ss fastfetch
  Running `winget search --accept-source-agreements fastfetch`
No package found matching input criteria.
    Error Subprocess exited with code -1978335212
@rami3l
Copy link
Owner

rami3l commented Jan 29, 2024

@cd-CreepArghhh Thanks for filing this issue!

This is indeed an unexpected behavior, however I'm no longer using Windows recently so maybe that's why it remains untouched.

I'll have a look into it and hopefully get a fix done real soon. Stay tuned!

@rami3l rami3l changed the title --using/--pm don't do anything if overridden by a config file [Bug] --using/--pm don't do anything if overridden by a config file Jan 29, 2024
@rami3l rami3l self-assigned this Jan 29, 2024
@rami3l rami3l added the bug Something isn't working label Jan 29, 2024
@rami3l
Copy link
Owner

rami3l commented Jan 29, 2024

Looks like a regression brought in #537. I guess the ideal precedence would be CLI flags > env vars > config, right?
cc @cd-CreepArghhh

@00-kat
Copy link
Author

00-kat commented Jan 29, 2024

I guess the ideal precedence would be CLI flags > env vars > config, right?

Yeah, that's what I thought would make the most sense.

@00-kat
Copy link
Author

00-kat commented Jan 29, 2024

By the way, I just installed pacaptr on WSL (Ubuntu) too, and the same problem still exists, so it's probably not a Windows-only issue, unless it's somehow an issue specific to Windows and WSL (which I doubt).

~/.config/pacaptr/pacaptr.toml:

# This enforces the use of `install` instead of
# `reinstall` in `pacaptr -S`
needed = true

# Explicitly set the default package manager
default_pm = "pip"
[I] user@hostname ~> pacaptr -Q
  Running `pip list`
Package                Version
---------------------- -------------
bla bla bla            1.0.0
more useful package    2.0.0
[I] user@hostname ~> pacaptr --using apt -Q
  Running `pip list`
Package                Version
---------------------- -------------
bla bla bla            1.0.0
more useful package    2.0.0

@rami3l
Copy link
Owner

rami3l commented Jan 29, 2024

@cd-CreepArghhh Yes, you're right. I meant to say that this feature is mostly intended for Windows users, but it's true that it could also be used on Linux (but maybe not as often), which is just a possible explanation for why it hasn't been reported till just then.

It'll be a very quick fix, nothing to be worried about on your side!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants