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

using --config in cli fails, File not found #15768

Closed
dkebler opened this issue Dec 15, 2024 · 3 comments
Closed

using --config in cli fails, File not found #15768

dkebler opened this issue Dec 15, 2024 · 3 comments
Labels
bug Something isn't working needs triage

Comments

@dkebler
Copy link

dkebler commented Dec 15, 2024

What version of Bun is running?

1.1.38+bf2f153f5

What platform is your computer?

linux arch/manjaro. Linux 6.6.54-2-MANJARO x86_64 unknown

What steps can reproduce the bug?

--config is not working for me on linux, just upgraded to 1.1.38, still not working

this is my bash script to run bun
/opt/bun/bun --config /opt/bun/bunfig.toml "$@"

bun below is script above

bun --help
error: File not found: "/opt/bun/bunfig.toml"

bun binary and bunfig are indeed in /opt/bun

lla /opt/bun
total 94748
drwxrwxr-x+ 1 david david       36 Dec 14 16:21 ./
drwxr-xr-x+ 1 david david      738 Dec 14 16:21 ../
-rwxr-xr-x+ 1 david david 97014496 Dec 14 16:21 bun*
-rw-rw-r--+ 1 david david      486 Dec 14 16:01 bunfig.toml

you can even cat the toml file using same path

cat /opt/bun/bunfig.toml
[install]
#optional = true
#dev = true
#peer = true
#production = false
#exact = false
#auto = "auto"
#frozenLockfile = false
#dryRun = false
globalDir = "/opt/bun/global"
globalBinDir = "/opt/bin"

# Registry configuration
registry = "https://registry.npmjs.org"

[install.scopes]
@uci-utils = { username = "", password = "", url = "https://npm..net/" }

[install.cache]
dir = "/tmp/cache/bun"
disable = false
disableManifest = false

#[install.lockfile]
#save = true

### What is the expected behavior?

bun should read the config file from path given after the --config cli option.  

### What do you see instead?

`error: File not found: "/opt/bun/bunfig.toml"`

### Additional information

_No response_
@dkebler dkebler added bug Something isn't working needs triage labels Dec 15, 2024
@dkebler
Copy link
Author

dkebler commented Dec 15, 2024

looks like even though --config is available for all commands it must appear after the command which was not intuitive for me and makes it near impossible to have an alternative toml file for all commands. As long you are are willing to use ~/.bun all is fine but I want not to run bun as a particular user.

/opt/bun/bun add --config /opt/bun/bunfig.toml --global [email protected]:jsdoc2md/jsdoc-to-markdown.git [email protected]:jsdoc2md/jsdoc-to-markdown.git

and on top of that this fails.

/opt/bun/bun add --config /opt/bun/bunfig.toml --global  git+github.com/jsdoc2md/jsdoc-to-markdown
bun add v1.1.38 (bf2f153f)
error: unrecognised dependency format: git+github.com/jsdoc2md/jsdoc-to-markdown
david@seldon:[home/david] $ /opt/bun/bun add --config /opt/bun/bunfig.toml --global  [email protected]:jsdoc2md/jsdoc-to-markdown.git
bun add v1.1.38 (bf2f153f)
4 | "/opt/bun/bunfig.toml": "/opt/bun/bunfig.toml"
    ^
warn: Duplicate key "/opt/bun/bunfig.toml" in object literal
   at /home/david/.bun/install/global/package.json:4:1

4 | "/opt/bun/bunfig.toml": "/opt/bun/bunfig.toml"
    ^
warn: Duplicate dependency: "/opt/bun/bunfig.toml" specified in package.json
   at /home/david/.bun/install/global/package.json:4:1

3 | "/opt/bun/bunfig.toml": "",
                            ^
note: "/opt/bun/bunfig.toml" originally specified here
   at /home/david/.bun/install/global/package.json:3:25

error: ENOTDIR

note: error occured while resolving /opt/bun/bunfig.toml

error: GET https://registry.npmjs.org/%2fopt%2fbun%2fbunfig.toml - 405
error: /opt/bun/bunfig.toml@ failed to resolve
error: /opt/bun/bunfig.toml failed to resolve

@Jarred-Sumner
Copy link
Collaborator

for --config=path the = is not optional because there is parsing ambiguity whether it’s meant as a boolean to load the config or a specific path

yeah this is confusing

@Jarred-Sumner Jarred-Sumner closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2024
@dkebler
Copy link
Author

dkebler commented Dec 15, 2024

code is fine but the help was....not helpful :).

should indicate what you just wrote. It says nothing about using as a boolean only as specify path nor does it indicate that = is required when giving path.

so from
-c, --config Specify path to Bun config file. Default $cwd/bunfig.toml

to this
-c, --config As a boolean to load default or with a path, --config=/path/to/my.toml

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

No branches or pull requests

2 participants